I've been able to set local hotkeys like this
RegisterHotKey(hwndDlg, 100, MOD_ALT | MOD_CONTROL, 'S');
How can I set the hotkey to be global? I want it to be there even when my window is hidden.
I solved it myself but thanks for your reply here's what was wrong...
ShowWindow(hwndDlg, SW_HIDE);
RegisterHotKey(hwndDlg, 100, MOD_ALT | MOD_CONTROL, 'S');
if you register the hotkey first then hide the window... it ignores the hotkey for some reason... oh well.. it's working now :)
http://msdn.microsoft.com/ru-RU/library/windows/desktop/ms646309(v=vs.85).aspx
hWnd [in, optional]
Type: HWND
<...> If this parameter is NULL, WM_HOTKEY messages are posted to the message queue of the calling thread and must be processed in the message loop.
That is a better way for registering global hotkeys.
It desn't matter if your window is visible or not. You should not use a hWnd you plan to destory (like a dialog). Create a separate (invisible) window if you have no other suitable window.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With