|
-
January 19th, 2010, 05:30 PM
#1
GetAsyncKeyState alternative for a process hotkey.
Well here's the situation I have injected a dll into a process, I want for example when I press F5 something to happen. I could use GetAsyncKeyState without a problem for that but that is system-wide i could press F5 in my VS and still the dll will toggle. I could make checks for foreground windows but I'm asking whether there is a sexier alternative that is process-wide ( accelerators won't work since I don't own a window except a message-only window and since windows only process keystrokes if focused my hidden window doesnt help me ). Something that could tell me whether a key is pressed within my process without mapping the windows messages I guess ( or a workaround to using accelerators with a message-only window).
Thanks in advance.
-
January 19th, 2010, 07:03 PM
#2
Re: GetAsyncKeyState alternative for a process hotkey.
It is not clear why you are avoiding to use windows messages approach (for example SetWindowsHookEx function).
-
January 20th, 2010, 02:43 AM
#3
Re: GetAsyncKeyState alternative for a process hotkey.
 Originally Posted by Armen
It is not clear why you are avoiding to use windows messages approach (for example SetWindowsHookEx function).
Well let me clarify this. My injected DLL has a console ( AllocConsole-ed), now the original application has its own window. I want my hotkey to be active whether the console has focus or the main window has focus. Consoles don't have a message queue so that's why I have made a message-only window ( to show a system tray icon for the console window etc ) but if it's not focused it won't receive any keystrokes notification or translate any accelerators and since it's hidden it can't be focused.
-
January 25th, 2010, 04:43 AM
#4
Re: GetAsyncKeyState alternative for a process hotkey.
Use RegisterHotKey. This hotkey will work everywhere in windows, your windows doesn't need focus for it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|