Windows 7 – keyboard hooks stop working, a workaround

It seems that sometimes applications that install a keyboard hook (to monitor media keys, for instance) can randomly stop receiving the keyboard commands. I’ve seen this problem happen with the Groovie app. I’ve also heard of it happening with various music and video players.

It turns out to be a bug in Windows7; under full-load, the Operating System will not allow sufficient time for the hooks to process the messages and will remove them without notifying the application.

One workaround that I found was to increase the Hooks Timeout setting in the Windows registry:

Go to HKEY_CURRENT_USER\Control Panel\Desktop and set the LowLevelHooksTimeout to a larger value, I used 2710 (which is 10 seconds)

Hope this helps someone.

2 comments

  1. You don’t have to calculate hex values if you use regedit. You can simply switch from hex to deciamal input.
    This behavior is no bug. It should prevent Windows from a not responding state. 10 seconds is way too much time for hook handling!

    • While the idea is indeed to remove unresponsive/frozen apps, the implementation is buggy.
      Imagine having a process that runs with high priority. While it is busy, a keyboard message is sent but the background hook never gets a chance to process it because the first process is eating all the CPU cycles. This results in Windows removing the hook from its event chain, even though the hook never got the message.
      I’ve seen this happening with Photoshop running at full capacity. So yeah, it is a bug.

Leave a Reply

Your email address will not be published. Required fields are marked *