I am trying to hook the keyboard in my program, but there is something that I can't accomplish. The method below is the most important part in my class where I handle certain key combinations. All of them work, but I also want to hook Ctrl-Alt-Tab. I've spent hours trying to figure out what to do, but I came empty handed. How can I hook this combination as well?
More Information can be found here:
http://msdn.microsoft.com/en-us/library/ms644967(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms927178.aspx
private static IntPtr KeyboardHookHandler(int nCode, IntPtr wParam, KBDLLHookStruct lParam)
{
if (nCode == 0)
{
if ( ( (lParam.flags == 32) && (lParam.vkCode == 0x09) ) || // Alt+Tab
( (lParam.flags == 32) && (lParam.vkCode == 0x1B) ) || // Alt+Esc
( (lParam.flags == 0 ) && (lParam.vkCode == 0x1B) ) || // Ctrl+Esc
( (lParam.flags == 1 ) && (lParam.vkCode == 0x5B) ) || // Left Windows Key
( (lParam.flags == 1 ) && (lParam.vkCode == 0x5C) ) || // Right Windows Key
( (lParam.flags == 32) && (lParam.vkCode == 0x73) ) || // Alt+F4
( (lParam.flags == 32) && (lParam.vkCode == 0x20) )) // Alt+Space
{
return new IntPtr(1);
}
}
return CallNextHookEx(hookPtr, nCode, wParam, lParam);
}