Generating Keyboard events in another application

W

wesmanjunk

does anyone know how to generate keyboard events in another
application?

like
[DllImport ("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int
wParam, int lParam);

can be used for mouse events...

how would you do keyboard events?

assuming that the other appliation is not a dotNet application
 
M

Michael Cierkowski

You would use SendMessage also:

The follow will send a 'M' to the targetWindow

SendMessage(targetWindowHandle, WM_KEYDOWN, VK_M, 0)

Michael Cierkowski
 
W

wesmanjunk

i believe that SendMessage() is useful when you're not certain that the
application is visible but you want to send it a click anyway. It is
possible however for the receving application to determine that this
was in fact a "fake" keyboard event and consequently ignore it. is that
true.. i know that it is true for mouse events, which is why you'd
prefer to use mouse_event()... is the same also true for keyboard
events?

Michael said:
You would use SendMessage also:

The follow will send a 'M' to the targetWindow

SendMessage(targetWindowHandle, WM_KEYDOWN, VK_M, 0)

Michael Cierkowski

does anyone know how to generate keyboard events in another
application?

like
[DllImport ("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int
wParam, int lParam);

can be used for mouse events...

how would you do keyboard events?

assuming that the other appliation is not a dotNet application
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top