C++ Hotkey to run function

2019-03-07 08:06发布

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条回答
贪生不怕死
2楼-- · 2019-03-07 08:45

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.

查看更多
登录 后发表回答