Global hotkey release (keyup)? (WIN32 API)

后端 未结 2 1482
忘了有多久
忘了有多久 2020-12-10 15:50

Is there a way to notice the release of a hot-key button registered with RegisterHotKey?

I get a WM_HOTKEY message every time I press the h

相关标签:
2条回答
  • 2020-12-10 16:24

    There is no specific notification for that specific action. You will have to write a DLL that implements a global keyboard hook via SetWindowsHookEx(), then you will receive individual keypress up/down notifications and can match them up to your WM_HOTKEY notifications as needed.

    0 讨论(0)
  • Use RegisterHotkey to detect the key going down, then use polling with GetAsyncKeyState until the key is no longer down. This avoids the complexity of SetWindowsHookEx and the polling is generally acceptable since it is only done while the hotkey is being held down.

    0 讨论(0)
提交回复
热议问题