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

doug

Senior member
Oct 18, 1999
259
0
0
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?
 

doug

Senior member
Oct 18, 1999
259
0
0
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?
 

RSMemphis

Golden Member
Oct 6, 2001
1,521
0
0
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.
 

bsobel

Moderator Emeritus<br>Elite Member
Dec 9, 2001
13,346
0
0
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