Exemplo n.º 1
0
        public static uint GetModifiers()
        {
            CfxEventFlags flags = CfxEventFlags.None;

            // triggered
            if ((DllImports.GetKeyState((int)Keys.CapsLock) & 65535) != 0)
            {
                flags |= CfxEventFlags.CapsLockOn;
            }
            if ((DllImports.GetKeyState((int)Keys.NumLock) & 65535) != 0)
            {
                flags |= CfxEventFlags.NumLockOn;
            }

            // down
            if ((DllImports.GetKeyState((int)Keys.LShiftKey) & 32768) == 32768)
            {
                flags |= CfxEventFlags.ShiftDown | CfxEventFlags.IsLeft;
            }
            if ((DllImports.GetKeyState((int)Keys.RShiftKey) & 32768) == 32768)
            {
                flags |= CfxEventFlags.ShiftDown | CfxEventFlags.IsRight;
            }

            if ((DllImports.GetKeyState((int)Keys.LControlKey) & 32768) == 32768)
            {
                flags |= CfxEventFlags.ControlDown | CfxEventFlags.IsLeft;
            }
            if ((DllImports.GetKeyState((int)Keys.RControlKey) & 32768) == 32768)
            {
                flags |= CfxEventFlags.ControlDown | CfxEventFlags.IsRight;
            }

            if ((DllImports.GetKeyState((int)Keys.LMenu) & 32768) == 32768)
            {
                flags |= CfxEventFlags.AltDown | CfxEventFlags.IsLeft;
            }
            if ((DllImports.GetKeyState((int)Keys.RMenu) & 32768) == 32768)
            {
                flags |= CfxEventFlags.AltDown | CfxEventFlags.IsRight;
            }

            if ((DllImports.GetKeyState((int)Keys.LButton) & 32768) == 32768)
            {
                flags |= CfxEventFlags.LeftMouseButton;
            }
            if ((DllImports.GetKeyState((int)Keys.MButton) & 32768) == 32768)
            {
                flags |= CfxEventFlags.MiddleMouseButton;
            }
            if ((DllImports.GetKeyState((int)Keys.RButton) & 32768) == 32768)
            {
                flags |= CfxEventFlags.RightMouseButton;
            }

            return((uint)flags);
        }