Пример #1
0
        /// <summary>
        /// Lefts the click.
        /// </summary>
        /// <param name="xPoint">The x point.</param>
        private static void LeftClick(Point xPoint)
        {
            MOUSEINPUT xMouseInput = new MOUSEINPUT();
            INPUT      xInput      = new INPUT();
            //			MouseEventFlags xFlags= MouseEventFlags.LEFTDOWN&MouseEventFlags.LEFTUP&MouseEventFlags.ABSOLUTE&MouseEventFlags.ABSOLUTE;
            MouseEventFlags xFlags = MouseEventFlags.ABSOLUTE & MouseEventFlags.MOVE;

            xMouseInput.mouseData   = 0;
            xMouseInput.time        = 0;
            xMouseInput.dx          = xPoint.X;
            xMouseInput.dy          = xPoint.Y;
            xMouseInput.dwFlags     = (int)xFlags;
            xMouseInput.dwExtraInfo = IntPtr.Zero;

            xInput.mi   = xMouseInput;
            xInput.type = (int)InputType.Mouse;

            int xSize = Marshal.SizeOf(xInput);

            SendInput(1, new INPUT[] { xInput }, xSize);

            xInput.mi.dwFlags = (int)MouseEventFlags.LEFTDOWN;
            xMouseInput.dx    = 0;
            xMouseInput.dy    = 0;
            SendInput(1, new INPUT[] { xInput }, xSize);

            xInput.mi.dwFlags = (int)MouseEventFlags.LEFTUP;
            xMouseInput.dx    = 0;
            xMouseInput.dy    = 0;
            SendInput(1, new INPUT[] { xInput }, xSize);
        }
Пример #2
0
 public static int SendInput(MOUSEINPUT mi)
 {
     INPUT[] inputs = new INPUT[1];
     inputs[0].type     = 0 /*INPUT_MOUSE*/;
     inputs[0].union.mi = mi;
     return(SendInput(1, inputs, Marshal.SizeOf(inputs[0])));
 }
Пример #3
0
        internal static void SendMouseClickEvent(GestureEventType mouseEvent)
        {
            var mouse = new MOUSEINPUT();

            switch (mouseEvent)
            {
            case GestureEventType.MOUSE_LEFT_CLICK:
                mouse.dwFlags = (uint)MouseFlag.LEFTDOWN;
                SendMouseInput(mouse);
                mouse.dwFlags = (uint)MouseFlag.LEFTUP;
                SendMouseInput(mouse);
                break;

            case GestureEventType.MOUSE_MIDDLE_CLICK:
                mouse.dwFlags = (uint)MouseFlag.MIDDLEDOWN;
                SendMouseInput(mouse);
                mouse.dwFlags = (uint)MouseFlag.MIDDLEUP;
                SendMouseInput(mouse);
                break;

            case GestureEventType.MOUSE_RIGHT_CLICK:
                mouse.dwFlags = (uint)MouseFlag.RIGHTDOWN;
                SendMouseInput(mouse);
                mouse.dwFlags = (uint)MouseFlag.RIGHTUP;
                SendMouseInput(mouse);
                break;
            }
        }
Пример #4
0
        async Task MouseClick(int xpos, int ypos)
        {
            POINT client = new POINT();

            ClientToScreen(hWnd, ref client);

            MOUSEINPUT mi    = new MOUSEINPUT();
            INPUT      input = new INPUT();

            mi.dx        = (xpos + client.x) * (65535 / screenWidth);
            mi.dy        = (ypos + client.y) * (65535 / screenHeight);
            mi.mouseData = 0;
            mi.dwFlags   = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE | MOUSEEVENTF_LEFTDOWN;
            mi.time      = 0; mi.dwExtraInfo = 0;

            input.type = 0;
            input.mi   = mi;

            SendInput(1, ref input, Marshal.SizeOf(input));

            mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE | MOUSEEVENTF_LEFTUP;

            input.mi = mi;

            await Task.Delay(80);

            SendInput(1, ref input, Marshal.SizeOf(input));
        }
Пример #5
0
 public INPUT(UInt32 _type, UInt16 _wVk, UInt16 _wScan, UInt32 _dwFlags, UInt32 _time)
 {
     type = _type;
     mi   = new MOUSEINPUT();
     hi   = new HARDWAREINPUT();
     ki   = new KEYBDINPUT(_wVk, _wScan, _dwFlags, _time);
 }
Пример #6
0
        protected INPUT ToInput(MOUSEINPUT mouseInput)
        {
            var input = new INPUT();

            input.type = (int)InputType.INPUT_MOUSE;
            input.data.asMouseInput = mouseInput;
            return(input);
        }
Пример #7
0
        private MOUSEINPUT createMouseInput(int x, int y, uint data, uint t, uint flag)
        {
            MOUSEINPUT mi = new MOUSEINPUT();

            mi.mouseData = data;

            mi.dwFlags = MOUSEEVENTF_WHEEL;
            return(mi);
        }
Пример #8
0
        private MOUSEINPUT GetCreviceMouseInput()
        {
            var mouseInput = new MOUSEINPUT();

            // Set the CreviceApp signature to the mouse event
            mouseInput.dwExtraInfo = MOUSEEVENTF_CREVICE_APP;
            mouseInput.time        = 0;
            return(mouseInput);
        }
Пример #9
0
        private MOUSEINPUT createMouseInput(int x, int y, uint data, uint t, uint flag)
        {
            MOUSEINPUT mi = new MOUSEINPUT();

            mi.dx        = x;
            mi.dy        = y;
            mi.mouseData = data;
            mi.time      = t;
            mi.dwFlags   = flag;
            return(mi);
        }
Пример #10
0
        private static void setMouseInput(ref MOUSEINPUT mi, int?x, int?y)
        {
            if (x == null || y == null)
            {
                return;
            }
            RECT screen = Screen.GetVirtualScreenRect();

            mi.dx      = (int)((x - screen.left) * 65536 / (screen.right - screen.left)) + 1;
            mi.dy      = (int)((y - screen.top) * 65536 / (screen.bottom - screen.top)) + 1;
            mi.dwFlags = (uint)(MOUSEEVENTF.MOVE | MOUSEEVENTF.ABSOLUTE | MOUSEEVENTF.VIRTUALDESK);
        }
Пример #11
0
    private MOUSEINPUT createMouseInput(int x, int y, uint data, uint t, uint flag)
    {
        MOUSEINPUT mi = new MOUSEINPUT();

        mi.dx        = x;
        mi.dy        = y;
        mi.mouseData = data;
        mi.time      = t;
        //mi.dwFlags = MOUSEEVENTF_ABSOLUTE| MOUSEEVENTF_MOVE;
        mi.dwFlags = flag;
        return(mi);
    }
Пример #12
0
 public RawInput(MOUSEINPUT Data)
 {
     this.Data = new[] {
         new INPUT()
         {
             Type = INPUTTYPE.Mouse,
             Data = new INPUTUNION()
             {
                 Mouse = Data
             }
         }
     };
 }
Пример #13
0
        public MacroEvent_Mouse(MouseEvent _event, eMouseButton _button)
        {
            Event  = _event;
            Button = _button;

            INPUT keyInput = new INPUT();

            keyInput.type = 0;
            MOUSEINPUT mInput = new MOUSEINPUT();

            eMouseCommand command = eMouseCommand.Move;

            if (Button == eMouseButton.LDOWN)
            {
                command = eMouseCommand.LDown;
            }
            if (Button == eMouseButton.LUP)
            {
                command = eMouseCommand.LUp;
            }
            if (Button == eMouseButton.RDOWN)
            {
                command = eMouseCommand.RDown;
            }
            if (Button == eMouseButton.RUP)
            {
                command = eMouseCommand.RUp;
            }
            if (Button == eMouseButton.MWheel)
            {
                command = eMouseCommand.MWheel;
            }
            if (Button == eMouseButton.MHWheel)
            {
                command = eMouseCommand.HWHeel;
            }

            mInput.dx          = 0;
            mInput.dy          = 0;
            mInput.mouseData   = Event.mouseData;
            mInput.time        = 0;
            mInput.dwExtraInfo = Event.extraInfo;
            mInput.dwFlags     = (uint)command;

            keyInput.iUinion.mi = mInput;

            InputList[0] = keyInput;

            inputSize = Marshal.SizeOf(InputList[0]);
        }
Пример #14
0
        /*
         * Function that creates an INPUT structure to inject a mouse right button down event in the system queue.
         */
        public static INPUT mouseRightDown()
        {
            MOUSEINPUT mi = new MOUSEINPUT();

            mi.dwFlags     = MOUSEEVENTF.RIGHTDOWN;
            mi.dwExtraInfo = UIntPtr.Zero;

            INPUT inp = new INPUT();

            inp.type = INPUTYPE.INPUT_MOUSE;
            inp.U.mi = mi;

            return(inp);
        }
Пример #15
0
        /*
         * Function that creates an INPUT structure to inject a mouse middle button up event in the system queue.
         */
        public static INPUT middleUp()
        {
            MOUSEINPUT mi = new MOUSEINPUT();

            mi.dwFlags     = MOUSEEVENTF.MIDDLEUP;
            mi.dwExtraInfo = UIntPtr.Zero;

            INPUT inp = new INPUT();

            inp.type = INPUTYPE.INPUT_MOUSE;
            inp.U.mi = mi;

            return(inp);
        }
Пример #16
0
        /*
         * Function that creates an INPUT structure to inject a mouse wheel rotation event in the system queue.
         */
        public static INPUT mouseWheel(int wheelMov)
        {
            MOUSEINPUT mi = new MOUSEINPUT();

            mi.dwFlags     = MOUSEEVENTF.WHEEL;
            mi.mouseData   = wheelMov;
            mi.dwExtraInfo = UIntPtr.Zero;

            INPUT inp = new INPUT();

            inp.type = INPUTYPE.INPUT_MOUSE;
            inp.U.mi = mi;

            return(inp);
        }
Пример #17
0
        internal static MouseEventsHelper.MOUSEINPUT GetCurrentMouseInput()
        {
            var result = new MOUSEINPUT();

            double x;
            double y;
            var    win32CursorRange = 65535.0;

            GetCursorRelativePosition(out x, out y, win32CursorRange);

            result.dx = (int)x;
            result.dy = (int)y;

            return(result);
        }
Пример #18
0
 static public void SendMouseInput(MOUSEINPUT mouse)
 {
     INPUT[] inputs = new INPUT[]
     {
         new INPUT
         {
             type = INPUT_MOUSE,
             u    = new InputUnion
             {
                 mi = mouse,
             }
         }
     };
     SendInput((uint)inputs.Length, inputs, Marshal.SizeOf(typeof(INPUT)));
 }
Пример #19
0
        /*
         * Function that creates an INPUT structure to inject a mouse movement in the system queue.
         */
        public static INPUT mouseMovement(int x, int y)
        {
            MOUSEINPUT mi = new MOUSEINPUT();   /* INPUT will contain a MOUSEINPUT structure */

            mi.dx          = x;
            mi.dy          = y;
            mi.dwFlags     = MOUSEEVENTF.MOVE | MOUSEEVENTF.ABSOLUTE | MOUSEEVENTF.VIRTUALDESK;
            mi.dwExtraInfo = UIntPtr.Zero;  /* There are no extra info. */

            INPUT inp = new INPUT();

            inp.type = INPUTYPE.INPUT_MOUSE;
            inp.U.mi = mi;

            return(inp);
        }
Пример #20
0
        private Thread createThreadEvent(eventCallback callback, object sender, MOUSEINPUT data)
        {
            Thread hilo = new Thread(
                () =>
            {
                callback.Invoke(sender, data);
            }
                );

            hilo.SetApartmentState(ApartmentState.MTA);
            hilo.IsBackground   = true;
            hilo.CurrentCulture = System.Globalization.CultureInfo.CurrentCulture;
            hilo.Priority       = ThreadPriority.Normal;
            hilo.Name           = callback.ToString() + "Thread";

            return(hilo);
        }
Пример #21
0
        public static INPUT mouseMovement(int x, int y)
        {
            MOUSEINPUT mi = new MOUSEINPUT();
            Screen     s  = Screen.PrimaryScreen;
            int        dx = x * 65536 / s.Bounds.Width;
            int        dy = y * 65536 / s.Bounds.Height;

            mi.dx          = dx;
            mi.dy          = dy;
            mi.dwFlags     = MOUSEEVENTF.MOVE | MOUSEEVENTF.ABSOLUTE | MOUSEEVENTF.VIRTUALDESK;
            mi.dwExtraInfo = UIntPtr.Zero;

            INPUT inp = new INPUT();

            inp.type = 0x0000;
            inp.U.mi = mi;

            return(inp);
        }
Пример #22
0
        public static INPUT mouseClick(int x, int y)
        {
            MOUSEINPUT mi = new MOUSEINPUT();
            Screen     s  = Screen.PrimaryScreen;
            int        dx = x * 65536 / s.Bounds.Width;
            int        dy = y * 65536 / s.Bounds.Height;

            mi.dx          = dx;
            mi.dy          = dy;
            mi.dwFlags     = MOUSEEVENTF.LEFTDOWN | MOUSEEVENTF.LEFTUP;
            mi.dwExtraInfo = UIntPtr.Zero;

            INPUT inp = new INPUT();

            inp.type = 0x0000;
            inp.U.mi = mi;

            return(inp);
        }
Пример #23
0
        private void MoveMousePointer(Point point)
        {
            var mi = new MOUSEINPUT
            {
                dx          = point.X,
                dy          = point.Y,
                mouseData   = 0,
                time        = 0,
                dwFlags     = MouseEventFlags.MOVE,
                dwExtraInfo = UIntPtr.Zero
            };
            var input = new INPUT
            {
                mi   = mi,
                type = Convert.ToInt32(Win32Consts.INPUT_MOUSE)
            };

            SendInput(1, ref input, Marshal.SizeOf(input));
        }
Пример #24
0
        public static void MouseLeftPress(int x, int y)
        {
            MOUSEINPUT mouseinput = new MOUSEINPUT();

            mouseinput.X     = x * (65535 / Screen.PrimaryScreen.Bounds.Width);
            mouseinput.Y     = y * (65535 / Screen.PrimaryScreen.Bounds.Height);
            mouseinput.Flags = (uint)(MouseFlag.LEFTDOWN | MouseFlag.MOVE | MouseFlag.ABSOLUTE);
            var click = new INPUT();

            click.Type       = (UInt32)InputType.MOUSE;
            click.Data.Mouse = mouseinput;
            INPUT[] inputList = new INPUT[1];
            inputList[0] = click;
            var numberOfSuccessfulSimulatedInputs = InputSimulator.SendInput(1, inputList, Marshal.SizeOf(typeof(INPUT)));

            if (numberOfSuccessfulSimulatedInputs == 0)
            {
                throw new Exception("Mouse Click Failed");
            }
        }
        /// <summary>
        /// Click the left mouse button at the current cursor position using
        /// the imported SendInput function
        /// </summary>
        public static void ClickLeftMouseButtonSendInput()
        {
            //Initialise INPUT object with corresponding values for a left click
            MOUSEINPUT mouseinput = new MOUSEINPUT();

            mouseinput.type           = INPUT_MOUSE;
            mouseinput.mi.dx          = 0;
            mouseinput.mi.dy          = 0;
            mouseinput.mi.dwFlags     = MOUSEEVENTF_LEFTDOWN;
            mouseinput.mi.dwExtraInfo = IntPtr.Zero;
            mouseinput.mi.mouseData   = 0;
            mouseinput.mi.time        = 0;

            //Send a left click down followed by a left click up to simulate a
            //full left click
            SendInput(1, ref mouseinput, Marshal.SizeOf(mouseinput));
            Thread.Sleep(10); // Need for Windows to recognize a click
            mouseinput.mi.dwFlags = MOUSEEVENTF_LEFTUP;
            SendInput(1, ref mouseinput, Marshal.SizeOf(mouseinput));
        }
Пример #26
0
        private static void SendInput(int x, int y, uint data, MouseEventFlags flags)
        {
            System.Diagnostics.Debug.WriteLine(" In Mouse SendInput ");
            // correct permissions ?
            //   var permissions = new PermissionSet(PermissionState.Unrestricted);
            //   permissions.Demand();
            //    System.Diagnostics.Debug.WriteLine(" USED COORDS 1 :: " + x + " " + y);
            // Check if we are trying to do an absolute move
            if (flags.HasFlag(MouseEventFlags.MOUSEEVENTF_ABSOLUTE))
            {
                // Absolute position requires normalized coordinates
                NormalizeCoordinates(ref x, ref y);
                flags |= MouseEventFlags.MOUSEEVENTF_VIRTUALDESK;
            }

            // Build the mouse input object
            var mouseInput = new MOUSEINPUT
            {
                dx          = x,
                dy          = y,
                mouseData   = data,
                dwExtraInfo = User32.GetMessageExtraInfo(),
                time        = 0,
                dwFlags     = flags
            };

            // Build the input object
            var input = INPUT.MouseInput(mouseInput);

            // Send the command

            if (User32.SendInput(1, new[] { input }, INPUT.Size) == 0)
            {
                System.Diagnostics.Debug.WriteLine("error");
                var errorCode = Marshal.GetLastWin32Error();
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("click " + mouseInput.dx);
            }
        }
Пример #27
0
        ///<summary>
        /// 在x,y位置模拟鼠标点击
        ///</summary>
        ///<param name="dwFlagsDown">MOUSEEVENTF</param>
        ///<param name="dwFlagsUp">MOUSEEVENTF</param>
        ///<param name="x">点击的x坐标</param>
        ///<param name="y">点击的y坐标</param>
        public static void SendMouseLeftClick(int dwFlagsDown, int dwFlagsUp, int x, int y)
        {
            INPUT[]    input           = new INPUT[2];
            MOUSEINPUT mouseinput_down = new MOUSEINPUT();
            MOUSEINPUT mouseinput_up   = new MOUSEINPUT();

            mouseinput_down.dwFlags = dwFlagsDown;
            mouseinput_up.dwFlags   = dwFlagsUp;
            input[0].type           = (int)InputType.INPUT_MOUSE;
            input[0].mi             = mouseinput_down;
            input[1].type           = (int)InputType.INPUT_MOUSE;
            input[1].mi             = mouseinput_up;
            SetCursorPos(x, y);
            Thread.Sleep(2000);
            SendInput(1, input, Marshal.SizeOf(input[0])); //down
            SendInput(1, input, Marshal.SizeOf(input[1])); //up

            //  SendInput(1, input, Marshal.SizeOf(input[0]));//down
            //  Thread.Sleep(2000);
            //  SendInput(1, input, Marshal.SizeOf(input[1]));//up
        }
Пример #28
0
        public static void SendInput(MOUSEINPUT mouseInput)
        {
            // Demand the correct permissions
            var permissions = new PermissionSet(PermissionState.Unrestricted);

            permissions.Demand();

            var input = new INPUT
            {
                type = InputType.INPUT_MOUSE,
                u    = new INPUTUNION
                {
                    mi = mouseInput,
                },
            };

            // Send the command
            if (User32.SendInput(1, new[] { input }, INPUT.Size) == 0)
            {
                throw new Win32Exception();
            }
        }
Пример #29
0
        private void SendInput(int x, int y, uint data, MouseEventFlags flags)
        {
            // Demand the correct permissions
            var permissions = new PermissionSet(PermissionState.Unrestricted);

            permissions.Demand();

            // Check if we are trying to do an absolute move
            if (flags.HasFlag(MouseEventFlags.MOUSEEVENTF_ABSOLUTE))
            {
                // Absolute position requires normalized coordinates
                NormalizeCoordinates(ref x, ref y);
                flags |= MouseEventFlags.MOUSEEVENTF_VIRTUALDESK;
            }

            // Build the mouse input object
            var mouseInput = new MOUSEINPUT
            {
                dx          = x,
                dy          = y,
                mouseData   = data,
                dwExtraInfo = User32.GetMessageExtraInfo(),
                time        = 0,
                dwFlags     = flags
            };

            // Build the input object
            var input = INPUT.MouseInput(mouseInput);

            // Send the command
            if (User32.SendInput(1, new[] { input }, INPUT.Size) == 0)
            {
                // An error occured
                var errorCode = Marshal.GetLastWin32Error();
                return;
            }
        }
Пример #30
0
        public static void SendMouseUp(System.Windows.Forms.MouseEventArgs e)
        {
            MOUSEINPUT m = new MOUSEINPUT();
            m.dx = (IntPtr)0;
            m.dy = (IntPtr)0;
            m.mouseData = 0;
            m.time = (IntPtr)0;

            MOUSEEVENTF button = MOUSEEVENTF.LEFTUP;
            if (e.Button == MouseButtons.Right)
                button = MOUSEEVENTF.RIGHTUP;

            m.dwFlags = (IntPtr)(MOUSEEVENTF.ABSOLUTE | button);

            INPUT i = new INPUT();
            i.type = (IntPtr)INPUTF.MOUSE;
            i.mi = m;

            INPUT[] inputs = new INPUT[] { i };
            int isize = Marshal.SizeOf(i);
            SendInput(1, inputs, isize);
        }
Пример #31
0
        public static void SendMouseWheel(System.Windows.Forms.MouseEventArgs e)
        {
            MOUSEINPUT m = new MOUSEINPUT();
            m.dx = (IntPtr)0;
            m.dy = (IntPtr)0;
            m.mouseData = e.Delta;
            m.time = (IntPtr)0;

            MOUSEEVENTF button = MOUSEEVENTF.WHEEL;
            m.dwFlags = (IntPtr)(button);

            INPUT i = new INPUT();
            i.type = (IntPtr)INPUTF.MOUSE;
            i.mi = m;

            INPUT[] inputs = new INPUT[] { i };
            int isize = Marshal.SizeOf(i);
            SendInput(1, inputs, isize);
        }
Пример #32
0
 private MOUSEINPUT CreateMouseInput(int x, int y, uint data, uint t, uint flag)
 {
     MOUSEINPUT mi = new MOUSEINPUT();
     mi.dx = x;
     mi.dy = y;
     mi.mouseData = data;
     mi.time = t;
     //mi.dwFlags = MOUSEEVENTF_ABSOLUTE| MOUSEEVENTF_MOVE;
     mi.dwFlags = flag;
     return mi;
 }
Пример #33
0
 public static uint sendInput(MOUSEINPUT input)
 {
     var pInputs = new[] { 
         new INPUT()
         {
             type=2,
             inputunion=new InputUnion()
             {
                 mouseinput=input
             }
         }
     };
     return sendInput(pInputs);
 }
Пример #34
0
 internal static void AddMouseRollEvent(GestureEventType mouseEvent, double percentage, ref MOUSEINPUT mouse)
 {
     var velocity = 0.05;
     var sign = 1;
     var middleDistance = (percentage - 0.5);
     if (middleDistance < 0) sign = -1;
     var middleDistanceSquared = middleDistance * middleDistance * sign;
     switch (mouseEvent)
     {
         case GestureEventType.MOUSE_X_ABSOLUTE:
             var absoluteX = Math.Min((int)(percentage * 65535.0), 65535);
             mouse.dx = absoluteX;
             mouse.dwFlags |= (uint)MouseFlag.MOVE | (uint)MouseFlag.ABSOLUTE;
             break;
         case GestureEventType.MOUSE_Y_ABSOLUTE:
             var absoluteY = Math.Min((int)(percentage * 65535.0), 65535);
             mouse.dy = absoluteY;
             mouse.dwFlags |= (uint)MouseFlag.MOVE | (uint)MouseFlag.ABSOLUTE;
             break;
         case GestureEventType.MOUSE_WHEEL:
             // wheel data can be negative or positive
             // on this implementation it varies from -100 to 100
             var wheelMotion = (int)((percentage * 2 - 1.0) * 100);
             mouse.mouseData = (uint)wheelMotion;
             mouse.dwFlags |= (uint)MouseFlag.WHEEL;
             break;
         case GestureEventType.MOUSE_X_MOVE:
             // middleDistance * middleDistance guarantees a stable behavior around the middle
             var deltaX = (middleDistanceSquared * 65535.0) * velocity;
             mouse.dx = Math.Max(0, Math.Min(65535, (int)(mouse.dx + deltaX)));
             mouse.dwFlags |= (uint)MouseFlag.MOVE | (uint)MouseFlag.ABSOLUTE;
             break;
         case GestureEventType.MOUSE_Y_MOVE:
             // middleDistance * middleDistance guarantees a stable behavior around the middle
             var deltaY = (middleDistanceSquared * 65535.0) * velocity;
             mouse.dy = Math.Max(0, Math.Min(65535, (int)(mouse.dy + deltaY)));
             mouse.dwFlags |= (uint)MouseFlag.MOVE | (uint)MouseFlag.ABSOLUTE;
             break;
     }
 }
Пример #35
0
 private MOUSEINPUT createMouseInput(int x, int y, uint data, uint t, uint flag)
 {
     MOUSEINPUT mi = new MOUSEINPUT();
     mi.dx = x;
     mi.dy = y;
     mi.mouseData = data;
     mi.time = t;
     mi.dwFlags = flag;
     return mi;
 }
Пример #36
0
        public void MoveMouse(int in_dx, int in_dy)
        {
            MOUSEINPUT m = new MOUSEINPUT();
            m.dx = in_dx;
            m.dy = in_dy;
            m.dwFlags = MOUSEEVENTF_MOVE;

            INPUT input = new INPUT();
            input.type = INPUT_MOUSE;
            input.mi = m;

            INPUT[] lstInput = new INPUT[] { input };
            int iSize = Marshal.SizeOf(input);

            uint result = SendInput(1, lstInput, iSize);
            if (result != 1) throw new Exception("Could not move the mouse.");
        }
Пример #37
0
 internal static void SendMouseClickEvent(GestureEventType mouseEvent)
 {
     var mouse = new MOUSEINPUT();
     switch (mouseEvent)
     {
         case GestureEventType.MOUSE_LEFT_CLICK:
             mouse.dwFlags = (uint)MouseFlag.LEFTDOWN;
             SendMouseInput(mouse);
             mouse.dwFlags = (uint)MouseFlag.LEFTUP;
             SendMouseInput(mouse);
             break;
         case GestureEventType.MOUSE_MIDDLE_CLICK:
             mouse.dwFlags = (uint)MouseFlag.MIDDLEDOWN;
             SendMouseInput(mouse);
             mouse.dwFlags = (uint)MouseFlag.MIDDLEUP;
             SendMouseInput(mouse);
             break;
         case GestureEventType.MOUSE_RIGHT_CLICK:
             mouse.dwFlags = (uint)MouseFlag.RIGHTDOWN;
             SendMouseInput(mouse);
             mouse.dwFlags = (uint)MouseFlag.RIGHTUP;
             SendMouseInput(mouse);
             break;
     }
 }
Пример #38
0
        internal static MouseEventsHelper.MOUSEINPUT GetCurrentMouseInput()
        {
            var result = new MOUSEINPUT();

            double x;
            double y;
            var win32CursorRange = 65535.0;
            GetCursorRelativePosition(out x, out y, win32CursorRange);

            result.dx = (int)x;
            result.dy = (int)y;

            return result;
        }
Пример #39
0
 internal static extern int SendMouseInput(int cInputs, ref MOUSEINPUT pInputs, int cbSize);
Пример #40
0
 public static void SendMouseInput(MOUSEINPUT mouse)
 {
     INPUT[] inputs = new INPUT[]
     {
         new INPUT
         {
             type = INPUT_MOUSE,
             u = new InputUnion
             {
                 mi = mouse,
             }
         }
     };
     SendInput((uint)inputs.Length, inputs, Marshal.SizeOf(typeof(INPUT)));
 }
Пример #41
0
		internal static extern int SendMouseInput(int cInputs, ref MOUSEINPUT pInputs, int cbSize);
Пример #42
0
 public static uint sendInput(MOUSEINPUT[] inputs)
 {
     INPUT[] pInputs = new INPUT[inputs.Length];
     for(int i=0;i<inputs.Length;i++)
     {
         pInputs[i] = new INPUT()
         {
             type = 2,
             inputunion = new InputUnion()
             {
                 mouseinput = inputs[i]
             }
         };
     }
     return sendInput(pInputs);
 }