' Global hotkeys $TYPECHECK ON CONST WM_HOTKEY = &H312 CONST MOD_CTRL = &H2 CONST MOD_SHFT = &H4 CONST MOD_ALT = &H1 DECLARE FUNCTION RegisterHotKey LIB "USER32" ALIAS "RegisterHotKey" _ (hWnd AS LONG, ID AS LONG, fsModifiers AS LONG, _ vk AS LONG) AS LONG DECLARE FUNCTION UnRegisterHotKey LIB "USER32" ALIAS "UnregisterHotKey" _ (hWnd AS LONG, ID AS LONG) AS LONG DECLARE SUB SetForegroundWindow LIB "USER32" ALIAS "SetForegroundWindow" _ (HWnd AS LONG) DECLARE SUB FormWndProc (hWnd&, uMsg&, wParam&, lParam&) CREATE Form AS QFORM Center Caption = "Global hotkeys" WndProc = FormWndProc END CREATE '-- CTRL+A IF RegisterHotKey(Form.Handle, 0, MOD_CTRL, ASC("A")) = 0 THEN ShowMessage("Sorry, hot key CTRL+A already taken!") END IF '-- CTRL+SHIFT+B IF RegisterHotKey(Form.Handle, 1, MOD_CTRL OR MOD_SHFT, ASC("B")) = 0 THEN ShowMessage("Sorry, hot key CTRL+SHIFT+B already taken!") END IF Form.ShowModal UnRegisterHotKey(Form.Handle, 0) UnRegisterHotKey(Form.Handle, 1) SUB FormWndProc (hWnd&, uMsg&, wParam&, lParam&) IF uMsg& = WM_HOTKEY THEN SetForeGroundWindow(hWnd&) ShowMessage("Hotkey "+STR$(wParam&)+" hit!") END IF END SUB