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.
Re: GetAsyncKeyState alternative for a process hotkey.
It is not clear why you are avoiding to use windows messages approach (for example SetWindowsHookEx function).
Re: GetAsyncKeyState alternative for a process hotkey.
Quote:
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.
Re: GetAsyncKeyState alternative for a process hotkey.
Use RegisterHotKey. This hotkey will work everywhere in windows, your windows doesn't need focus for it.