How to detect KeyPress while running a program in the background in Win32 C ++

I have a program that, when I minimize it, gets into the system tray.

I want to know the following: a) how can I detect a keystroke when my program is in the system tray. b) how can I find out that they press the function buttons on the keyboard.

+4
source share
2 answers

You need to configure the Windows hook using SetWindowsHookEx () and WH_KEYBOARDHOOK .

+7
source

If you know exactly what keystroke you expect, you can use RegisterHotkey and Windows will send you a message when that key is pressed.

If you want to detect all keystrokes, @OJ's answer will work.

+5
source

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


All Articles