Click here to Skip to main content
15,881,898 members
Articles / Desktop Programming / Win32
Tip/Trick

Change to Global Keyboard and Mouse Hooks behavior in Windows 7

Rate me:
Please Sign up or sign in to vote.
4.00/5 (6 votes)
19 Jan 2011CPOL1 min read 23K   4   3
This is probably why your global keyboard and mouse hooks stopped working on Windows 7
We've all written one of these apps at one time or another. You've got something that has to grab keyboard or mouse events globally for some reason. Maybe you're hotkeying something or logging what the user is doing with your app, ...

Everything worked fine under Windows XP or Vista, but now you're running into a problem where your hooks just mysteriously stop working. Maybe you're not getting any error messages, no crash, nothing in the event log, ... just nothing works!

Well, Microsoft thought it was a good idea to put a timeout in the code that calls your hook callback. I would tend to agree with them that something really did have to be done because a bad hook proc you may have written could bog down the entire system.

If you're having this little problem on Windows 7, you might want to read this[^] little blog post.

Apparently, Microsoft slipped this change into Windows 7 after its Beta was complete and just before the code went RTM. I wouldn't recommend taking this course of action in your own projects. Microsoft may have billions of dollars laying around to deal with a problem that crops up with a quick change that may be buggy like this, you probably don't.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Systems Engineer Blue Cross Blue Shield of Michigan
United States United States
I started out as a child. First, mastering drooling and sucking on a bottle. I soon discovered that these skills came to be very important later in life, and I put them to good use. Not "over the top" mind you, as I never drove home drunk. But, that damn bib catching my drool was getting in the way and turning the ladies away, so I had to abandon my strength and develop other skills.

So, I entered the world of geekdom. BASIC at first, then TMS9900 and Intel Assemblers, COBOL, C, C++, ...

... to be continued ...

Comments and Discussions

 
GeneralGreat article Pin
sprice869-Apr-14 1:14
professionalsprice869-Apr-14 1:14 
General+5 Excellent tip, Dave Pin
BillWoodruff29-Aug-11 21:04
professionalBillWoodruff29-Aug-11 21:04 
GeneralReason for my vote of 5 Good info, Dave ! Pin
BillWoodruff29-Aug-11 20:39
professionalBillWoodruff29-Aug-11 20:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.