shahab.dogar on Wed, 19 Sep 2018 03:10:42
Hi, I'm pretty new to C++ and am trying to make a program to automate some tasks. I want to spawn a new thread with a function call when I hit ctrl - but I am having some trouble figuring out how to get the ctrl - check. I looked at GetKeyState but it seems to only look at a single key. I'm not sure how to proceed with this and any help would be greatly appreciated
Viorel_ on Wed, 19 Sep 2018 07:02:29
Try this sequence:
RegisterHotKey( hwnd, 1, MOD_CONTROL | MOD_NOREPEAT, VK_SUBTRACT );
RegisterHotKey( hwnd, 2, MOD_CONTROL | MOD_NOREPEAT, VK_OEM_MINUS );
where hwnd is HWND of your window. The window will receive the WM_HOTKEY notification.
If you do not have a window, see the example where hwnd is NULL: https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-registerhotkey.