How can I intercept Ctrl-Alt-Tab?

I am trying to connect a keyboard in my program, but there is something that I cannot perform. The method below is the most important part of my class, where I handle certain key combinations. They all work, but I also want to enable Ctrl-Alt-Tab. I spent hours trying to figure out what to do, but I came empty-handed. How can I intercept this combination?

Additional 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);
}
+3
source share
3 answers

, , lParam.flags, , -.

, , :

(lParam.flags == 32)

:

((lParam.flags & 32 == 32) && (lParam.flags & 16 == 16))

32 16 . , ALT CTRL. 1, 2, 4... 16, 32 .., .

+2

, , , Ctrl + Alt + Del . , .NET, CodeProject .

, , , .

0

You must subclass the win32 message pump.
You may get some ideas from this VC6 Trap project CtrlAltDel; Hide the application in the task list on Win2000 / XP

0
source

Source: https://habr.com/ru/post/1727868/


All Articles