Exemplo n.º 1
0
        private void TouchedDown(object sender, PointerEventArgs e)
        {
            var x = Convert.ToUInt16(e.Position.X.Inbetween(0, 800) / 800.0 * ushort.MaxValue);
            var y = Convert.ToUInt16(e.Position.Y.Inbetween(0, 480) / 480.0 * ushort.MaxValue);

            var data = (uint)(x << 16) | (uint)(y << 0);

            var moveInfo = new InjectedInputMouseInfo
            {
                DeltaX       = x,
                DeltaY       = y,
                MouseData    = data,
                MouseOptions = InjectedInputMouseOptions.Move | InjectedInputMouseOptions.Absolute
            };

            var downInfo = new InjectedInputMouseInfo
            {
                DeltaX       = 0,
                DeltaY       = 0,
                MouseData    = data,
                MouseOptions = InjectedInputMouseOptions.LeftDown
            };

            _inputInjector.InjectMouseInput(new[] { moveInfo, downInfo });
        }
 private void RightClick()
 {
     var inputInject = InputInjector.TryCreate();
     var mouseInfo = new InjectedInputMouseInfo();
     mouseInfo.MouseOptions = InjectedInputMouseOptions.RightDown;
     inputInject.InjectMouseInput(new[] { mouseInfo });
 }
        public RelayCommand GetStartCommand()
        {
            return(startCommand ??
                   (startCommand = new RelayCommand(obj =>
            {
                InjectedInputPoint injectedInputPoint = new InjectedInputPoint();
                injectedInputPoint.PositionX = 1817;
                injectedInputPoint.PositionY = 0;
                //injectedInputPoint.PointerOptions.

                CoreWindow.GetForCurrentThread().PointerPosition = new Point(injectedInputPoint.PositionX, injectedInputPoint.PositionY);
                //InjectedInputMouseOptions.Absolute(); Cursor.Position = new Point(400, 700);
                InputInjector inputInjector = InputInjector.TryCreate();
                var down = new InjectedInputMouseInfo();
                down.MouseOptions = InjectedInputMouseOptions.LeftDown;
                var up = new InjectedInputMouseInfo();
                up.MouseOptions = InjectedInputMouseOptions.LeftUp;
                Task.Delay(1500);
                inputInjector.InjectMouseInput(new[] { down, up });
                injectedInputPoint.PositionX = 0;
                injectedInputPoint.PositionY = 0;
                CoreWindow.GetForCurrentThread().PointerPosition = new Point(injectedInputPoint.PositionX, injectedInputPoint.PositionY);
                Task.Delay(15000);
                inputInjector.InjectMouseInput(new[] { down });
                injectedInputPoint.PositionX = 879;
                injectedInputPoint.PositionY = 115;
                CoreWindow.GetForCurrentThread().PointerPosition = new Point(injectedInputPoint.PositionX, injectedInputPoint.PositionY);
                inputInjector.InjectMouseInput(new[] { down, up });
                inputInjector.InjectMouseInput(new[] { down, up });
            })));
        }
Exemplo n.º 4
0
        private async void mainpage_KeyUp(CoreWindow sender, KeyEventArgs args)
        {
            if (reading.Buttons.HasFlag(GamepadButtons.RightShoulder) == true)
            {
                var info = new InjectedInputMouseInfo();
                info.MouseOptions = InjectedInputMouseOptions.Wheel;
                unchecked
                {
                    info.MouseData = (uint)+50; //scroll up
                }
                InputInjector inputInjector = InputInjector.TryCreate();
                inputInjector.InjectMouseInput(new[] { info });
                Debug.WriteLine("wheel up");
            }
            else if (reading.Buttons.HasFlag(GamepadButtons.LeftShoulder) == true)
            {
                var info = new InjectedInputMouseInfo();
                info.MouseOptions = InjectedInputMouseOptions.Wheel;
                unchecked
                {
                    info.MouseData = (uint)-50; //scroll down
                }
                InputInjector inputInjector = InputInjector.TryCreate();
                inputInjector.InjectMouseInput(new[] { info });
                Debug.WriteLine("wheel down");
            }
            //else if (reading.Buttons.HasFlag(GamepadButtons.A) == true)
            //{
            //    var down = new InjectedInputMouseInfo();
            //    down.MouseOptions = InjectedInputMouseOptions.LeftDown;
            //    var up = new InjectedInputMouseInfo();
            //    up.MouseOptions = InjectedInputMouseOptions.LeftUp;
            //    InputInjector inputInjector = InputInjector.TryCreate();
            //    inputInjector.InjectMouseInput(new[] { down, up });
            //    Debug.WriteLine("A pressed");
            //}
            if (GamepadButtons.A == (reading.Buttons & GamepadButtons.A))
            {
                down = new InjectedInputMouseInfo();
                down.MouseOptions = InjectedInputMouseOptions.LeftDown;
                Debug.WriteLine("A pressed");
            }
            else if (GamepadButtons.None == (reading.Buttons & GamepadButtons.A) && down != null)
            {
                var up = new InjectedInputMouseInfo();
                up.MouseOptions = InjectedInputMouseOptions.LeftUp;
                InputInjector inputInjector = InputInjector.TryCreate();
                inputInjector.InjectMouseInput(new[] { down, up });
                Debug.WriteLine("A released");
                down = null;
            }
            await Task.Delay(0);

            ////if (args.VirtualKey == VirtualKey.GamepadB)
            ////{
            ////    args.Handled = false;
            ////}
        }
Exemplo n.º 5
0
        private void MoveMouse()
        {
            var info = new InjectedInputMouseInfo();

            info.MouseOptions = InjectedInputMouseOptions.Move;
            info.DeltaY       = 100;

            InputInjector inputInjector = InputInjector.TryCreate();

            inputInjector.InjectMouseInput(new[] { info });
        }
Exemplo n.º 6
0
        public override void InjectMouseInput(RIMNativeMethods.MouseInput mouseInput)
        {
            var injectedInputMouseInfo = new InjectedInputMouseInfo();

            injectedInputMouseInfo.DeltaX                   = mouseInput.dx;
            injectedInputMouseInfo.DeltaY                   = mouseInput.dy;
            injectedInputMouseInfo.MouseData                = mouseInput.mouseData;
            injectedInputMouseInfo.MouseOptions             = (InjectedInputMouseOptions)(int)mouseInput.flags;
            injectedInputMouseInfo.TimeOffsetInMilliseconds = mouseInput.time;
            var injectedInputMouseInfoList = new List <InjectedInputMouseInfo>();

            injectedInputMouseInfoList.Add(item: injectedInputMouseInfo);
            this.injector.InjectMouseInput(input: injectedInputMouseInfoList);
        }
Exemplo n.º 7
0
        private void StackPanel_PreviewKeyUp(object sender, KeyRoutedEventArgs e)
        {
            if (e.Key == VirtualKey.C)
            {
                var down = new InjectedInputMouseInfo();
                down.MouseOptions = InjectedInputMouseOptions.LeftDown;

                var up = new InjectedInputMouseInfo();
                up.MouseOptions = InjectedInputMouseOptions.LeftUp;

                InputInjector inputInjector = InputInjector.TryCreate();
                inputInjector.InjectMouseInput(new[] { down, up });
            }
        }
Exemplo n.º 8
0
        private void ScrollMouse()
        {
            MoveMouse(); //first move mouse above the listview
            var info = new InjectedInputMouseInfo();

            info.MouseOptions = InjectedInputMouseOptions.Wheel;
            unchecked
            {
                info.MouseData = (uint)-500; //scroll down
            }

            InputInjector inputInjector = InputInjector.TryCreate();

            inputInjector.InjectMouseInput(new[] { info });
        }
Exemplo n.º 9
0
        private void TouchedUp(object sender, PointerEventArgs e)
        {
            var x = Convert.ToUInt16(e.Position.X.Inbetween(0, 800) / 800.0 * ushort.MaxValue);
            var y = Convert.ToUInt16(e.Position.Y.Inbetween(0, 480) / 480.0 * ushort.MaxValue);

            var data = (uint)(x << 16) | (uint)(y << 0);

            var upInfo = new InjectedInputMouseInfo
            {
                DeltaX       = 0,
                DeltaY       = 0,
                MouseData    = data,
                MouseOptions = InjectedInputMouseOptions.LeftUp | InjectedInputMouseOptions.Absolute
            };

            _inputInjector.InjectMouseInput(upInfo.ToEnumerable());
        }
        private async void Tabs_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var pointerPosition = Windows.UI.Core.CoreWindow.GetForCurrentThread().PointerPosition;
            var x = pointerPosition.X;
            var y = pointerPosition.Y;

            if (UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Touch)
            {
                var X = Window.Current.Bounds.Width - 50;
                var Y = Window.Current.Bounds.Height - 800;
                Window.Current.CoreWindow.PointerPosition = new Point(X, Y);
                var down = new InjectedInputMouseInfo();
                down.MouseOptions = InjectedInputMouseOptions.LeftDown;
                var up = new InjectedInputMouseInfo();
                up.MouseOptions = InjectedInputMouseOptions.LeftUp;
                InputInjector IIInputInjector = InputInjector.TryCreate();
                IIInputInjector.InjectMouseInput(new[] { down, up });
                await Task.Delay(100);

                IIInputInjector.InjectMouseInput(new[] { down, up });
                Window.Current.CoreWindow.PointerPosition = new Point(x, y);
            }
            else
            {
                await Task.Delay(150);

                Window.Current.CoreWindow.PointerPosition = new Point(500, 500);
                var down = new InjectedInputMouseInfo();
                down.MouseOptions = InjectedInputMouseOptions.LeftDown;
                var up = new InjectedInputMouseInfo();
                up.MouseOptions = InjectedInputMouseOptions.LeftUp;
                InputInjector IIInputInjector = InputInjector.TryCreate();
                IIInputInjector.InjectMouseInput(new[] { down, up });
                await Task.Delay(100);

                IIInputInjector.InjectMouseInput(new[] { down, up });
                Window.Current.CoreWindow.PointerPosition = new Point(x, y);
            }
        }
Exemplo n.º 11
0
        //private void dispatcherTimer_Tick(object sender, object e)
        private async void ReadingGamepad()
        {
            //if (Gamepad.Gamepads.Count > 0)
            while (true)
            {
                if (controller == null || Gamepad.Gamepads.Count <= 0)
                {
                    break;
                }
                controller = Gamepad.Gamepads.First();

                reading = this.controller.GetCurrentReading();

                // UI and the task run at different levels.
                // Therefore, the dispatcher must input data
                // and the data from the ViewModel binding Async be treated.
                await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
                {
                    pbLeftThumbstickX.Value = reading.LeftThumbstickX;
                    pbLeftThumbstickY.Value = reading.LeftThumbstickY;
                    if (reading.LeftThumbstickX > 0.5)
                    {
                        ChangeVisibility(true, lbl8bitdoDPadRight);
                    }
                    else
                    {
                        ChangeVisibility(false, lbl8bitdoDPadRight);
                    }
                    if (reading.LeftThumbstickX < -0.5)
                    {
                        ChangeVisibility(true, lbl8bitdoDPadLeft);
                    }
                    else
                    {
                        ChangeVisibility(false, lbl8bitdoDPadLeft);
                    }
                    if (reading.LeftThumbstickY > 0.5)
                    {
                        ChangeVisibility(true, lbl8bitdoDPadUp);
                    }
                    else
                    {
                        ChangeVisibility(false, lbl8bitdoDPadUp);
                    }
                    if (reading.LeftThumbstickY < -0.5)
                    {
                        ChangeVisibility(true, lbl8bitdoDPadDown);
                    }
                    else
                    {
                        ChangeVisibility(false, lbl8bitdoDPadDown);
                    }


                    pbRightThumbstickX.Value = reading.RightThumbstickX;
                    pbRightThumbstickY.Value = reading.RightThumbstickY;

                    pbLeftTrigger.Value  = reading.LeftTrigger;
                    pbRightTrigger.Value = reading.RightTrigger;

                    //https://msdn.microsoft.com/en-us/library/windows/apps/windows.gaming.input.gamepadbuttons.aspx
                    ChangeVisibility(reading.Buttons.HasFlag(GamepadButtons.A), lblA);
                    ChangeVisibility(reading.Buttons.HasFlag(GamepadButtons.A), ell8bitdoB);
                    ChangeVisibility(reading.Buttons.HasFlag(GamepadButtons.B), lblB);
                    ChangeVisibility(reading.Buttons.HasFlag(GamepadButtons.B), ell8bitdoA);
                    ChangeVisibility(reading.Buttons.HasFlag(GamepadButtons.X), lblX);
                    ChangeVisibility(reading.Buttons.HasFlag(GamepadButtons.X), ell8bitdoY);
                    ChangeVisibility(reading.Buttons.HasFlag(GamepadButtons.Y), lblY);
                    ChangeVisibility(reading.Buttons.HasFlag(GamepadButtons.Y), ell8bitdoX);
                    ChangeVisibility(reading.Buttons.HasFlag(GamepadButtons.Menu), lblMenu);
                    ChangeVisibility(reading.Buttons.HasFlag(GamepadButtons.Menu), lbl8bitdoStart);
                    ChangeVisibility(reading.Buttons.HasFlag(GamepadButtons.DPadLeft), lblDPadLeft);
                    ChangeVisibility(reading.Buttons.HasFlag(GamepadButtons.DPadRight), lblDPadRight);
                    ChangeVisibility(reading.Buttons.HasFlag(GamepadButtons.DPadUp), lblDPadUp);
                    ChangeVisibility(reading.Buttons.HasFlag(GamepadButtons.DPadDown), lblDPadDown);
                    ChangeVisibility(reading.Buttons.HasFlag(GamepadButtons.View), lblView);
                    ChangeVisibility(reading.Buttons.HasFlag(GamepadButtons.View), lbl8bitdoSelect);
                    ChangeVisibility(reading.Buttons.HasFlag(GamepadButtons.RightThumbstick), ellRightThumbstick);
                    ChangeVisibility(reading.Buttons.HasFlag(GamepadButtons.LeftThumbstick), ellLeftThumbstick);
                    ChangeVisibility(reading.Buttons.HasFlag(GamepadButtons.LeftShoulder), rectLeftShoulder);
                    ChangeVisibility(reading.Buttons.HasFlag(GamepadButtons.LeftShoulder), rect8bitdoLS);
                    ChangeVisibility(reading.Buttons.HasFlag(GamepadButtons.RightShoulder), rectRightShoulder);
                    ChangeVisibility(reading.Buttons.HasFlag(GamepadButtons.RightShoulder), rect8bitdoRS);

                    //// prevent the cursor from going outside the window of the app
                    //if (x < 0) { x = 0; }
                    //if (x > ScreenWidth) { x = ScreenWidth; }
                    //if (y < 0) { y = 0; }
                    //if (y > ScreenHeight) { y = ScreenHeight; }

                    if (reading.LeftThumbstickY > Deadzone || reading.LeftThumbstickY < -Deadzone || reading.LeftThumbstickX > Deadzone || reading.LeftThumbstickX < -Deadzone)
                    {
                        //Debug.WriteLine("x= " + (int)x + " y= " + (int)y);
                        info1 = new InjectedInputMouseInfo();
                        info1.MouseOptions = InjectedInputMouseOptions.Move;
                        if ((reading.LeftThumbstickX > Deadzone || reading.LeftThumbstickX < -Deadzone) && x >= 0 && x <= ScreenWidth)
                        {
                            info1.DeltaX = (int)(reading.LeftThumbstickX * 10);
                            //Debug.WriteLine("info.DeltaX  = " + info1.DeltaX);
                        }
                        if ((reading.LeftThumbstickY > Deadzone || reading.LeftThumbstickY < -Deadzone) && y >= 0 && y <= ScreenHeight)
                        {
                            info1.DeltaY = (int)(-reading.LeftThumbstickY * 10);
                            //Debug.WriteLine("info.DeltaY = " + info1.DeltaY);
                        }
                        InputInjector inputInjector = InputInjector.TryCreate();
                        inputInjector.InjectMouseInput(new[] { info1 });
                    }
                });

                // delay while loop interval
                await Task.Delay(DelayReadingGamepad);
            }
        }