Hi there,
I just bumped across this website through google and found it very neat. I am self taught at Delphi, and know very little. I know there are quite a few ways to send the virtual keypresses, but I only know of one and I doubt I am using it properly.
procedure TForm1.Timer1Timer(Sender: TObject);
var
Int10: Integer;
begin
if Odd(GetAsyncKeyState(VK_F10)) then //Hotkey on F10.
begin
Inc(Int10);
Timer2.Interval:=StrToInt(Edit1.Text);
end;
if odd(Int10) then //If on
begin
Timer2.Enabled:=True; //Enables the keypress.
end
else //If off
begin
Timer2.Enabled:=False;//Disables the keypress.
end;
end;
procedure TForm1.Timer2Timer(Sender: TObject);
var
Window:hwnd;
begin
Window:=FindWindowA('notepad',nil); //Finds notepad.
if Window<>0 then
begin
keybd_event(Ord('B'), 0, 0, 0);
end;
end;
I found Delphi Tricks and there are a few ways of sending key presses, however I do not understand them. I only want Keydown in this application so it holds down B. I have tried googling and found some other examples, but I'm not sure if I am incorporating them in properly.
I appreciate your assistance!
Sincerely,
Ab.
Post Scriptum: I apologize if I was not being specific enough.