I have used Stephen Toubs version of global keyboard hook, using it in a WIN 7 environment.
It works fine for a moment, and then it just stops receiving keystrokes.
I have increased the timeout value in regedit but it still disconnects after some time.
So problem is, how do I detect if it have been disconnected and how do I set the hook to be active again?
There is no way of knowing (from msdn):
One way you can work around this is to keep the timestamp of last message received and use background timer to add new hook after some time has passed from previous message.
Also, to minimize this happening your hook handling method should only collect minimum required information and leave the actual processing of the data to another thread.