View previous topic :: View next topic |
Author |
Message |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Mon Jan 19, 2009 4:26 am Post subject: Send key presses without making it focus? |
|
|
Does anyone know of a way to send key presses to another app window without it becoming the active window, or bringing it forward?
Thanks,
~Garrett _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
Back to top |
|
|
uvedese Contributor
Joined: 21 Jan 2006 Posts: 169 Location: Spain
|
Posted: Mon Jan 19, 2009 3:14 pm Post subject: |
|
|
Hi Garret.
When I send a string to an application it becoming automaticaly the active window.
The "dialog focus" command not activate our window. We must activate it... "window activate" |
|
Back to top |
|
|
nickos Valued Newbie
Joined: 17 Mar 2007 Posts: 26
|
|
Back to top |
|
|
vdsalchemist Admin Team
Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Mon Jan 19, 2009 7:32 pm Post subject: |
|
|
Garrett,
You have finally asked for something that is not possible in Windows. Windows uses the WM_KEYDOWN and WM_KEYUP API messages to tell a application that the users is typing on the keyboard. The issue is that windows only sends these messages to the active window. Windows will not send them to inactive windows. Micro$oft figures a user can only type in 1 window at a time since they only have 2 hands and 1 keyboard unless you know someone with more than that You could switch focus, send the keys, then switch back to your program.
Also what program are you trying to control? Is it something you wrote? _________________ Home of
Give VDS a new purpose!
|
|
Back to top |
|
|
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Tue Jan 20, 2009 10:56 am Post subject: |
|
|
dragonsphere wrote: | Garrett,
You have finally asked for something that is not possible in Windows. Windows uses the WM_KEYDOWN and WM_KEYUP API messages to tell a application that the users is typing on the keyboard. The issue is that windows only sends these messages to the active window. Windows will not send them to inactive windows. Micro$oft figures a user can only type in 1 window at a time since they only have 2 hands and 1 keyboard unless you know someone with more than that You could switch focus, send the keys, then switch back to your program.
Also what program are you trying to control? Is it something you wrote? |
Yeah, that program I just uploaded on the main vdsworld site. "Media Keyboard 2 Media Player".
What I'm doing is intercepting the media keys, such as play, pause, next, back, stop and sending those keys to some media players that do not have media key support.
I found out though while playing a full screen DX game that when I do that, it draws the darn media player out and takes me out of my game, thus getting me killed in the midst of combat! LOL
I already put a warning that this behavior may happen, so at least anyone who uses it knows it might happen. _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
Back to top |
|
|
vdsalchemist Admin Team
Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Tue Jan 20, 2009 2:14 pm Post subject: |
|
|
Garrett,
You may be able to call keybd_event API function to toggle those keyboard keys. SnarlingSheep has an example here on the forum showing how to use this function http://forum.vdsworld.com/viewtopic.php?t=2213&highlight=keybdevent There are other examples as well. This function may just send the keys to the active window though but you could try it. _________________ Home of
Give VDS a new purpose!
|
|
Back to top |
|
|
|