Windows键盘挂钩挂起调试器 [英] Windows keyboard hook hangs debugger
问题描述
SetWindowsHookEx()
,它的效果很好。 但是,如果我在Visual Studio中点了一个断点,挂钩处于活动状态,然后按一个键,Visual Studio和我的应用程序完全锁定。这是一个问题,因为我通常使用F-key来执行代码。如果我使用鼠标并从Visual Studio的调试菜单中向前移动,则可以正常工作。但是使用F10等是这样的习惯,我通常会忘记使用鼠标。
有什么可以做的来让我的键盘快捷键回来吗?或者一种不同的方法来听键盘?
这是非常不可避免的,调试器中断阻止钩子处理通知,所以键盘死了在另一台机器上使用远程调试器是调试这样的代码的好方法。您还需要增加挂机超时,以便Windows在调试时不会销毁挂钩,HKEY_CURRENT_USER\Control Panel\Desktop\LowLevelHooksTimeout设置。假设您正在使用WH_KEYBOARD_LL。
I have a plug-in DLL that is launched from a secondary (not GUI) thread in the main application. The DLL must grab keyboard events from the application's main window. I am using 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 lock up completely. This is a problem because I usually use the F-keys to step through code. If I use the mouse and step forward from Visual Studio's Debug menu, it works fine. But using F10 et al. is such a habit, I usually forget to use the mouse.
Is there anything I can do to get my keyboard shortcuts back? Or a different method to listen to the keyboard?
That's pretty inevitable, the debugger break stops the hook from handling notifications so the keyboard goes dead. Using the remote debugger on another machine is a good way to debug code like this. You'll also want to increase the hook timeout so Windows doesn't destroy the hook while you are debugging, HKEY_CURRENT_USER\Control Panel\Desktop\LowLevelHooksTimeout setting. Assuming you are using WH_KEYBOARD_LL.
这篇关于Windows键盘挂钩挂起调试器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!