Ejemplo n.º 1
0
        /// <summary>
        /// Sets the current cursor position to the passed in coordinates on the virtual desktop.
        /// </summary>
        /// <param name="x">The X coordinate to use.</param>
        /// <param name="y">The Y coordinate to use.</param>
        public static void SetCursorPosition(int x, int y)
        {
            // get normalized values
            double normalizedY;
            double normalizedX;
            NormalizeCoordinates(x, y, out normalizedY, out normalizedX);

            // prepare mouse move input
            Win32.MOUSEINPUT mouseInput = new Win32.MOUSEINPUT();
            mouseInput.dx = (int)Math.Round(normalizedX);
            mouseInput.dy = (int)Math.Round(normalizedY);
            mouseInput.dwFlags = (int)Win32.Constants.MOUSEEVENTF_ABSOLUTE | (int)Win32.Constants.MOUSEEVENTF_VIRTUALDESK | (int)Win32.Constants.MOUSEEVENTF_MOVE;

            SendMouseInput(mouseInput);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sends mouse right button down input, followed by mouse right button up input, to the operating system.
        /// </summary>
        public static void SendMouseRightButtonClick()
        {
            // prepare and send mouse left button down
            Win32.MOUSEINPUT mouseInput = new Win32.MOUSEINPUT();
            mouseInput.dwFlags = (int)Win32.Constants.MOUSEEVENTF_ABSOLUTE | (int)Win32.Constants.MOUSEEVENTF_VIRTUALDESK | (int)Win32.Constants.MOUSEEVENTF_RIGHTDOWN;

            SendMouseInput(mouseInput);

            // prepare and send mouse left button up
            mouseInput = new Win32.MOUSEINPUT();
            mouseInput.dwFlags = (int)Win32.Constants.MOUSEEVENTF_ABSOLUTE | (int)Win32.Constants.MOUSEEVENTF_VIRTUALDESK | (int)Win32.Constants.MOUSEEVENTF_RIGHTUP;

            SendMouseInput(mouseInput);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Sends mouse wheel input to the operating system, using the given ticks amount.
        /// </summary>
        /// <param name="ticks">The ticks amount to send.</param>
        public static void SendMouseWheel(int ticks)
        {
            // prepare and send mouse wheel data
            Win32.MOUSEINPUT mouseInput = new Win32.MOUSEINPUT();
            mouseInput.dwFlags = (int)Win32.Constants.MOUSEEVENTF_WHEEL;
            mouseInput.mouseData = (uint)ticks * Win32.Constants.WHEEL_DELTA;

            SendMouseInput(mouseInput);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Sends mouse left button up input to the operating system.
        /// </summary>
        public static void SendMouseLeftButtonUp()
        {
            // prepare and send mouse left button up
            Win32.MOUSEINPUT mouseInput = new Win32.MOUSEINPUT();
            mouseInput.dwFlags = (int)Win32.Constants.MOUSEEVENTF_ABSOLUTE | (int)Win32.Constants.MOUSEEVENTF_VIRTUALDESK | (int)Win32.Constants.MOUSEEVENTF_LEFTUP;

            SendMouseInput(mouseInput);
        }