Example #1
0
 /// <summary>
 /// Moves the position of the mouse cursor relative to the current position.
 /// </summary>
 /// <param name="x">The amount of pixels the mouse cursor needs to be moved in the horizontal direction.</param>
 /// <param name="y">The amount of pixels the mouse cursor needs to be moved in the vertical direction.</param>
 public static void MouseMoveRelative(int x, int y)
 {
     win32.INPUT[] InputData = new win32.INPUT[1];
     InputData[0].type             = win32.INPUTTYPE.MOUSE;
     InputData[0].U.mi.dwFlags     = win32.MOUSEEVENTF.MOVE;
     InputData[0].U.mi.dx          = x;
     InputData[0].U.mi.dy          = y;
     InputData[0].U.mi.time        = 1;
     InputData[0].U.mi.dwExtraInfo = UIntPtr.Zero;
     win32.SendInput(1, InputData, Marshal.SizeOf(typeof(win32.INPUT)));
 }
Example #2
0
        public static void KeyUp(win32.ScanCodeShort scancode)
        {
            win32.INPUT[] InputData = new win32.INPUT[1];

            InputData[0].type             = win32.INPUTTYPE.KEYBOARD;
            InputData[0].U.ki.wScan       = scancode;
            InputData[0].U.ki.dwFlags     = win32.KEYEVENTF.KEYUP | win32.KEYEVENTF.SCANCODE;
            InputData[0].U.ki.time        = 1;
            InputData[0].U.ki.dwExtraInfo = UIntPtr.Zero;

            win32.SendInput(1, InputData, Marshal.SizeOf(typeof(win32.INPUT)));
        }
Example #3
0
        public static void MouseUp(MouseButton Button)
        {
            win32.INPUT[] InputData = new win32.INPUT[1];
            InputData[0].type = win32.INPUTTYPE.MOUSE;

            if (Button == MouseButton.Left)
            {
                InputData[0].U.mi.dwFlags = win32.MOUSEEVENTF.LEFTUP;
            }
            if (Button == MouseButton.Middle)
            {
                InputData[0].U.mi.dwFlags = win32.MOUSEEVENTF.MIDDLEUP;
            }
            if (Button == MouseButton.Right)
            {
                InputData[0].U.mi.dwFlags = win32.MOUSEEVENTF.RIGHTUP;
            }

            InputData[0].U.mi.time        = 1;
            InputData[0].U.mi.dwExtraInfo = UIntPtr.Zero;

            win32.SendInput(1, InputData, Marshal.SizeOf(typeof(win32.INPUT)));
        }