[英]Global hotkey release (keyup)? (WIN32 API)
Is there a way to notice the release of a hot-key button registered with RegisterHotKey
? 有没有办法注意到RegisterHotKey
的热键按钮的发布?
I get a WM_HOTKEY
message every time I press the hot-key but I need to know when the key was released 每次按热键时都会收到WM_HOTKEY
消息,但我需要知道密钥何时被释放
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. 您必须编写一个通过SetWindowsHookEx()
实现全局键盘钩子的DLL,然后您将收到单独的按键上/下通知,并且可以根据需要将它们与WM_HOTKEY
通知进行匹配。
Use RegisterHotkey
to detect the key going down, then use polling with GetAsyncKeyState
until the key is no longer down. 使用RegisterHotkey
检测关闭的密钥,然后使用GetAsyncKeyState
轮询,直到密钥不再关闭。 This avoids the complexity of SetWindowsHookEx
and the polling is generally acceptable since it is only done while the hotkey is being held down. 这避免了SetWindowsHookEx
的复杂性,并且轮询通常是可接受的,因为它仅在按住热键时完成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.