我正在尝试为键盘事件创建一个钩子,但是从不在键击上调用钩子。我设置了钩子:
HHOOK hookRes = SetWindowsHookEx( WH_KEYBOARD, &KeyStrokeHook, NULL, GetCurrentThreadId() );
回调函数是:
LRESULT CALLBACK KeyStrokeHook( _In_ int code, _In_ WPARAM wParam, _In_ LPARAM lParam )
{
if( code < 0 )
return CallNextHookEx( NULL, code, wParam, lParam );
if( lParam & 0x80000000 == 0 ) // If key pressed, not released
{
keyStroke = wParam;
SetEvent( keyEvent );
}
return CallNextHookEx( NULL, code, wParam, lParam );
}
hookRes
有一个有效的钩子,但从不调用钩子函数。
如果设置挂钩的线程当前在互斥锁上被阻塞,是否可以触发挂钩?