hotkey-detective icon indicating copy to clipboard operation
hotkey-detective copied to clipboard

Check if hotkeys registered with WM_SETHOTKEY should be checked too

Open ITachiLab opened this issue 2 years ago • 2 comments

RegisterHotKey isn't the only method that can be used to register a hotkey. Application can post WM_SETHOTKEY message to a window to assign a hotkey to it, but this is a different kind of hotkeys than hotkeys registered by using the mentioned system call.

Explore the topic and check if hotkeys registered with WM_SETHOTKEY are:

  • global,
  • blocking other combinations,
  • worth taking into account in HKD.

According to Microsoft documentation, the hotkey brings up the associated window into a foreground, but only when the message is passed to DefWindowProc. What happens when it is serviced by the application instead, and never makes it to the default window procedure?

Links

https://learn.microsoft.com/en-us/windows/win32/inputdev/wm-sethotkey https://learn.microsoft.com/en-us/windows/win32/menurc/wm-syscommand

ITachiLab avatar Jan 16 '23 16:01 ITachiLab

Hotkeys registered with WM_SETHOTKEY are indeed global, and can block key combinations equally the same as those registered with RegisterHotKey (verified with Hotkey Tester #27).

ITachiLab avatar Aug 22 '24 21:08 ITachiLab

When hotkey registered with WM_SETHOTKEY is pressed, two scenarios are possible:

  1. When the window, to which the hotkey is attached, is the active window (i.e. receives keyboard input), the window gets WM_SYSCOMMAND message, with SC_HOTKEY wParam.
  2. When the window is not active (background, minimized, etc.), the window gets WM_ACTIVATE message, but DO NOT gets SC_HOTKEY at this point.

That means tracking SC_HOTKEY is not enough. Hotkey Detective must spy for all windows receiving WM_ACTIVATE and then try to get the hotkey with WM_GETHOTKEY.

ITachiLab avatar Sep 06 '24 11:09 ITachiLab