Click here to Skip to main content
Click here to Skip to main content

Change to Global Keyboard and Mouse Hooks behavior in Windows 7

, 19 Jan 2011
Rate this:
Please Sign up or sign in to vote.
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)

About the Author

Dave Kreskowiak
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 Pinmembersprice869-Apr-14 1:14 
General+5 Excellent tip, Dave PinmemberBillWoodruff29-Aug-11 21:04 
GeneralReason for my vote of 5 Good info, Dave ! PinmemberBillWoodruff29-Aug-11 20:39 
Reason for my vote of 5
Good info, Dave !

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

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

| Advertise | Privacy | Mobile
Web04 | 2.8.140709.1 | Last Updated 19 Jan 2011
Article Copyright 2011 by Dave Kreskowiak
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid