Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法注意到注册的热键按钮的释放RegisterHotKey?
RegisterHotKey
WM_HOTKEY每次按下热键时都会收到一条消息,但我需要知道该键何时释放
WM_HOTKEY
没有针对该特定操作的特定通知。您必须编写一个通过 实现全局键盘挂钩的 DLL SetWindowsHookEx(),然后您将收到单独的按键向上/向下通知,并可以WM_HOTKEY根据需要将它们与您的通知相匹配。
SetWindowsHookEx()
用于RegisterHotkey检测键关闭,然后使用轮询GetAsyncKeyState直到键不再关闭。这避免了轮询的复杂性,SetWindowsHookEx并且轮询通常是可以接受的,因为它仅在按住热键时进行。
RegisterHotkey
GetAsyncKeyState
SetWindowsHookEx