Example #1
0
        public void SetKeyPressed(int code, bool pressed)
        {
            if (MyKeyDown[code] == pressed || code < 1 || code > 255)
            {
                return;
            }
            MyKeyDown[code] = pressed;
            var input = new MouseKeyIO.INPUT[1];

            input[0].type = MouseKeyIO.INPUT_KEYBOARD;

            if (pressed)
            {
                input[0].ki = KeyInput((ushort)code, extendedKeyMap.Contains(code) ? MouseKeyIO.KEYEVENTF_EXTENDEDKEY : 0);
            }
            else
            {
                if (extendedKeyMap.Contains(code))
                {
                    input[0].ki = KeyInput((ushort)code,
                                           MouseKeyIO.KEYEVENTF_EXTENDEDKEY | MouseKeyIO.KEYEVENTF_KEYUP);
                }
                else
                {
                    input[0].ki = KeyInput((ushort)code, MouseKeyIO.KEYEVENTF_KEYUP);
                }
            }
            MouseKeyIO.NativeMethods.SendInput(1, input, Marshal.SizeOf(input[0].GetType()));
        }
Example #2
0
        public void SetButtonPressed(int button, bool pressed)
        {
            if (MyKeyDown[button] == pressed)
            {
                return;
            }
            MyKeyDown[button] = pressed;

            uint btn_flag;
            int  mousedata  = 0;
            var  reelbutton = button - (int)Mouse.Left;
            var  up         = !pressed ? 2 : 1;

            if (reelbutton == 3 || reelbutton == 4)
            {
                mousedata = reelbutton - 3 + (int)MouseKeyIO.XBUTTON1;
            }

            btn_flag = (mousedata > 0 ? MouseKeyIO.MOUSEEVENTF_XDOWN : MouseKeyIO.MOUSEEVENTF_LEFTDOWN << (reelbutton * 2)) * (uint)up;

            var input = new MouseKeyIO.INPUT[1];

            input[0].type = MouseKeyIO.INPUT_MOUSE;
            input[0].mi   = MouseInput(0, 0, (uint)mousedata, 0, btn_flag);
            MouseKeyIO.NativeMethods.SendInput(1, input, Marshal.SizeOf(input[0].GetType()));
        }
Example #3
0
        private void setXY()
        {
            var input = new MouseKeyIO.INPUT[1];

            input[0].type = MouseKeyIO.INPUT_MOUSE;
            input[0].mi   = MouseInput(MouseX, MouseY, 0, 0, MouseKeyIO.MOUSEEVENTF_MOVE | MouseKeyIO.MOUSEEVENTF_ABSOLUTE);
            MouseKeyIO.NativeMethods.SendInput(1, input, Marshal.SizeOf(input[0].GetType()));
        }
Example #4
0
        //public double DeltaX
        //{
        //    set { deltaXOut = deltaXOut + value; }
        //    get { return CurrentMouseState.X; }
        //}

        //public double DeltaY
        //{
        //    set { deltaYOut = deltaYOut + value; }
        //    get { return CurrentMouseState.Y; }
        //}


        private void setWheel(int button)
        {
            int mousedata = WheelMax * (button == (int)Mouse.WheelBwd ? -1 : 1);
            var input     = new MouseKeyIO.INPUT[1];

            input[0].type = MouseKeyIO.INPUT_MOUSE;
            input[0].mi   = MouseInput(0, 0, (uint)mousedata, 0, MouseKeyIO.MOUSEEVENTF_WHEEL);
            MouseKeyIO.NativeMethods.SendInput(1, input, Marshal.SizeOf(input[0].GetType()));
        }
Example #5
0
        public void DragAndDrop(int x, int y)
        {
            var input = new MouseKeyIO.INPUT[3];

            input[0].type = MouseKeyIO.INPUT_MOUSE;
            input[0].mi   = MouseInput(0, 0, 0, 0, MouseKeyIO.MOUSEEVENTF_LEFTDOWN);
            input[1].type = MouseKeyIO.INPUT_MOUSE;
            var X = CalculateAbsoluteCoordinateX(x);
            var Y = CalculateAbsoluteCoordinateY(y);

            input[1].mi   = MouseInput(X, Y, 0, 0, MouseKeyIO.MOUSEEVENTF_MOVE | MouseKeyIO.MOUSEEVENTF_ABSOLUTE);
            input[2].type = MouseKeyIO.INPUT_MOUSE;
            input[2].mi   = MouseInput(0, 0, 0, 0, MouseKeyIO.MOUSEEVENTF_LEFTUP);
            MouseKeyIO.NativeMethods.SendInput(3, input, Marshal.SizeOf(input[0].GetType()));
        }