Systemwide Hotkeys Not Working For DirectX?

EliteELMO

Newcomer
Joined
Aug 3, 2005
Messages
6
I'm not sure if this is the category to drop this question under, so please move it if it's not.

I have a program that takes screenshots by using a hotkey (user defined - ALT, CTRL, SHIFT or WIN + a user-defined character). This works perfectly under any program EXCEPT directx programs. It works fine with OpenGL (Medal of Honor Allied Assault) but not at all with DirectX (Halo). It seems that DX just completely ignores all hotkeys. Is there a way I can set this up to recognize my hotkeys while directx is in the foreground and my program is minimized to the system tray? I even tried setting the program on top and hiding the form, and still no go.

I'd appreciate any feedback anyone has on this.

Thanks!
 
I'm not sure, but there is a way to disable global hotkeys this is most likely what Microsoft did in halo. Reason being if you use ALT as a strife moniter, and TAB is the score board if you are strifing and then try to view the score board you will ALT + TAB out of the game, which is annoying. You may want to look into enabling global hotkeys. And then enable them after you run the game. Just a thought.
 
No, it's in the program. There is a specific module in DirectX that ignores hotkeys. If the programmer that wrote the game chooses to use this method, there is nothing you can do about it. ;)
 
I just thought of it, you might be able to use the Windows API, and GetAsyncKeyState . It's just a thought I don't know if it would work or not. You could also try this website it may work even if 'hot keys' are disabled. http://www.codeguru.com/vb/gen/vb_system/keyboard/article.php/c4831/.

Visual Basic:
Private Declare Function GetAsyncKeyState Lib "user32" _
    (ByVal vKey As Integer) As Integer
 
I dont know the GetAsyncKeyState, but it sounds like you'd have to ask each key to see if it is pressed or not, several times per second.

Another way would be to use the LowLevelKeyboardProc API (sorry, dont have a declare ;), do have a link though : MSDN - LowLevelKeyboardProc ). This should allow you to put a hook into all keyboard input. This means that each time a key is pressed or released, windows calls a callback function you specified with the information of which key is pressed/released. Also, if you take a screenshot while in the callback, it will probably freeze all input from the keyboard until the screenshot has finished.

Be carefull though as this allows you to intercept keyboard commands before they are even handled by the application that actually receives them. Also make sure you remove the hook, I remember debugging and quiting an application with a hook still active. I was quite iritated that after the debugger had stopped and I pressed a key somehow the system stopped responding to the keyboard, either due to not cleaning up the hook in itself, or in combination with VB 5 ;). It took a reboot to correct this problem.

EDIT: Only just read the link to codeguru from Nate Bross. This is an article about using the lowlevelkeyboardproc to hook the keyboard action. So if you're curious about it, that article is a good read, including the declarations you'll need
 
Last edited:
Back
Top