Can any one tell me how can i stimulate key press on keyboard using API or

WH_KEYBOARD hook ???

Also is it possible for me to send keystrokes to another window(Like in VB) if so then

which API should be used ???
Posted on 2003-04-24 23:59:32 by telophase
What about sending the message WM_CHAR/WM_KEYDOWN/WM_KEYUP?
Posted on 2003-04-25 02:31:16 by roticv
the keybd_event API simulates keystrokes on a hardware level. It might fit your needs.
Posted on 2003-04-25 05:06:46 by Delight

Click here to get an example using the WM_CHAR technique.
Posted on 2003-04-25 05:17:33 by Vortex
The right way is:

invoke VkKeyScan, eax
mov ebx,eax
invoke keybd_event, ebx, 0, 0, 0
invoke keybd_event, ebx, 0, KEYEVENTF_KEYUP , 0

eax contains ASCII code of the symbol.

Remember that you MUST invoke "keybd_event" twice with the same scan code and KEYEVENTF_KEYUP flag for the second call. This is because if the next key is the same as previous no key event is generated.
Posted on 2003-04-25 06:28:53 by JohnFound
Maybe this would stimulate a keypress?

push 0
call blah1
db "Hi!",0
call blah2
db "Hello there! If you press (insert key of your choice here) now, I'll give you some candy... Come on, press the key, don't be afraid! If you don't press it, you'll regret it later on. I swear.",0
push 0
call MessageBoxA
Posted on 2003-04-25 13:27:34 by Sephiroth3
lol :tongue:
Posted on 2003-04-25 15:57:47 by Delight
how would you simulate a ctrl-v or ctrl-x btw?

and how would you properly subclass it?
Posted on 2003-04-25 23:44:41 by xkardisx
How can i stimulate key press of Ctrl+Alt+A??
Posted on 2003-04-26 10:10:53 by telophase
to stimulate alt use
invoke keybd_event, 18, 0, 0, 0   ;\\ Press 'ALT' Key

The numbers of alt and A I am not too sure. You go check it out.
Posted on 2003-04-26 11:09:18 by roticv
If you just want to send it to a specific window, send WM_KEYDOWN with wparam=VK_CONTROL, then send WM_SYSKEYDOWN and WM_SYSKEYUP with wparam='A', then WM_KEYUP with wparam=VK_CONTROL. You can send Ctrl+V and Ctrl+X in the same manner, but some controls will accept WM_PASTE and WM_CUT.
Posted on 2003-04-26 18:10:23 by Sephiroth3