示例#1
0
 public RouteHandler_MouseClick(
     ILogger log,
     IMouseSimulator mouseSimulator
     ) : base(log)
 {
     this.mouseSimulator = mouseSimulator;
 }
示例#2
0
 public ControllerAsInput()
 {
     _controller        = new Controller(UserIndex.One);
     _mouseSimulator    = new InputSimulator().Mouse;
     _keyboardSimulator = new InputSimulator().Keyboard;
     _timer             = new Timer(obj => Update());
 }
示例#3
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="InputSimulator" /> class using the specified
 ///     <see cref="IKeyboardSimulator" />, <see cref="IMouseSimulator" /> and <see cref="IInputDeviceStateAdaptor" />
 ///     instances.
 /// </summary>
 /// <param name="keyboardSimulator">The <see cref="IKeyboardSimulator" /> instance to use for simulating keyboard input.</param>
 /// <param name="mouseSimulator">The <see cref="IMouseSimulator" /> instance to use for simulating mouse input.</param>
 /// <param name="inputDeviceStateAdaptor">
 ///     The <see cref="IInputDeviceStateAdaptor" /> instance to use for interpreting the
 ///     state of input devices.
 /// </param>
 public InputSimulator(IKeyboardSimulator keyboardSimulator, IMouseSimulator mouseSimulator,
                       IInputDeviceStateAdaptor inputDeviceStateAdaptor)
 {
     _keyboardSimulator = keyboardSimulator;
     _mouseSimulator    = mouseSimulator;
     _inputDeviceState  = inputDeviceStateAdaptor;
 }
 public XBoxControllerAsMouse()
 {
     _controller        = new Controller(UserIndex.One);
     _mouseSimulator    = new InputSimulator().Mouse;
     _keyboardSimulator = new InputSimulator().Keyboard;
     _timer             = new System.Threading.Timer(obj => Update());
 }
 public InputSimulator(IKeyboardSimulator keyboardSimulator, IMouseSimulator mouseSimulator,
                       IInputDeviceStateAdaptor inputDeviceStateAdaptor)
 {
     Keyboard         = keyboardSimulator;
     Mouse            = mouseSimulator;
     InputDeviceState = inputDeviceStateAdaptor;
 }
示例#6
0
 public KeyPlayer(Stopwatch stopwatch, LevelProfile levelProfile)
 {
     _stopwatch    = stopwatch;
     _keyboard     = new InputSimulator().Keyboard;
     _mouse        = new InputSimulator().Mouse;
     _levelProfile = levelProfile;
 }
示例#7
0
 public CodedUiUiNavigationProvider(IMouseSimulator mouseSimulator, IKeyboardSimulator keyboardSimulator, ISettings settings, ILogger logger)
 {
     this.mouse    = mouseSimulator;
     this.keyboard = keyboardSimulator;
     this.settings = settings;
     this.logger   = logger;
 }
示例#8
0
 public ActionFactory(RootConfiguration config, IKeyboardSimulator keyboard, IMouseSimulator mouse, IMenuController menuController)
 {
     Config         = config;
     Keyboard       = keyboard;
     Mouse          = mouse;
     MenuController = menuController;
 }
示例#9
0
        public ManipularItens()
        {
            var input = new InputSimulator();

            mouse     = input.Mouse;
            teclado   = input.Keyboard;
            movimento = new MovimentosMouse();
        }
示例#10
0
文件: AppTarget.cs 项目: burstas/rmps
        public AppTarget(UserModel userModel)
        {
            _UserModel = userModel;

            _KeyboardSimulator = new KeyboardSimulator();
            _MouseSimulator = new MouseSimulator();
            _InputDeviceState = new WindowsInputDeviceStateAdaptor();
            _MediaPlayer = new SoundPlayer("letter.wav");
            _MediaPlayer.LoadAsync();
        }
示例#11
0
 /// <summary>
 /// A class that uses OpenCV and WindowsInput to automate Windows using computer vision
 /// </summary>
 /// <param name="matchingAccuracy">specifies the matching accuracy used on the result of OpenCV MatchTemplate (0-1). 0.75 seems adequate</param>
 public Automator(double matchingAccuracy)
 {
     screenMaxWidth        = Screen.PrimaryScreen.Bounds.Width;
     screenMaxHeight       = Screen.PrimaryScreen.Bounds.Height;
     inputSimulator        = new InputSimulator();
     mouse                 = inputSimulator.Mouse;
     keyboard              = inputSimulator.Keyboard;
     this.matchingAccuracy = matchingAccuracy;
     matchingType          = TemplateMatchingType.CcoeffNormed;
 }
示例#12
0
        public MainWindow()
        {
            InitializeComponent();

            controller     = new Controller(UserIndex.One);
            mouseSimulator = new InputSimulator().Mouse;
            timer          = new Timer(obj => Update());

            Start();
        }
示例#13
0
 public ProfileFactory(
     RootConfiguration rootConfiguration,
     IActionFactory actionFactory,
     IKeyboardSimulator keyboard,
     IMouseSimulator mouse,
     IMenuController menuController)
 {
     RootConfiguration = rootConfiguration;
     ActionFactory     = actionFactory;
     Keyboard          = keyboard;
     Mouse             = mouse;
     MenuController    = menuController;
 }
示例#14
0
        public static void MouseButtonClick(this IMouseSimulator mouse, MouseButton button)
        {
            switch (button)
            {
            case MouseButton.LeftButton:
                mouse.LeftButtonClick();
                break;

            case MouseButton.RightButton:
                mouse.RightButtonClick();
                break;

            default:
                break;
            }
        }
示例#15
0
        private static void OsuTap(ReplayFrame frame)
        {
            var timer         = Menu.ReadMemory(Menu.TimerAddress, 4);
            var trackPosition = BitConverter.ToInt32(timer, 0);
            var frameX        = GetScaledX(frame.X);
            var frameY        = GetScaledY(frame.Y);
            var frameTime     = frame.Time;

            var frameKey = frame.Keys;

            while (trackPosition < frameTime && Menu.IsRun)
            {
                Thread.Sleep(1);
                timer         = Menu.ReadMemory(Menu.TimerAddress, 4);
                trackPosition = BitConverter.ToInt32(timer, 0);
            }
            Input.Mouse.MoveMouseTo(frameX, frameY);

            if (GetAsyncKeyState(Keys.LControlKey) != 0)
            {
                if (UseMouse)
                {
                    Input.Mouse.LeftButtonUp();
                    Input.Mouse.RightButtonUp();
                }
                Input.Keyboard.KeyUp(OsuLeft);
                Input.Keyboard.KeyUp(OsuRight);
                _replayIndex++;
                return;
            }
            if (UseMouse)
            {
                _mouseSimulator = (frameKey.HasFlag(KeyData.M1) && !frame.Keys.HasFlag(KeyData.K1))
                                      ? Input.Mouse.LeftButtonDown()
                                      : Input.Mouse.LeftButtonUp();
                _mouseSimulator = (frameKey.HasFlag(KeyData.M2) && !frame.Keys.HasFlag(KeyData.K2))
                                      ? Input.Mouse.RightButtonDown()
                                      : Input.Mouse.RightButtonUp();
            }
            _keyboardSimulator = frameKey.HasFlag(KeyData.K1)
                                     ? Input.Keyboard.KeyDown(OsuLeft)
                                     : Input.Keyboard.KeyUp(OsuLeft);
            _keyboardSimulator = frameKey.HasFlag(KeyData.K2)
                                     ? Input.Keyboard.KeyDown(OsuRight)
                                     : Input.Keyboard.KeyUp(OsuRight);
            _replayIndex++;
        }
示例#16
0
        public CodedUiUiItemWrapper(
            AutomationElement automationElement,
            IMouseSimulator mouseSimulator,
            IKeyboardSimulator keyboardSimulator,
            ILogger logger,
            ISettings settings,
            IAwaitingService awaitingService)
        {
            this.automationElement = automationElement ?? throw new ArgumentNullException(nameof(automationElement));
            this.mouse             = mouseSimulator ?? throw new ArgumentNullException(nameof(mouseSimulator));
            this.keyboard          = keyboardSimulator ?? throw new ArgumentNullException(nameof(keyboardSimulator));
            this.logger            = logger ?? throw new ArgumentNullException(nameof(logger));
            this.settings          = settings ?? throw new ArgumentNullException(nameof(settings));
            this.awaitingService   = awaitingService ?? throw new ArgumentNullException(nameof(awaitingService));

            this.visualTreeNavigationRetryCount = this.settings.VisualTreeNavigationRetryCount;
        }
        public KeyPressActuator(IKeyboardSimulator keyboard, IMouseSimulator mouse, IEnumerable <VirtualKeyCode> keys, ModifierKeys modifiers)
        {
            Keyboard = keyboard;
            Mouse    = mouse;
            var list = new List <VirtualKeyCode>();

            foreach (var key in keys ?? Enumerable.Empty <VirtualKeyCode>())
            {
                switch (key)
                {
                case VirtualKeyCode.MENU:
                    modifiers |= ModifierKeys.Alt;
                    break;

                case VirtualKeyCode.CONTROL:
                    modifiers |= ModifierKeys.Control;
                    break;

                case VirtualKeyCode.SHIFT:
                    modifiers |= ModifierKeys.Shift;
                    break;

                case VirtualKeyCode.LWIN:
                    modifiers |= ModifierKeys.WinKey;
                    break;

                default:
                    list.Add(key);
                    break;
                }
            }

            Keys          = list;
            modifiersList = Utils.ModifiersToKeys(modifiers);
            Modifiers     = modifiers;
        }
示例#18
0
        public void FireMouseEvent(IMouseSimulator a_ims, mousePacket a_mhs)
        {
            switch ((MouseEventFlag)a_mhs.flags)
            {
            case MouseEventFlag.MOUSEEVENTF_MOVE:
                a_ims.MoveMouseTo(a_mhs.x, a_mhs.y);
                break;

            case MouseEventFlag.MOUSEEVENTF_LEFTDOWN:
                a_ims.LeftButtonDown();
                break;

            case MouseEventFlag.MOUSEEVENTF_LEFTUP:
                a_ims.LeftButtonUp();
                break;

            case MouseEventFlag.MOUSEEVENTF_RIGHTDOWN:
                a_ims.RightButtonDown();
                break;

            case MouseEventFlag.MOUSEEVENTF_RIGHTUP:
                a_ims.RightButtonUp();
                break;

            case MouseEventFlag.MOUSEEVENTF_WHEEL:
                if (a_mhs.y > 0)
                {
                    a_ims.VerticalScroll(3);
                }
                else
                {
                    a_ims.VerticalScroll(-3);
                }
                break;
            }
        }
示例#19
0
 private Win32EmulatedMouse(IMouseSimulator mouseSimulator)
 {
     _mouseSimulator = mouseSimulator;
 }
 public MouseScrollActuator(IMouseSimulator mouseSimulator)
 {
     MouseSimulator = mouseSimulator;
 }
示例#21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InputSimulator"/> class using the specified <see cref="IKeyboardSimulator"/>, <see cref="IMouseSimulator"/> and <see cref="IInputDeviceStateAdaptor"/> instances.
 /// </summary>
 /// <param name="keyboardSimulator">The <see cref="IKeyboardSimulator"/> instance to use for simulating keyboard input.</param>
 /// <param name="mouseSimulator">The <see cref="IMouseSimulator"/> instance to use for simulating mouse input.</param>
 /// <param name="inputDeviceStateAdaptor">The <see cref="IInputDeviceStateAdaptor"/> instance to use for interpreting the state of input devices.</param>
 public InputSimulator(IKeyboardSimulator keyboardSimulator, IMouseSimulator mouseSimulator, IInputDeviceStateAdaptor inputDeviceStateAdaptor) {
     Keyboard = keyboardSimulator;
     Mouse = mouseSimulator;
     InputDeviceState = inputDeviceStateAdaptor;
 }
示例#22
0
 public MouseMovementActuator(IMouseSimulator mouseSimulator)
 {
     MouseSimulator = mouseSimulator;
 }
 public KeyPressActuator(IKeyboardSimulator keyboard, IMouseSimulator mouse, VirtualKeyCode key, ModifierKeys modifiers)
     : this(keyboard, mouse, new[] { key }, modifiers)
 {
 }
示例#24
0
        private static void OsuTap(ReplayFrame frame)
        {
            var timer = Menu.ReadMemory(Menu.TimerAddress, 4);
            var trackPosition = BitConverter.ToInt32(timer, 0);
            var frameX = GetScaledX(frame.X);
            var frameY = GetScaledY(frame.Y);
            var frameTime = frame.Time;

            var frameKey = frame.Keys;
            while (trackPosition < frameTime && Menu.IsRun)
            {
                Thread.Sleep(1);
                timer = Menu.ReadMemory(Menu.TimerAddress, 4);
                trackPosition = BitConverter.ToInt32(timer, 0);
            }
            Input.Mouse.MoveMouseTo(frameX, frameY);

            if (GetAsyncKeyState(Keys.LControlKey) != 0)
            {
                if (UseMouse)
                {
                    Input.Mouse.LeftButtonUp();
                    Input.Mouse.RightButtonUp();
                }
                Input.Keyboard.KeyUp(OsuLeft);
                Input.Keyboard.KeyUp(OsuRight);
                _replayIndex++;
                return;
            }
            if (UseMouse)
            {
                _mouseSimulator = (frameKey.HasFlag(KeyData.M1) && !frame.Keys.HasFlag(KeyData.K1))
                                      ? Input.Mouse.LeftButtonDown()
                                      : Input.Mouse.LeftButtonUp();
                _mouseSimulator = (frameKey.HasFlag(KeyData.M2) && !frame.Keys.HasFlag(KeyData.K2))
                                      ? Input.Mouse.RightButtonDown()
                                      : Input.Mouse.RightButtonUp();
            }
            _keyboardSimulator = frameKey.HasFlag(KeyData.K1)
                                     ? Input.Keyboard.KeyDown(OsuLeft)
                                     : Input.Keyboard.KeyUp(OsuLeft);
            _keyboardSimulator = frameKey.HasFlag(KeyData.K2)
                                     ? Input.Keyboard.KeyDown(OsuRight)
                                     : Input.Keyboard.KeyUp(OsuRight);
            _replayIndex++;
        }
示例#25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InputSimulator"/> class using the default <see cref="KeyboardSimulator"/>, <see cref="MouseSimulator"/> and <see cref="WindowsInputDeviceStateAdaptor"/> instances.
 /// </summary>
 public InputSimulator()
 {
     _keyboardSimulator = new KeyboardSimulator();
     _mouseSimulator = new MouseSimulator();
     _inputDeviceState = new WindowsInputDeviceStateAdaptor();
 }
 internal MouseSimulatorExt(IMouseSimulator mouseSimulator)
 {
     this.mouseSimulator = mouseSimulator;
 }
示例#27
0
 public MouseSimulatorTests()
 {
     this.mouseSimulator = new MouseSimulator(Mock.Of <IInputMessageDispatcher>());
 }
示例#28
0
 public KeyMapActuator(IKeyboardSimulator keyboard, IMouseSimulator mouse, IEnumerable <VirtualKeyCode> virtualKeys)
 {
     Keyboard    = keyboard;
     Mouse       = mouse;
     VirtualKeys = virtualKeys?.ToList() ?? new List <VirtualKeyCode>(0);
 }
示例#29
0
 public MouseServices(IMouseSimulator mouseSimulator, WowWindow _wowWindow)
 {
     this._wowWindow = _wowWindow;
     _mouseSimulator = mouseSimulator;
 }
 public KeyPressActuator(IKeyboardSimulator keyboard, IMouseSimulator mouse, VirtualKeyCode key)
     : this(keyboard, mouse, new[] { key }, 0)
 {
 }
示例#31
0
 public static Win32EmulatedMouse FromMouseSimulator(IMouseSimulator simulator)
 {
     return(new Win32EmulatedMouse(simulator));
 }
示例#32
0
 internal MouseSimulatorExt(IMouseSimulator mouseSimulator)
 {
     this.mouseSimulator = mouseSimulator;
 }
示例#33
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InputSimulator"/> class using the specified <see cref="IKeyboardSimulator"/>, <see cref="IMouseSimulator"/> and <see cref="IInputDeviceStateAdaptor"/> instances.
 /// </summary>
 /// <param name="keyboardSimulator">The <see cref="IKeyboardSimulator"/> instance to use for simulating keyboard input.</param>
 /// <param name="mouseSimulator">The <see cref="IMouseSimulator"/> instance to use for simulating mouse input.</param>
 /// <param name="inputDeviceStateAdaptor">The <see cref="IInputDeviceStateAdaptor"/> instance to use for interpreting the state of input devices.</param>
 public InputSimulator(IKeyboardSimulator keyboardSimulator, IMouseSimulator mouseSimulator, IInputDeviceStateAdaptor inputDeviceStateAdaptor)
 {
     _keyboardSimulator = keyboardSimulator;
     _mouseSimulator = mouseSimulator;
     _inputDeviceState = inputDeviceStateAdaptor;
 }
示例#34
0
 private VirtualMouse()
 {
     _mouseSimulator = _inputSimulator.Mouse;
 }
示例#35
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InputSimulator"/> class using the default <see cref="KeyboardSimulator"/>, <see cref="MouseSimulator"/> and <see cref="WindowsInputDeviceStateAdaptor"/> instances.
 /// </summary>
 public InputSimulator()
 {
     _keyboardSimulator = new KeyboardSimulator(this);
     _mouseSimulator    = new MouseSimulator(this);
     _inputDeviceState  = new WindowsInputDeviceStateAdaptor();
 }
 public KeyPressActuator(IKeyboardSimulator keyboard, IMouseSimulator mouse, IEnumerable <VirtualKeyCode> keys)
     : this(keyboard, mouse, keys, 0)
 {
 }