Sign in to follow this  

SetWindowsHookEx works only when app is not active

This topic is 3569 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
(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)

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites

This topic is 3569 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this