How to programmatically determine the system hotkey?

I am looking for a way to programmatically detect hotkeys in a system. My application supports customizable hotkeys to do different things, and I would like to know if another application already hooked it or the built-in Windows hotkey (for example, Win-L to lock a workstation).

And if this is another application that owns a hotkey, I would like to show it to the user. At least the name is exe.

I know of three ways to create hotkeys:

  • Capture a system using standard APIs
  • Using the hotkey function in the properties dialog box for a shortcut
  • Asynchronous polling state status and response

I doubt I can detect the third type, but what about the other two? And are there other situations that I need to know about?

+3
source share
1 answer

I can imagine three ways to do this with the standard API:

  • Registerhotkey

  • SetWindowsHookEx (WH_KEYBOARD)

  • SetWindowsHookEx (WH_LL_KEYBOARD)

At the first approach, you will get a return value whether another application was already registered with the same hotkey (or the shortcut uses this hotkey, or Explorer.exe registered a hotkey because it is Win + E or win + R). You do not get the application name this way.

Windows Hooks async " ": , , (, "t" "", "Fris" ) . keybd_event ( ) , ""; , " ", , , .

, : , ( , , ). RegisterHotkey, ( ), " " .

+4

Source: https://habr.com/ru/post/1706333/


All Articles