By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,247 Members | 1,250 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,247 IT Pros & Developers. It's quick & easy.

Generating Keyboard events in another application

P: n/a
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

Nov 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
You would use SendMessage also:

The follow will send a 'M' to the targetWindow

SendMessage(targetWindowHandle, WM_KEYDOWN, VK_M, 0)

Michael Cierkowski

<we********@hotmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
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

Nov 17 '05 #2

P: n/a
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 Cierkowski wrote:
You would use SendMessage also:

The follow will send a 'M' to the targetWindow

SendMessage(targetWindowHandle, WM_KEYDOWN, VK_M, 0)

Michael Cierkowski

<we********@hotmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
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


Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.