Exemple #1
0
        // # It is not possible to distinguish Keys.LControlKey and Keys.RControlKey when they are modifiers
        // Check for Keys.Control instead
        // Same for Shift and Alt(Menu)
        // See more at http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.framework.windowsforms/2008-04/msg00127.html #
        private static Keys AppendModifierStates(Keys keyData)
        {
            // Is Control being held down?
            bool control = ((KeyboardNativeMethods.GetKeyState(KeyboardNativeMethods.VK_LCONTROL) & 0x80) != 0) ||
                           ((KeyboardNativeMethods.GetKeyState(KeyboardNativeMethods.VK_RCONTROL) & 0x80) != 0);

            // Is Shift being held down?
            bool shift = ((KeyboardNativeMethods.GetKeyState(KeyboardNativeMethods.VK_LSHIFT) & 0x80) != 0) ||
                         ((KeyboardNativeMethods.GetKeyState(KeyboardNativeMethods.VK_RSHIFT) & 0x80) != 0);

            // Is Alt being held down?
            bool alt = ((KeyboardNativeMethods.GetKeyState(KeyboardNativeMethods.VK_LMENU) & 0x80) != 0) ||
                       ((KeyboardNativeMethods.GetKeyState(KeyboardNativeMethods.VK_RMENU) & 0x80) != 0);

            // Windows keys
            bool winL = ((KeyboardNativeMethods.GetKeyState(KeyboardNativeMethods.VK_LWIN) & 0x80) != 0);
            bool winR = ((KeyboardNativeMethods.GetKeyState(KeyboardNativeMethods.VK_RWIN) & 0x80) != 0);

            // Function (Fn) key
            // # CANNOT determine state due to conversion inside keyboard
            // See http://en.wikipedia.org/wiki/Fn_key#Technical_details #

            return(keyData |
                   (control ? Keys.Control : Keys.None) |
                   (shift ? Keys.Shift : Keys.None) |
                   (alt ? Keys.Alt : Keys.None) |
                   (winL ? Keys.LWin : Keys.None) |
                   (winR ? Keys.RWin : Keys.None));
        }
Exemple #2
0
 // Token: 0x060002D8 RID: 728 RVA: 0x0000357F File Offset: 0x0000177F
 private static bool CheckModifier(int vKey)
 {
     return(((int)KeyboardNativeMethods.GetKeyState(vKey) & 32768) > 0);
 }
Exemple #3
0
        // # It is not possible to distinguish Keys.LControlKey and Keys.RControlKey when they are modifiers
        // Check for Keys.Control instead
        // Same for Shift and Alt(Menu)
        // See more at http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.framework.windowsforms/2008-04/msg00127.html #

        // A shortcut to make life easier
        private static bool CheckModifier(int vKey)
        {
            return((KeyboardNativeMethods.GetKeyState(vKey) & 0x8000) > 0);
        }