SetWindowsHookEx WH_MOUSE_LL Hook only takes 1 mouse movement
c++, hook, mouse, windows
Solution
I have a breakpoint set
That's enough to explain the problem. The debugger will break of course. Which prevents further mouse messages from being delivered to the window with the focus. Windows puts up with that for 5 seconds, then unceremoniously disables your hook because it thinks your code is broken.
The timeout is configurable, you can use Regedit.exe to set the `HKEY_CURRENT_USER\Control Panel\Desktop\LowLevelHooksTimeout` value. Not present by default, add the DWORD value first. The unit is milliseconds.
Problem
I am setting a global hook with the following code: ``` SetWindowsHookEx(WH_MOUSE_LL, MouseProc, NULL, 0) ``` I have a breakpoint set so that when I first run the application I can see that the MouseProc method is called. This works but after the first time it is no longer called. Is the Hook automatically removed, how do I get this so that the hook automatically persists? I am writing this application for windows and this is a C++ win32 project.