Esempio n. 1
0
        public static void ControlMouse(int dx, int dy, bool leftClick)
        {
            INPUT[] inputs = new INPUT[2];

            inputs[0] = new INPUT();
            inputs[0].type = 0;
            inputs[0].mi.dx = dx;
            inputs[0].mi.dy = dy;
            inputs[0].mi.dwFlags = MOUSEEVENTF.MOVE;

            if (!leftClickDown && leftClick)
            {
                inputs[1] = new INPUT();
                inputs[1].type = 0;
                inputs[1].mi.dwFlags = MOUSEEVENTF.LEFTDOWN;
                leftClickDown = true;
            }
            else if (leftClickDown && !leftClick)
            {
                inputs[1] = new INPUT();
                inputs[1].type = 0;
                inputs[1].mi.dwFlags = MOUSEEVENTF.LEFTUP;
                leftClickDown = false;
            }

            SendInput(inputs.Length, inputs, INPUT.Size);
        }
Esempio n. 2
0
        public static void Move(int x, int y)
        {
            var dx = x * (65536 / System.Windows.SystemParameters.PrimaryScreenWidth);
            var dy = y * (65536 / System.Windows.SystemParameters.PrimaryScreenHeight);

            INPUT[] inputs = new INPUT[1];

            inputs[0] = new INPUT();
            inputs[0].type = 0;
            inputs[0].mi.dx = x;
            inputs[0].mi.dy = y;
            inputs[0].mi.dwFlags = MOUSEEVENTF.MOVE;

            SendInput(inputs.Length, inputs, INPUT.Size);
        }
Esempio n. 3
0
 private static extern uint SendInput(int nInputs, INPUT[] inputs, int size);
Esempio n. 4
0
 public static void LeftUp()
 {
     INPUT[] inputs = new INPUT[1];
     inputs[0] = new INPUT();
     inputs[0].type = 0;
     inputs[0].mi.dwFlags = MOUSEEVENTF.LEFTUP;
     SendInput(inputs.Length, inputs, INPUT.Size);
 }