SetWindowsHookEx works only when app is not active

Started by
7 comments, last by thedustbustr 16 years, 1 month ago
Hey! The titles says pretty much all there is to know about my problem. For a mysterious reason, my low level keyboard hook doesn't get called unless my window is not active. I use the exact same code as in the technical article "Disabling Shortcut Keys in Games" which can be found in the DirectX SDK's documentation. The only hypothesis I came up with is perhaps there's another hook installed which prevents mine from being called (since iiuc in order for all hokks to be called each one must nicely call the next one) Is there any way to know the hook installed on my exec? Did anyone here ever experienced the same behavior? Regards, JA
Advertisement
post YOUR code to be sure.

you're correct about hooks needing to 'be nice', but this is desired behavior. I wrote a screen capture application that suppresses printscreen after it gets hooked, so that it doesnt obliterate your clipboard unnecessarily.

fwiw, the most recently inserted hook should be at the front of the hook chain... which should be *your* hook. i doubt that is the problem.

You could be using the wrong hook type - are you sure you're using the WH_KEYBOARD_LL hook and not the regular WH_KEYBOARD hook?
Yup I'm 200% sure.

In fact I've identified the problem which is DirectInput. As soon as I do not initialize the keyboard, everything works correctly. I have tested all possible combinations of flags in SetCooperative level, none of which fixed the problem.

Theres an additional flag: "DISCL_NOWINKEY" but it seems to have no effect on windows Vista, or work only partially. I need the hook anyway to block stuff like ctrl+shif+esc, alt+tab, etc.
(And just so I don't get the usual "don't disable alt-tab" replay, I need to do this because the game is to run on kiosks in public places and no player should be able to use the computer for anything else but playing the game)
Why are you using DirectInput at all?
Yeah yeah yeah. You're right, I know. But I aint gonna start a refactoring of all my input code 2 weeks before the end of the project. This is the first time I have to ship a kiosk demo build and the incompatibility between DirectInput and SetWindowHookEx is documented like nowhere. I have to keep faith and believe that a solution exists...

Quote:Original post by janta
(And just so I don't get the usual "don't disable alt-tab" replay, I need to do this because the game is to run on kiosks in public places and no player should be able to use the computer for anything else but playing the game)


i dont necessarily think this is the way to do it. Doesn't windows have a kiosk mode?

All I know is that disabling Alt+Tab (as well as a bunch of other system key combinations) is part of Microsoft TCR. I hope I can get in touch with someone from microsoft tomorrow and ask them for advice, unless I find a solution on my own...
I assume you've googled...
registry solutions and other

Even simpler would be to put a hardware key interceptor between the keyboard and the PC.

This topic is closed to new replies.

Advertisement