Exemple #1
0
        public static void SendMouseInput(bool leftDown)
        {
            Input[] i = new Input[1];

            // move the mouse to the position specified
            i[0] = new Input();
            i[0].Type = InputMouse;

            if (leftDown)
                i[0].MouseInput.Flags = MouseEventLeftDown;
            else
                i[0].MouseInput.Flags = MouseEventLeftUp;

            // send it off
            uint result = SendInput(1, i, Marshal.SizeOf(i[0]));
            if (result == 0)
                throw new Win32Exception(Marshal.GetLastWin32Error());
        }
Exemple #2
0
        public static void SendMouseInput(int positionX, int positionY, int maxX, int maxY)
        {
            if (positionX > int.MaxValue)
                throw new ArgumentOutOfRangeException("positionX");
            if (positionY > int.MaxValue)
                throw new ArgumentOutOfRangeException("positionY");

            Input[] i = new Input[1];

            // move the mouse to the position specified
            i[0] = new Input();
            i[0].Type = InputMouse;
            i[0].MouseInput.X = (positionX * 65535) / maxX;
            i[0].MouseInput.Y = (positionY * 65535) / maxY;
            i[0].MouseInput.Flags = MouseEventAbsolute | MouseEventMove;

            // send it off
            uint result = SendInput(1, i, Marshal.SizeOf(i[0]));
            if (result == 0)
                throw new Win32Exception(Marshal.GetLastWin32Error());
        }
Exemple #3
0
 private static extern uint SendInput(uint numInputs, Input[] inputs, int size);