winapivisual-c++-2010

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


I got a program that whenever I minimize it, it goes to the system tray.

i want to know is this: a) how could i detect a key press while my program is in the system tray. b) how could I know what they press in the keyboard specifically the function buttons.


Solution

  • You need to set up a keyboard hook using SetWindowsHookEx(). Look at the WH_KEYBOARD and WH_KEYBOARD_LL hooks.