KBDLLHOOKSTRUCT *hooked=(KBDLLHOOKSTRUCT *)lParam;
if ((hooked->vkCode==0x4C && hooked->flags & LLKHF_ALTDOWN) && (hooked->vkCode==VK_RCONTROL||hooked->vkCode==VK_LCONTROL))
{
SendMessage(hWndMain, HM_LPRESSED, NULL, NULL);
return 1;
}
It seems that vkCode can only have one key being pressed. How should I rephrase this, so it sends the message when Ctrl+Alt+L is pressed?
Capturing Key combinations
Hey guys,
I''ve been working on this program for a couple of weeks. I have a keyboard hook and I would like to be able to catch the key combination Ctrl+Alt+L with it. I''ve tried this by using:
I had hoped it was, but only alt is in the the struct flag.
Nevermind, I found a way. I'm using :
GetAsyncKeyState (VK_CONTROL) >> ((sizeof(SHORT) * 8) - 1);
Gives me true if ctrl is pressed, then I can just add that to the test I had above.
Thanks
[edited by - Ranthalion on July 25, 2003 2:55:26 PM]
Nevermind, I found a way. I'm using :
GetAsyncKeyState (VK_CONTROL) >> ((sizeof(SHORT) * 8) - 1);
Gives me true if ctrl is pressed, then I can just add that to the test I had above.
Thanks
[edited by - Ranthalion on July 25, 2003 2:55:26 PM]
you don''t need a keyboard hook. just call RegisterHotKey for the required combination and you''ll get a WM_HOTKEY msg when the sequence is keyed. works for almost all key combinations.
btw, the low-level keyboard hook does give you control key up and down events, not flags. you have to track the control key up/down sequences yourself. the virtual-key codes are VK_LCONTROL and VK_RCONTROL. the Alt key is tracked via a separate flag since it has special meaning to the system (menu activation, window manager activation, task window, etc.)
I have newbie question about input; which has more overhead, directInput, or the Win32 API?
I''m not sure on this, but I would think that Direct Input has more overhead. But again, I''m not sure.
I need more than just a hot key because my hook also handles Alt+Tab, the Windows buttons,and Ctrl+Esc, stuff like that. I also need to be able to capture the key sequence when my program isn''t active or showing.
I need more than just a hot key because my hook also handles Alt+Tab, the Windows buttons,and Ctrl+Esc, stuff like that. I also need to be able to capture the key sequence when my program isn''t active or showing.
It didn''t work... Does anyone see any reason this would not perform appropriately?
I''m having the hardest time just trying to be notified if Ctrl+Alt+L is pressed in my Low Level Keyboard Hook.
#define KEYISDOWN(x) (GetAsyncKeyState(x) & 0x8000 ? true : false)KBDLLHOOKSTRUCT *hooked=(KBDLLHOOKSTRUCT *)lParam;if ((KEYISDOWN(VK_CONTROL) && KEYISDOWN(0x4C)) && hooked->flags & LLKHF_ALTDOWN) MessageBox(NULL, "Ctrl+Alt+L pressed", "Buttons", MB_OK);
I''m having the hardest time just trying to be notified if Ctrl+Alt+L is pressed in my Low Level Keyboard Hook.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement