Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

C# Ctrl + Esc disabled but cannot enable the Esc key

$
0
0
I have following the function which disables windows key, alt-tab, alt+esc, ctrl+esc etc:

        public static int HookCallback(int nCode, int wParam, ref KBDLLHOOKSTRUCT lParam)
        {
            bool blnEat = false;

            switch (wParam)
            {
                case 260:
                case 256:
                case 257:
                case 261:
                    //Alt+Tab, Alt+Esc, Ctrl+Esc, Windows Key,
                    blnEat = ((lParam.vkCode == 9) && (lParam.flags == 32))  // alt+tab
                             |
                             ((lParam.vkCode == 27) && (lParam.flags == 32)) // alt+esc
                             |
                             ((lParam.vkCode == 27) && (lParam.flags == 0))  // ctrl+esc
                             |
                             ((lParam.vkCode == 91) && (lParam.flags == 1))  // left winkey
                             |
                             ((lParam.vkCode == 92) && (lParam.flags == 1));

                    break;
            }

            if (blnEat == true)
            {
                return 1;
            }
            else
            {
                return CallNextHookEx(0, nCode, wParam, ref lParam);
            }
        }



This line of code disables Ctrl + Esc (which brings up the start menu)
((lParam.vkCode == 27) && (lParam.flags == 0))  



Unfortunately this disables the Esc key on its own. I actually want to be able to use the ESC key on its own but have the problem of also requiring Ctrl+Esc combination to be disabled. Is there another method I could use?

Thanks,

Andy

Viewing all articles
Browse latest Browse all 51036

Trending Articles