Windows keyboard key hangs by debugger

I have a pluggable DLL that runs from a secondary (non-GUI) thread in the main application. The DLL must capture keyboard events from the main application window. I use SetWindowsHookEx()

and it works great.

However, if I hit a breakpoint in Visual Studio while the hook is active and then press a key, Visual Studio and my application are completely blocked. This is a problem because I usually use the F keys to navigate through code. If I use the mouse and step by step from the Visual Studio Debug menu, it works fine. But using F10 et al. such a habit, I usually forget to use the mouse.

Is there anything I can do to get my keyboard shortcuts back? Or another way to listen to the keyboard?

+3


source to share


1 answer


It's pretty inevitable, breaking the debugger stops the hook from handling notifications, so the keyboard comes off. Using a remote debugger on another computer is a good way to debug code like this. You will also want to increase the connection timeout so that Windows does not kill the hook while debugging, HKEY_CURRENT_USER \ Control Panel \ Desktop \ LowLevelHooksTimeout. Assuming you are using WH_KEYBOARD_LL.



+4


source







All Articles