Пример #1
0
        public static void ClickMouse(MouseButtons mouseButtons, Point point) {
            if (mouseButtons != MouseButtons.Left)
                throw new NotImplementedException();
            MoveMouse(point, MouseMovementEnum.RelativeToScreen);
            var input = new Win32Types.INPUT {
                Type = Win32Types.INPUTTYPE.INPUT_MOUSE,
                mi = {
                    dwFlags = Win32Constants.MouseEvent.MOUSEEVENTF_LEFTDOWN,
                    mouseData = 0,
                    time = 0,
                    dwExtraInfo = IntPtr.Zero
                }
            };

            Win32Declares.KeyBoard.SendInput(1, new[] { input }, Win32Types.MOUSEINPUT.cbSize);
            input.mi.dwFlags = Win32Constants.MouseEvent.MOUSEEVENTF_LEFTUP;
            Win32Declares.KeyBoard.SendInput(1, new[] { input }, Win32Types.MOUSEINPUT.cbSize);
            Application.DoEvents();
        }
Пример #2
0
 private static void pressKey(Win32Constants.VirtualKeys keys) {
     var input = new Win32Types.INPUT {
         Type = Win32Types.INPUTTYPE.INPUT_KEYBOARD,
         ki = {
             wVk = keys,
             dwFlags = Win32Constants.KeyboardEvent.KEYEVENTF_EXTENDEDKEY
         }
     };
     Win32Declares.KeyBoard.SendInput(1, new[] { input }, Win32Types.KEYBDINPUT.cbSize);
 }