// The hWnd is the window which will be notified when the hotkey was pressed.
int hotkeyId1 = 1; // Every hotkey in a thread should have a unique ID...
// The window procedure should look something like this: switch(msg) { case HOTKEY: switch ((int)wParam) { case hotkeyId1: MessageBox(NULL, "Ctrl+Alt+F5 was hit", "Hotkey", MB_OK); break; } break; . . }
// Add the hotkey:
// You can use MOD_CONTROL, MOD_ALT, MOD_SHIFT or MOD_WIN. // Last variable is simply the VK. if (RegisterHotkey(hWnd, hotkeyId1, MOD_CONTROL | MOD_ALT, VK_F5) == 0) { // Error }
// Remove the hotkey: UnregisterHotkey(hWnd, hotkeyId1); |