I need a little help on hotkeys. That is, how can i turn say CTRL-ALT-F1 into a hotkey, then check it at runtime. I suppose it's RegisterHotKey at the program's initialisation, then check for WM_HOTKEY in the mesage loop. Also, how can this be done by setting a keyboard hook? Code snippets would be highly appreciated. Thank you in advance, tank_ ;)
Posted on 2001-03-20 17:52:00 by tank_
what you supposed is right. do as following to register a CTRL+Alt+F1 hotkey:

invoke RegisterHotKey,hWin,065h,MOD_CONTROL or MOD_ALT,VK_F1
(65h is the identifier) then just wait for the WM_HOTKEY message. if you have more than one hotkey you just have to check wParam for the identifier. if you don't need the hotkey anymore, don't forget to UnregisterHotKey i think that this method is much easier than setting a keyboard hook. but if you're interested in how to set keyboard hooks in general, have a look at my program (-log) on my website.
Posted on 2001-03-21 03:50:00 by [SaFc0n]
Well, i have followed the instructions but wasn't able to register it. Maybe someone could post a small listing of an app that actually registers a key combination. thank you tank_ out:D
Posted on 2001-03-22 18:13:00 by tank_
Hi, ;------------------------------------------------------------------------------ ; API "RegisterHotKey" defines a hot key for the current thread ;------------------------------------------------------------------------------ push 1Bh ;uVirtKey, virtual-key code, VK_ESCAPE=1Bh push 0h ;fuModifiers, key-modifier flags push 0B00h ;idHotKey, identifier of hot key push WP1_hWnd ;hwnd, window receive hot-key notification call RegisterHotKey ;- API Function - In your Window Proc check the WM_HOTKEY (value=312h) message. WM_HOTKEY : idHotKey = (int) wParam; // identifier of hot key fuModifiers = (UINT) LOWORD(lParam); // key-modifier flags uVirtKey = (UINT) HIWORD(lParam); // virtual-key code ;============================================================================== ; WM_HOTKEY (value=312h) message received ? ;------------------------------------------------------------------------------ WP1_uMsg_312h: cmp eax,312h ;check if WM_HOTKEY message recieved jne WP1_return ;if not goto label jmp WP1_return Test
Posted on 2001-03-23 02:58:00 by Test Department