Search code examples
c++winapihwndregisterhotkey

Global hotkey with WIN32 API?


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.


Solution

  • 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 :)