• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

C++ Program to do Hotkey during a game, not working

doug

Senior member
I wrote a little application that uses hotkeys, I was hoping to be able to do some functions while playing half-life.

So here is my problem: The application works fine on W2K but on Win98 when the game isn't running it works but does not work when the game is running. I'm using Visual C++ 6 on W2K for development.


I use GlobalAddAtom() and RegisterHotKey() to register the hotkey.
I use NULL for the HWND (handle to window).

In my WinMain message loop (while (GetMessage(&msg, NULL, 0, 0))) I look for the WM_HOTKEY message.

Anyoe know why this doesn't work on Win98?
 
So anyone ever create a program that uses global hotkeys at all?
If so does yours work all the time or do other programs prevent it from working?
 
Your problem most likely is that directx fetches the key event and therefore just by setting a key in the registry you cannot get something else running, I think.
Your application would most likely have to listen to all the key events going on (which I think is possible even when you don't have the focus) and do it that way.

Hope this makes some sense.
 
Yea, I think you'll need a keyboard hook, or maybe even a low level keyboard hook to do what you want. See SetWindowsHookEx() for more info.
Bill
 
Back
Top