Exemple #1
0
        private global::System.Windows.Forms.Keys TranslateKey(IntPtr LParam, global::System.Windows.Forms.Keys Key)
        {
            var extended = ((int)LParam & 0x01000000) != 0;
            var realCode = Key;

            if (realCode == global::System.Windows.Forms.Keys.ControlKey)
            {
                realCode = extended ? global::System.Windows.Forms.Keys.RControlKey : global::System.Windows.Forms.Keys.LControlKey;
            }
            if (realCode == global::System.Windows.Forms.Keys.ShiftKey)
            {
                //Grab the scan code from LParam... Who would have thought just telling
                // left and right shift apart would be such a PITA?
                var scanCode = ((int)LParam & 0xff0000) >> 16;
                if (scanCode == 42)
                {
                    return(global::System.Windows.Forms.Keys.LShiftKey);
                }
                if (scanCode == 54)
                {
                    return(global::System.Windows.Forms.Keys.RShiftKey);
                }
                throw new InvalidOperationException();
            }
            return(realCode);
        }
Exemple #2
0
 public static extern short GetAsyncKeyState(global::System.Windows.Forms.Keys vKey);