问题
Hey looking to assign F1 as a hotkey to run a function. I have a windows 32 project with a Form, however the form will be in the background and not the active window when I press F1.
Is there a way to code a hotkey or shortcut so when I press F1 it will run that function even if the Form1 isn't active?
回答1:
Have a look at the RegisterHotKey function.
It allows you to define a system-wide hot key. When the hot key is pressed, you will receive a WM_HOTKEY
message even if your window is not active.
来源:https://stackoverflow.com/questions/44078608/c-hotkey-to-run-function