Mastodon
Programmierung

Keyb_event (simulating Keypress part 2)

> I’ve already got a handle of another application’s window. Now, how can I
> simulate a keyboard input of ‘ALT-R’ to it?
> Thank you.

Use the keyb_event function:

[code lang=”delphi”]// press:
keyb_event(VK_MENU,0,0,0);
keyb_event(Ord(‘R’),0,0,0);
// release:
keyb_event(Ord(‘R’),0,KEYEVENTF_KEYUP,0);
keyb_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
[/code]

—–8<-------snip-------8<----------snap---------- > I know this a dumb question but how do I make the system think the user
> pressed Enter from somewhere other than the onKeypress or OnKeyDown events?

[code lang=”delphi”] {Key Down}
keybd_Event(VK_RETURN, 0, 0, 0) ;
Sleep(100);
{Key Up}
keybd_Event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
[/code]

[tags]Delphi, Misc[/tags]

0 Kommentare zu “Keyb_event (simulating Keypress part 2)

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.