Beispiel #1
0
        private static void getPixelsetPixel()
        {
            Image  jpg  = Image.FromFile("C:/Users/danila/skkribl/testScreenShot/image.jpg");
            Bitmap img  = new Bitmap(jpg);
            Bitmap nbmp = ResizeBitmap(img, 100, 100);

            int[] pxlColors = new int[100];

            for (int i = 0; i < nbmp.Width; i++)
            {
                for (int j = 0; j < nbmp.Height; j++)
                {
                    Color pixel = nbmp.GetPixel(i, j);
                    pxlColors[j] = pixel.ToArgb();
                }
            }
            for (int v = 0; v < 100; v++)
            {
                if (pxlColors[v] / 2 != 0)
                {
                    int x = 10000 + v;
                    int y = 10000 + v;
                    VirtualMouse.MoveTo(x, y);
                    VirtualMouse.LeftClick();
                }
                else
                {
                }
            }
        }
Beispiel #2
0
        public WebSocketHandle(WebSocket webSocket)
        {
            // 4kb buffer
            buffer         = new byte[1024 * 4];
            this.webSocket = webSocket;

            mouse = new VirtualMouse();
            audio = new AudioManipulator();
        }
Beispiel #3
0
        public Task ParseMessageReceived(WebSocketReceiveResult result)
        {
            string messageReceived = Encoding.Default.GetString(new ArraySegment <byte>(buffer, 0, result.Count));

            VirtualMouse.MouseCommand mc = VirtualMouse.JsonToMouseCommand(messageReceived);

            //Console.WriteLine("Parsing Command: " + mc);

            if (mc.command == "move")
            {
                mouse.Move(mc.x, mc.y);
            }

            else if (mc.command == "right_click")
            {
                mouse.RightClick();
            }
            else if (mc.command == "left_click")
            {
                mouse.LeftClick();
            }
            else if (mc.command == "left_down")
            {
                mouse.LeftDown();
            }
            else if (mc.command == "left_up")
            {
                mouse.LeftUp();
            }
            else if (mc.command == "right_down")
            {
                mouse.RightDown();
            }
            else if (mc.command == "right_up")
            {
                mouse.RightUp();
            }
            else if (mc.command == "touchpad_start")
            {
                mouse.TouchpadStart(mc.x, mc.y);
            }
            else if (mc.command == "touchpad_move")
            {
                mouse.TouchpadMove(mc.x, mc.y, (int)mc.extra);
            }
            else if (mc.command == "set_volume")
            {
                audio.SetVolume(mc.x);
            }
            else
            {
                return(Error());
            }

            return(Success());
        }
Beispiel #4
0
        /// <summary>
        /// Makes a new instance of <see cref="InputEngine"/> class.
        /// </summary>
        /// <param name="host">Game host owner.</param>
        /// <param name="moduleLoop">Running loop.</param>
        public InputEngine(GameHost host, GameLoop moduleLoop)
            : base(host, moduleLoop)
        {
            InputStates = new DeviceStates();
            bindings    = new List <Binding>();

            Keyboard = new VirtualKeyboard(null);
            Mouse    = new VirtualMouse(null);
            Joypads  = new List <VirtualJoypad>();
        }
Beispiel #5
0
        public static void MoveTo(Vector3 position,
                                  float holdAreaRadius      = 0,
                                  bool overrideTimer        = false,
                                  bool useFixedDistance     = true,
                                  bool randomizeMinDistance = true)
        {
            if (LeagueSharp.Common.Utils.GameTimeTickCount - LastMoveCommandT < _delay && !overrideTimer)
            {
                return;
            }

            LastMoveCommandT = LeagueSharp.Common.Utils.GameTimeTickCount;

            if (Player.ServerPosition.Distance(position, true) < holdAreaRadius * holdAreaRadius)
            {
                if (Player.Path.Count() > 1)
                {
                    Player.IssueOrder((GameObjectOrder)10, Player.ServerPosition);
                    Player.IssueOrder(GameObjectOrder.HoldPosition, Player.ServerPosition);
                    LastMoveCommandPosition = Player.ServerPosition;
                }
                return;
            }

            var point = position;

            if (useFixedDistance)
            {
                point = Player.ServerPosition +
                        (randomizeMinDistance ? (_random.NextFloat(0.6f, 1) + 0.2f) * _minDistance : _minDistance) *
                        (position.To2D() - Player.ServerPosition.To2D()).Normalized().To3D();
            }
            else
            {
                if (randomizeMinDistance)
                {
                    point = Player.ServerPosition +
                            (_random.NextFloat(0.6f, 1) + 0.2f) * _minDistance *
                            (position.To2D() - Player.ServerPosition.To2D()).Normalized().To3D();
                }
                else if (Player.ServerPosition.Distance(position) > _minDistance)
                {
                    point = Player.ServerPosition +
                            _minDistance * (position.To2D() - Player.ServerPosition.To2D()).Normalized().To3D();
                }
            }

            Player.IssueOrder(GameObjectOrder.MoveTo, point);
            LastMoveCommandPosition = point;

            if (ChallengerPlugin.DrawingsMenu.Item("streamingmode").GetValue <bool>())
            {
                VirtualMouse.RightClick(point);
            }
        }
Beispiel #6
0
        /// <summary>
        /// Makes a new instance of <see cref="InputService"/> class.
        /// </summary>
        /// <param name="module">Owner module.</param>
        /// <param name="mainScheduler">Scheduler for this service.</param>
        public InputService(Module module, GameLoop mainLoop)
            : base(module, mainLoop)
        {
            inputHistory        = new ConcurrentQueue <DeviceStates>();
            currentInputHistory = new List <DeviceStates>();

            Keyboard = new VirtualKeyboard(currentInputState?[Module.HardwareKeyboard]);
            Mouse    = new VirtualMouse(currentInputState?[Module.HardwareMouse]);
            Joypads  = new List <VirtualJoypad>();

            foreach (var j in Module.HardwareJoypads)
            {
                Joypads.Add(new VirtualJoypad(currentInputState?[j], j.Index, j.Name));
            }
        }
Beispiel #7
0
        private void ClickManagerWindow_OnLoaded(object sender,
                                                 RoutedEventArgs e)
        {
            var timer = new System.Windows.Threading.DispatcherTimer
            {
                Interval  = new TimeSpan(0, 0, 0, 0, 100),
                IsEnabled = true
            };

            timer.Tick += (o, t) =>
            {
                if (_targetWindow != IntPtr.Zero)
                {
                    WindowService.GetWindowRect(_targetWindow,
                                                out Rectangle rect);

                    Point cursorPoint = new Point();
                    VirtualMouse.GetCursorPos(ref cursorPoint);

                    _leftTop = new Point(rect.X, rect.Y);

                    ActiveWindowInfo.Text =
                        $"{_windowHeader}: " +
                        $"{_leftTop}, {_width} x {_height}";

                    XTextBlock.Text = (cursorPoint.X - _leftTop.X).ToString();
                    YTextBlock.Text = (cursorPoint.Y - _leftTop.Y).ToString();

                    if (_width != rect.Width - rect.X || _height !=
                        rect.Height - rect.Y)
                    {
                        _width  = rect.Width - rect.X;
                        _height = rect.Height - rect.Y;
                        UpdateActions();
                        ActionsGrid.ItemsSource = Actions;

                        SetBoltIconCoords();
                        SetSettingsIconCoords();
                    }
                }
                else
                {
                    SetElementsState(false);
                }
            };
            timer.Start();
        }
Beispiel #8
0
        /// <summary>
        ///     Orbwalk a target while moving to Position.
        /// </summary>
        public static void Orbwalk(AttackableUnit target,
                                   Vector3 position,
                                   float extraWindup         = 90,
                                   float holdAreaRadius      = 0,
                                   bool useFixedDistance     = true,
                                   bool randomizeMinDistance = true)
        {
            try
            {
                if (target.IsValidTarget() && CanAttack())
                {
                    DisableNextAttack = false;
                    FireBeforeAttack(target);

                    if (!DisableNextAttack)
                    {
                        if (!NoCancelChamps.Contains(Player.ChampionName))
                        {
                            LastAATick       = LeagueSharp.Common.Utils.GameTimeTickCount + Game.Ping + 100 - (int)(ObjectManager.Player.AttackCastDelay * 1000f);
                            _missileLaunched = false;
                        }
                        Player.IssueOrder(GameObjectOrder.AttackUnit, target);
                        _lastTarget = target;
                        if (ChallengerPlugin.DrawingsMenu.Item("streamingmode").GetValue <bool>())
                        {
                            VirtualMouse.ShiftClick(target.Position);
                        }
                        return;
                    }
                }

                if (CanMove(extraWindup))
                {
                    MoveTo(position, holdAreaRadius, false, useFixedDistance, randomizeMinDistance);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
Beispiel #9
0
        internal static void OnUpdate(EventArgs args)
        {
            var hero  = ObjectManager.Player;
            var shops = ObjectManager.Get <Obj_Shop>();

            if (IsHeroNearShop())
            {
                if (hero.InShop())
                {
                    // get req. items from website --> buy them step by step
                }
                else
                {
                    VirtualMouse.RightClick(shop.Position);
                }
            }
            else
            {
                // close shop
            }
        }
Beispiel #10
0
        private void Operation()
        {
            ScreenCapture sc = new ScreenCapture();

            sc.CaptureScreenToFile(Parameter._screenshotImagePath, ImageFormat.Png);

            Search4Pattern();

            if (pattern_location.Width != 0)
            {
                Cursor.Position = new Point(Parameter._location_Click1_X + pattern_location.X,
                                            Parameter._location_Click1_Y + +pattern_location.Y);
                VirtualMouse.LeftClick();

                System.Threading.Thread.Sleep(2000);

                Cursor.Position = new Point(Parameter._location_Click2_X + pattern_location.X,
                                            Parameter._location_Click2_Y + +pattern_location.Y);
                VirtualMouse.LeftClick();
            }

            try
            {
                File.Delete(Parameter._screenshotImagePath);
            }
            catch (IOException ex)
            {
                Debug.WriteLine(ex.Message);
            }

            //if (CaptureScreen.CaptureFullScreen())
            //{

            //}
            //else
            //{
            //    MessageBox.Show("Capture screen failed.");
            //}
        }
Beispiel #11
0
        private void fish()
        {
            int tracker = GetControlPropertyThreadSafe(trackBar1, t => t.Value);

            VirtualMouse.RightClick();


            System.Threading.Thread.Sleep(1700);
            while (active)
            {
                var device = (MMDevice)GetControlPropertyThreadSafe(processList, t => t.SelectedItem);
                var curVol = (int)Math.Round(device.AudioMeterInformation.MasterPeakValue * 1000);
                if (curVol >= tracker)
                {
                    VirtualMouse.RightClick();
                    break;
                }
            }

            fished = fished + 1;
            System.Threading.Thread.Sleep(400);
        }
Beispiel #12
0
        private void button3_Click(object sender, EventArgs e)
        {
            label2.Text = "...";

            Task.Delay(0).ContinueWith((t) =>
            {
                VirtualMouse vm = new VirtualMouse();
                int kk          = 0;
                Int32.TryParse(textBox2.Text, out kk);
                for (int i = 0; i < 5; i++)
                {
                    label2.Text = i.ToString();

                    int y = 0, w = 500, h = 400;
                    Int32.TryParse(textBox1.Text, out y);
                    ScreenProcessor sp = new ScreenProcessor(0, y, w, 400);

                    Bitmap b = sp.Get();
                    for (int yy = 100; yy < 102; yy++)
                    {
                        for (int x = 0; x < w; x++)
                        {
                            label2.Text = i.ToString() + ">>" + x.ToString();
                            if (b.GetPixel(x, yy).R < kk)
                            {
                                b.SetPixel(x, yy, Color.Red);
                            }
                        }
                    }
                    pictureBox1.Image = b;

                    vm.LClick(ml.X, ml.Y);
                    vm.LClick(ml.X, ml.Y);
                    Thread.Sleep(250);
                }

                label2.Text = "cool beans";
            });
        }
        private void PerformClick(WindowRectangle window, Click click,
                                  bool needDelay = true)
        {
            if (window == null)
            {
                throw new ArgumentNullException(nameof(window));
            }

            if (click == null)
            {
                throw new ArgumentNullException(nameof(click));
            }

            Point point = window.GetScreenPoint(click.Position);

            VirtualMouse.SendLeftClick(point);

            if (needDelay)
            {
                Thread.Sleep(click.Delay);
            }
        }
        public void keyCmdM()
        {
            bool ctrl = false, m = false;

            Hook.I().AddKeyHook((Key k) =>
            {
                if (k == Key.M)
                {
                    m = true;
                }

                if (k.ToString().Contains("Control"))
                {
                    ctrl = true;
                }
            }, (Key k) => { });

            Thread.Sleep(w);
            ks.KeyDown(VirtualKeyCode.CONTROL);
            ks.KeyPress(VirtualKeyCode.VK_M);
            ks.KeyUp(VirtualKeyCode.CONTROL);
            Assert.IsTrue(ctrl && m);
        }
Beispiel #15
0
        public override bool Execute(ref ControllerState state)
        {
            if (base.Execute(ref state))
            {
                #region Mouse Buttons
                if (commandState == ButtonState.Down)
                {
                    if (mouseButton == MouseButtons.Left)
                    {
                        VirtualMouse.LeftDown();
                    }
                    else if (mouseButton == MouseButtons.Right)
                    {
                        VirtualMouse.RightDown();
                    }
                }
                else
                {
                    if (mouseButton == MouseButtons.Left)
                    {
                        VirtualMouse.LeftUp();
                    }
                    else if (mouseButton == MouseButtons.Right)
                    {
                        VirtualMouse.RightUp();
                    }
                }
                #endregion
                return(true);
            }

            else
            {
                return(false);
            }
        }
Beispiel #16
0
        private void button1_Click(object sender, EventArgs e)
        {
            System.Threading.Thread.Sleep(2999);

            int count = File.ReadAllLines("proxy.txt").Length; // number of line in file

            //System.Diagnostics.Process.Start("www.instagram.com");

            for (int i = 0; i < 2; i++)
            {
                ParsingProxy();
                //m.Close();
                /*OperationsWithFile.DeleteFirstLineFromFile("proxy.txt");*/ // delete first line from file



                System.Diagnostics.Process.Start("www.instagram.com");
                System.Threading.Thread.Sleep(5000);
                Cursor.Position = new Point(1325, 95); //"свойства:интернет"
                System.Threading.Thread.Sleep(2999);
                VirtualMouse.LeftClick();
                System.Threading.Thread.Sleep(2999);
                Cursor.Position = new Point(320, 510); //"настройка сети"
                System.Threading.Thread.Sleep(2999);
                VirtualMouse.LeftClick();
                Cursor.Position = new Point(150, 355); //input proxy
                System.Threading.Thread.Sleep(2999);
                VirtualMouse.LeftClick();
                System.Threading.Thread.Sleep(2999);
                SendKeys.Send("^{a}");
                //VirtualMouse.DoubleLeftClick();
                System.Threading.Thread.Sleep(2999);
                Clipboard.SetText(proxy);
                SendKeys.Send("^{v}");
                System.Threading.Thread.Sleep(2999); //input port
                Cursor.Position = new Point(240, 355);
                System.Threading.Thread.Sleep(2999);
                VirtualMouse.LeftClick();
                SendKeys.Send("^{a}");
                System.Threading.Thread.Sleep(2999);
                Clipboard.SetText(port);
                SendKeys.Send("^{v}");
                System.Threading.Thread.Sleep(2999);
                Cursor.Position = new Point(240, 427);
                System.Threading.Thread.Sleep(2999);
                VirtualMouse.LeftClick();
                System.Threading.Thread.Sleep(2999);
                Cursor.Position = new Point(75, 45); //refersh
                System.Threading.Thread.Sleep(2999);
                VirtualMouse.LeftClick();
                System.Threading.Thread.Sleep(2999);
                Clipboard.SetText(proxyLogin); //insert proxyName
                SendKeys.Send("^{v}");
                System.Threading.Thread.Sleep(2999);
                Cursor.Position = new Point(660, 245); //insert proxyPass
                System.Threading.Thread.Sleep(2999);
                VirtualMouse.LeftClick();
                System.Threading.Thread.Sleep(2999);
                Clipboard.SetText(proxyPass);
                SendKeys.Send("^{v}");
                System.Threading.Thread.Sleep(2999);
                Cursor.Position = new Point(680, 320);
                System.Threading.Thread.Sleep(2999);
                VirtualMouse.LeftClick(); //click


                Cursor.Position = new Point(1250, 45); //coockie
                System.Threading.Thread.Sleep(2999);
                VirtualMouse.LeftClick();
                System.Threading.Thread.Sleep(2999); //delete coockie
                Cursor.Position = new Point(750, 75);
                System.Threading.Thread.Sleep(4000);
                VirtualMouse.LeftClick();
                System.Threading.Thread.Sleep(2999);
                Cursor.Position = new Point(75, 45); //refersh
                System.Threading.Thread.Sleep(2999);
                VirtualMouse.LeftClick();
                System.Threading.Thread.Sleep(2999);
                Cursor.Position = new Point(1250, 45); //coockie
                System.Threading.Thread.Sleep(2999);
                VirtualMouse.LeftClick();
                Cursor.Position = new Point(850, 250);
                System.Threading.Thread.Sleep(2999);
                VirtualMouse.LeftClick(); //doubleclick in "Значение"
                SendKeys.Send("^{a}");
                System.Threading.Thread.Sleep(2999);
                Clipboard.SetText(midCoockie);         //insert into buffer midCoockie value
                SendKeys.Send("^{v}");                 //ctrl+v into "Значение" in plaggin
                Cursor.Position = new Point(980, 505); //save midCoockie
                System.Threading.Thread.Sleep(2999);
                VirtualMouse.LeftClick();
                System.Threading.Thread.Sleep(2999);
                Cursor.Position = new Point(75, 45); //refersh
                System.Threading.Thread.Sleep(2999);
                VirtualMouse.LeftClick();
                System.Threading.Thread.Sleep(2999);


                Cursor.Position = new Point(850, 435); //name field
                System.Threading.Thread.Sleep(2999);
                VirtualMouse.LeftClick();
                System.Threading.Thread.Sleep(2999);
                GetNameFromFile();
                Clipboard.SetText(name);
                SendKeys.Send("^{v}");

                System.Threading.Thread.Sleep(2999);
                Cursor.Position = new Point(850, 400); //email field
                VirtualMouse.LeftClick();
                System.Threading.Thread.Sleep(2999);
                GetEmailFromFile();
                Clipboard.SetText(email);
                SendKeys.Send("^{v}");

                System.Threading.Thread.Sleep(2999);
                Cursor.Position = new Point(850, 510);
                System.Threading.Thread.Sleep(2999); //pass field
                VirtualMouse.LeftClick();
                System.Threading.Thread.Sleep(2999);
                GetPassFromFile();
                Clipboard.SetText(pass);
                System.Threading.Thread.Sleep(2999);
                SendKeys.Send("^{v}");


                System.Threading.Thread.Sleep(2999);
                Cursor.Position = new Point(850, 470); //copy nickname in file
                VirtualMouse.LeftClick();
                SendKeys.Send("^{a}");
                System.Threading.Thread.Sleep(2999);
                SendKeys.Send("^{c}");
                nickname = Clipboard.GetText(TextDataFormat.Text);
                WriteFinalInfoInFile();



                System.Threading.Thread.Sleep(2999);
                Cursor.Position = new Point(850, 555); //registration click
                VirtualMouse.LeftClick();
                System.Threading.Thread.Sleep(3000);
                VirtualMouse.LeftClick();

                Cursor.Position = new Point(1250, 45); //coockie
                System.Threading.Thread.Sleep(2999);
                VirtualMouse.LeftClick();
                System.Threading.Thread.Sleep(2999); //delete coockie
                Cursor.Position = new Point(750, 75);
                System.Threading.Thread.Sleep(4000);
                VirtualMouse.LeftClick();
                System.Threading.Thread.Sleep(2999);
                Cursor.Position = new Point(200, 200);
                System.Threading.Thread.Sleep(2999);
                VirtualMouse.LeftClick();
                SendKeys.Send("^{w}");
            }
        }
Beispiel #17
0
        internal void Execute(ref ControllerState state)
        {
            #region State Changes
            if (stateChange != null)
            {
                if (stateChange.toggle)
                {
                    if (state.inputMode == InputMode.Move)
                    {
                        state.inputMode = InputMode.Pointer;
                    }
                    else if (state.inputMode == InputMode.Pointer)
                    {
                        state.inputMode = InputMode.Move;
                    }
                }
                else if (stateChange.newMode != InputMode.None)
                {
                    state.inputMode = stateChange.newMode;
                }
            }
            #endregion

            #region Mouse Movements
            if (mouseMove != null)
            {
                if (mouseMove.commandTarget == CommandTarget.Cursor)
                {
                    if (mouseMove.moveType == MouseMoveType.Absolute)
                    {
                        state.cursorPosition.X = state.centerPosition.X + (int)(state.pointCommandValue.X * mouseMove.moveScale.X);
                        state.cursorPosition.Y = state.centerPosition.Y + (int)(state.pointCommandValue.Y * mouseMove.moveScale.Y);
                    }
                }
            }

            if (target == CommandTarget.TargetReticule)
            {
                VirtualMouse.MoveAbsolute(state.targetingReticulePosition.X, state.targetingReticulePosition.Y);
            }
            else if (target == CommandTarget.Cursor)
            {
                VirtualMouse.MoveAbsolute(state.cursorPosition.X, state.cursorPosition.Y);
            }
            else
            {
                //
            }
            #endregion


            #region Keys
            if (key.HasValue)
            {
                if (commandState == KeyboardMouseCommandState.Down)
                {
                    VirtualKeyboard.KeyDown(key.Value);
                }
                else
                {
                    VirtualKeyboard.KeyUp(key.Value);
                }
            }
            #endregion

            #region Mouse Buttons
            if (mouseButton.HasValue)
            {
                if (commandState == KeyboardMouseCommandState.Down)
                {
                    if (mouseButton.Value == MouseButtons.Left)
                    {
                        VirtualMouse.LeftDown();
                    }
                    else if (mouseButton.Value == MouseButtons.Right)
                    {
                        VirtualMouse.RightDown();
                    }
                }
                else
                {
                    if (mouseButton.Value == MouseButtons.Left)
                    {
                        VirtualMouse.LeftUp();
                    }
                    else if (mouseButton.Value == MouseButtons.Right)
                    {
                        VirtualMouse.RightUp();
                    }
                }
            }
            #endregion
        }
Beispiel #18
0
        public void Update(GamePadState newState)
        {
            currentControllerState.connected = newState.IsConnected;

            if (!newState.IsConnected)
            {
                return;
            }

            if (currentControllerState.inputMode == InputMode.Move)
            {
                int DeltaX = (int)currentControllerState.cursorPosition.X - (int)center.X;
                int DeltaY = (int)currentControllerState.cursorPosition.Y - (int)center.Y;

                Vector2 deltaVector = new Vector2(DeltaX, DeltaY);
                deltaVector.Normalize();

                deltaVector *= 1000.0f;


                currentControllerState.centerPosition = new UIntVector((uint)(center.X + deltaVector.X), (uint)(center.Y + deltaVector.Y));
                // VirtualMouse.MoveAbsolute(center.X, center.Y);
            }
            else
            {
                //
            }



            foreach (ControllerInputBinding binding in bindings)
            {
                if (binding.button != 0)
                {
                    if (binding.buttonState == ControllerButtonState.OnDown)
                    {
                        if ((newState.IsButtonDown(binding.button)) && (lastState.IsButtonUp(binding.button)))
                        {
                            enqueueCommands(binding, currentControllerState);
                        }
                    }
                    else if (binding.buttonState == ControllerButtonState.OnUp)
                    {
                        if ((newState.IsButtonUp(binding.button)) && (lastState.IsButtonDown(binding.button)))
                        {
                            enqueueCommands(binding, currentControllerState);
                        }
                    }
                    else if (binding.buttonState == ControllerButtonState.WhileDown)
                    {
                        if (newState.IsButtonDown(binding.button))
                        {
                            enqueueCommands(binding, currentControllerState);
                        }
                    }
                    else if (binding.buttonState == ControllerButtonState.WhileUp)
                    {
                        if (newState.IsButtonUp(binding.button))
                        {
                            enqueueCommands(binding, currentControllerState);
                        }
                    }
                }

                if (binding.trigger != null)
                {
                    if (binding.trigger.side == ControllerTrigger.Left)
                    {
                        if (binding.triggerState == ControllerTriggerState.OnDown)
                        {
                            if ((newState.Triggers.Left > binding.trigger.position) && (lastState.Triggers.Left < binding.trigger.position))
                            {
                                enqueueCommands(binding, currentControllerState);
                            }
                        }
                        else if (binding.triggerState == ControllerTriggerState.OnUp)
                        {
                            if ((newState.Triggers.Left < binding.trigger.position) && (lastState.Triggers.Left > binding.trigger.position))
                            {
                                enqueueCommands(binding, currentControllerState);
                            }
                        }
                        else if (binding.triggerState == ControllerTriggerState.WhileDown)
                        {
                            if (newState.Triggers.Left > 0)
                            {
                                enqueueCommands(binding, currentControllerState);
                            }
                        }
                        else if (binding.triggerState == ControllerTriggerState.WhileUp)
                        {
                            if (newState.Triggers.Left == 0)
                            {
                                enqueueCommands(binding, currentControllerState);
                            }
                        }
                    }
                    else if (binding.trigger.side == ControllerTrigger.Right)
                    {
                        if (binding.triggerState == ControllerTriggerState.OnDown)
                        {
                            if ((newState.Triggers.Right > binding.trigger.position) && (lastState.Triggers.Right < binding.trigger.position))
                            {
                                enqueueCommands(binding, currentControllerState);
                            }
                        }
                        else if (binding.triggerState == ControllerTriggerState.OnUp)
                        {
                            if ((newState.Triggers.Right < binding.trigger.position) && (lastState.Triggers.Right > binding.trigger.position))
                            {
                                enqueueCommands(binding, currentControllerState);
                            }
                        }
                        else if (binding.triggerState == ControllerTriggerState.WhileDown)
                        {
                            if (newState.Triggers.Right > 0)
                            {
                                enqueueCommands(binding, currentControllerState);
                            }
                        }
                        else if (binding.triggerState == ControllerTriggerState.WhileUp)
                        {
                            if (newState.Triggers.Right == 0)
                            {
                                enqueueCommands(binding, currentControllerState);
                            }
                        }
                    }
                }

                if (binding.stick != null)
                {
                    bool executeCommand;

                    if (binding.stick.side == ControllerStick.Left)
                    {
                        executeCommand = true;

                        if (binding.stick.newState == StickState.NotEqual)
                        {
                            if ((newState.ThumbSticks.Left.X == binding.stick.position.X) && (newState.ThumbSticks.Left.Y == binding.stick.position.Y))
                            {
                                executeCommand = false;
                            }
                        }
                        else if (binding.stick.newState == StickState.Equal)
                        {
                            if ((newState.ThumbSticks.Left.X != binding.stick.position.X) || (newState.ThumbSticks.Left.Y != binding.stick.position.Y))
                            {
                                executeCommand = false;
                            }
                        }

                        if (binding.stick.oldState == StickState.NotEqual)
                        {
                            if ((lastState.ThumbSticks.Left.X == binding.stick.position.X) && (lastState.ThumbSticks.Left.Y == binding.stick.position.Y))
                            {
                                executeCommand = false;
                            }
                        }
                        else if (binding.stick.oldState == StickState.Equal)
                        {
                            if ((lastState.ThumbSticks.Left.X != binding.stick.position.X) || (lastState.ThumbSticks.Left.Y != binding.stick.position.Y))
                            {
                                executeCommand = false;
                            }
                        }

                        if (executeCommand)
                        {
                            Microsoft.Xna.Framework.Vector2 inputCommandValue = new Microsoft.Xna.Framework.Vector2(newState.ThumbSticks.Left.X, newState.ThumbSticks.Left.Y);
                            enqueueCommands(binding, currentControllerState, inputCommandValue);
                        }
                    }
                    else if (binding.stick.side == ControllerStick.Right)
                    {
                        executeCommand = true;

                        if (binding.stick.newState == StickState.NotEqual)
                        {
                            if ((newState.ThumbSticks.Right.X == binding.stick.position.X) && (newState.ThumbSticks.Right.Y == binding.stick.position.Y))
                            {
                                executeCommand = false;
                            }
                        }
                        else if (binding.stick.newState == StickState.Equal)
                        {
                            if ((newState.ThumbSticks.Right.X != binding.stick.position.X) || (newState.ThumbSticks.Right.Y != binding.stick.position.Y))
                            {
                                executeCommand = false;
                            }
                        }

                        if (binding.stick.oldState == StickState.NotEqual)
                        {
                            if ((lastState.ThumbSticks.Right.X == binding.stick.position.X) && (lastState.ThumbSticks.Right.Y == binding.stick.position.Y))
                            {
                                executeCommand = false;
                            }
                        }
                        else if (binding.stick.oldState == StickState.Equal)
                        {
                            if ((lastState.ThumbSticks.Right.X != binding.stick.position.X) || (lastState.ThumbSticks.Right.Y != binding.stick.position.Y))
                            {
                                executeCommand = false;
                            }
                        }

                        if (executeCommand)
                        {
                            Microsoft.Xna.Framework.Vector2 inputCommandValue = new Microsoft.Xna.Framework.Vector2(newState.ThumbSticks.Right.X, newState.ThumbSticks.Right.Y);
                            enqueueCommands(binding, currentControllerState, inputCommandValue);
                        }
                    }
                }
            }


            while (stateChangeCommands.Count > 0)
            {
                VirtualKeyboard.AllUp();

                currentControllerState.targetingReticulePosition = currentControllerState.centerPosition;
                currentControllerState.cursorPosition            = currentControllerState.centerPosition;

                stateChangeCommands.Dequeue().Execute(ref currentControllerState);
            }

            while (cursorMoveCommands.Count > 0)
            {
                cursorMoveCommands.Dequeue().Execute(ref currentControllerState);
            }



            if (centerRandomTargetedCommands.Count > 0)
            {
                int DeltaX = (int)currentControllerState.cursorPosition.X - (int)center.X;
                int DeltaY = (int)currentControllerState.cursorPosition.Y - (int)center.Y;

                Vector2 deltaVector = new Vector2(DeltaX, DeltaY);
                deltaVector.Normalize();

                deltaVector *= 1000.0f;


                UIntVector centerOffset = new UIntVector((uint)(center.X + deltaVector.X), (uint)(center.Y + deltaVector.Y));
                VirtualMouse.MoveAbsolute(centerOffset.X, centerOffset.Y);
            }
            while (centerRandomTargetedCommands.Count > 0)
            {
                centerRandomTargetedCommands.Dequeue().Execute(ref currentControllerState);
            }



            if (reticuleTargetedCommands.Count > 0)
            {
                if ((currentControllerState.targetingReticulePosition.X == currentControllerState.centerPosition.X) && (currentControllerState.targetingReticulePosition.Y == currentControllerState.centerPosition.Y))
                {
                    VirtualMouse.MoveAbsolute(currentControllerState.cursorPosition.X, currentControllerState.cursorPosition.Y);
                }
                else
                {
                    VirtualMouse.MoveAbsolute(currentControllerState.targetingReticulePosition.X, currentControllerState.targetingReticulePosition.Y);
                }
            }

            Thread.Sleep(10);

            while (reticuleTargetedCommands.Count > 0)
            {
                reticuleTargetedCommands.Dequeue().Execute(ref currentControllerState);
            }

            //if ((currentControllerState.inputMode != InputMode.None) && (currentControllerState.inputMode != InputMode.Pointer))
            if (currentControllerState.inputMode != InputMode.None)
            {
                VirtualMouse.MoveAbsolute(currentControllerState.cursorPosition.X, currentControllerState.cursorPosition.Y);
            }
            while (cursorTargetedCommands.Count > 0)
            {
                cursorTargetedCommands.Dequeue().Execute(ref currentControllerState);
            }


            //if ((currentControllerState.inputMode != InputMode.None) && (currentControllerState.inputMode != InputMode.Pointer))



            while (untargetedCommands.Count > 0)
            {
                untargetedCommands.Dequeue().Execute(ref currentControllerState);
            }

            lastState = newState;
        }
Beispiel #19
0
 // Start is called before the first frame update
 void Start()
 {
     mouse = GetComponentInParent <VirtualMouse>();
     input = GetComponentInParent <VehicleInput>();
     gr    = GetComponentInParent <GraphicRaycaster>();
 }
Beispiel #20
0
        private void WindowScreenshot(String filepath, String filename, ImageFormat format)
        {
            if (bmp != null)
            {
                bmp.Dispose();
                bmp = null;
            }
            string basePath = filepath + "\\temp\\";
            bool   exists   = System.IO.Directory.Exists(basePath);

            if (!exists)
            {
                System.IO.Directory.CreateDirectory(basePath);
            }


            string fullpath  = basePath + filename;
            string fullpath2 = basePath + "scaled_" + filename;
            string testPath  = basePath + "test1.jpg";
            string tempPath  = filepath + "\\temp\\temp.jpg";
            string success   = basePath + "succeed";

            string[] result = new string[50];
            var      ps     = Process.GetProcessesByName("AtlasGame");

            if (ps.Length == 0)
            {
                colors.Text = "ATLAS ISNT OPEN YET";
                return;
            }
            Process p = ps[0];

            if (!isSetup())
            {
                colors.Text = "Need to find the skillshot region of screen!";
                setupEnv();
                doSearch(true);
            }
            Graphics  g;
            Rectangle screenshotBounds = searchMode ? useOffset : offset;

            if (screenshotBounds.Width <= 0 || screenshotBounds.Height <= 0)
            {
                return;
            }
            bmp = new Bitmap(screenshotBounds.Width, screenshotBounds.Height);
            g   = Graphics.FromImage(bmp);
            g.CopyFromScreen(screenshotBounds.X, screenshotBounds.Y, 0, 0, bmp.Size, CopyPixelOperation.SourceCopy);
            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            g.Dispose();

            if (bmp != null)
            {
                var         doingSkillShot = IsProgressPresent(bmp);
                Rectangle[] coords         = new Rectangle[] { };
                if (doingSkillShot.Height != 0 && doingSkillShot.X >= 0)
                {
                    Rectangle rounded     = new Rectangle(RoundOff(doingSkillShot.X), RoundOff(doingSkillShot.Y), RoundOff(doingSkillShot.Width), RoundOff(doingSkillShot.Height));
                    var       ratio       = RoundOff(doingSkillShot.Width / doingSkillShot.Height, 1);
                    var       screenRatio = RoundOff(screenshotBounds.Height / doingSkillShot.Height, 1);
                    Point     skillPos    = new Point((int)(100.0 * doingSkillShot.X / screenshotBounds.Width), (int)(100.0 * doingSkillShot.Y / screenshotBounds.Height));
                    var       seemsRight  = rounded.Height != 0 && rounded.Width != 0 && ratio >= 10 && ratio <= 14 && (!searchMode || (searchMode && skillPos.X > 25 && skillPos.X < 40 && skillPos.Y > 70 && skillPos.Y < 85));
                    doingSkillshotCheck.Checked = seemsRight;
                    if (seemsRight)
                    {
                        coords = getGoal(bmp, doingSkillShot);
                        if (searchMode && coords.Length == 3 && coords[1].Width > 0)
                        {
                            seeGoalCheck.Checked = true;
                            resultBox.Items.Insert(0, "MaybeOffset (" + rounded + ") ratio = " + ratio + ", positioning = " + (skillPos) + "%");
                            resultBox.Items.Insert(0, "Seems right, lets go with it.");
                            var unscaledOffset = new Rectangle(
                                (int)(doingSkillShot.X / widthScale),
                                (int)(doingSkillShot.Y / heightScale),
                                (int)(doingSkillShot.Width / widthScale),
                                (int)(doingSkillShot.Height / heightScale)
                                );
                            offset = doingSkillShot;

                            Properties.Settings.Default.Offset = offset;
                            Properties.Settings.Default.Save();
                            doSearch(false);
                            running = true;
                            RefreshTimer.Enabled = true;
                            setupEnv();
                            resultBox.Items.Insert(0, "Offset set to " + offset + ", (scaled: " + scaledOffset + ")");
                        }
                        if (coords.Length == 3 && coords[2].Width > 200 * heightScale && coords[1].X > 5 && coords[1].Width > 5)
                        {
                            seeGoalCheck.Checked = true;
                            var goal       = coords[1];
                            var current    = coords[0];
                            var wiggleRoom = (coords[2].Width / goal.Width - 5) * 3;
                            var currentMid = current.Left + current.Width / 2;

                            var shouldClick    = currentMid > (goal.Left - wiggleRoom) && currentMid < (goal.Right + wiggleRoom);
                            var goalStart      = (int)(1000.0 * (coords[1].X - coords[2].X) / coords[2].Width) / 10.0;
                            var goalEnd        = (int)((1000.0 * (coords[1].X + coords[1].Width) - coords[2].X) / coords[2].Width) / 10.0;
                            var currentPrecent = (int)((1000.0 * (current.X + (current.Width / 2.0)) - coords[2].X) / coords[2].Width) / 10.0;
                            var coordsString   =
                                System.DateTime.Now.ToLongTimeString() + ", " + widthScale + ": Current: " + current.Left + ", " +
                                "Goal: [" + coords[1].X + " - " + (coords[1].X + coords[1].Width) + "] +/- " + (int)(wiggleRoom) + " " +
                                "Total: [" + coords[2].X + " - " + (coords[2].X + coords[2].Width) + "]    Shot at (" + currentPrecent + "%) going for (" + goalStart + "% - " + goalEnd + "%)";
                            if (shouldClick && !clicked)
                            {
                                status.Text = "Status: At (" + currentPrecent + "%) going for (" + goalStart + "% - " + goalEnd + "%)";
                                previousMsg = coordsString;
                                VirtualMouse.LeftClick();
                                clicked   = true;
                                waitCount = 0;
                            }
                            if (clicked && previousMsg != "" && (centerColor == "RED" || centerColor == "GREEN"))
                            {
                                if (waitCount == 5)
                                {
                                    var hitRate = Properties.Settings.Default.hitRate;
                                    hitRate.X += (centerColor == "RED") ? 0 : 1;
                                    hitRate.Y += (centerColor == "RED") ? 1 : 0;
                                    Properties.Settings.Default.hitRate = hitRate;
                                    Properties.Settings.Default.Save();
                                    updateStats();
                                    if (centerColor == "RED")
                                    {
                                        var savePath = basePath + "miss-" + System.DateTime.Now.ToFileTimeUtc() + ".png";

                                        var rate = (int)(hitRate.X * 1000.0 / (hitRate.X + hitRate.Y)) / 10.0;
                                        resultBox.Items.Insert(0, "MISSED, Saving SS (" + savePath + ").");
                                        resultBox.Items.Insert(0, "Bot Status: Hits " + hitRate.X + "; Misses " + hitRate.Y + "; SuccessRate: (" + rate + "%)");
                                        bmp.Save(savePath, format);
                                        pictureBox1.ImageLocation = savePath;
                                    }
                                    frameCount = -50;
                                    resultBox.Items.Remove(previousMsg);
                                    resultBox.Items.Insert(0, previousMsg + " Result: " + (centerColor == "RED" ? "Missed!" : "Nailed It!"));
                                    previousMsg = "";
                                    status.Text = "Status: See a SkillShot, Already Clicked (" + (centerColor == "RED" ? "Miss" : "Hit") + ")";
                                    doSearch(false);
                                }
                                else
                                {
                                    waitCount++;
                                }
                            }
                        }
                        else
                        {
                            seeGoalCheck.Checked = false;
                        }
                    }
                }
                else
                {
                    status.Text                 = "Status: Waiting for SkillShot";
                    clicked                     = false;
                    seeGoalCheck.Checked        = false;
                    doingSkillshotCheck.Checked = false;
                    waitCount                   = 0;
                }

                frameCount++;
                if (frameCount == 2 && waitCount != 10)
                {
                    bmp.Save(tempPath, format);
                    pictureBox1.ImageLocation = tempPath;
                    frameCount = 0;
                }
            }
            bmp.Dispose();
        }
Beispiel #21
0
        protected override void WndProc(ref Message m)
        {
            try
            {
                if (wasException)
                {
                    base.WndProc(ref m);
                    return;
                }


                if (!systemReady)
                {
                    if (m.Msg == NativeMethods.CM_STARTENGINE)
                    {
                        ActivateEngine();
                        return;
                    }

                    if ((m.Msg == NativeMethods.WM_CLOSE) || (m.Msg == NativeMethods.WM_QUIT) || (m.Msg == NativeMethods.WM_QUERYENDSESSION))
                    {
                        UnloadAll();
                    }
                    base.WndProc(ref m);
                    return;
                }
                else //do it only if the system is ready
                {
                    if (context.Dispatch(ref m))
                    {
                        return;
                    }

                    int code = m.Msg;
                    switch (code)
                    {
                    case NativeMethods.WM_ACTIVATEAPP:
                        // The WParam value identifies what is occurring.
                        bool appActive = (((int)m.WParam != 0));
                        {
                            if (GlobalSettings.HideOnClick)
                            {
                                if (!appActive)
                                {
                                    if (Manager.Visible && (!Manager.Fading))
                                    {
                                        if (!context.HookActive)
                                        {
                                            ChangeVisibility();
                                        }
                                    }
                                }
                            }
                        }
                        break;

                    case NativeMethods.WM_CLOSE:
                    case NativeMethods.WM_QUIT:
                        this.UnloadAll();
                        break;

                    case NativeMethods.WM_QUERYENDSESSION:
                        this.UnloadAll();
                        break;

                    case NativeMethods.CM_CHECKUPDATE:
                        ShowNewVersion();
                        break;

                    case NativeMethods.WM_POWERBROADCAST:
                        if (m.WParam == (IntPtr)NativeMethods.PBT_APMRESUMEAUTOMATIC)
                        {
                            context.HidePulsar();
                            if (Settings.Default.ShowPulsar)
                            {
                                Pulsar.RestoreAlpha();
                                Pulsar.Alpha = 60;
                                context.ShowPulsar();
                                Pulsar.DeactivatePulsar();
                            }
                        }
                        break;

                    case NativeMethods.CM_RBUTTONDOWN:
                    {
                        if (GlobalSettings.UseMouseActivation)
                        {
                            if (GlobalSettings.UseRightClick)
                            {
                                TraceDebug.Trace("CM_RBUTTONDOWN");
                                if (!trackRightDown)
                                {
                                    trackRightDown = true;
                                    if (!context.Manager.Visible)
                                    {
                                        timerIntercept.Enabled = true;
                                    }
                                }
                            }
                        }
                        break;
                    }

                    case NativeMethods.CM_RBUTTONUP:
                    {
                        if (GlobalSettings.UseMouseActivation)
                        {
                            if (GlobalSettings.UseRightClick)
                            {
                                TraceDebug.Trace("CM_RBUTTONUP");
                                timerIntercept.Enabled = false;

                                if (trackRightDown)
                                {
                                    trackRightDown = false;
                                    if (!trackRightUp)
                                    {
                                        trackRightUp = true;
                                        MouseHook.PauseIntercept();
                                        VirtualMouse.RightClick();
                                    }
                                    else
                                    {
                                        trackRightUp = false;
                                        MouseHook.ResumeIntercept();
                                    }
                                }
                            }
                        }
                        break;
                    }

                    case NativeMethods.CM_MBUTTONUP:
                    case NativeMethods.CM_XBUTTONUP:

                        if (GlobalSettings.UseMouseActivation)
                        {
                            int             xButton    = (int)m.WParam;
                            MouseHookButton hookButton = MouseHookButton.None;

                            if (m.Msg == NativeMethods.CM_MBUTTONUP)
                            {
                                hookButton = MouseHookButton.Wheel;
                            }
                            else
                            {
                                switch (xButton)
                                {
                                case NativeMethods.XBUTTON1:
                                    hookButton = MouseHookButton.XButton1;
                                    break;

                                case NativeMethods.XBUTTON2:
                                    hookButton = MouseHookButton.XButton2;
                                    break;

                                default:
                                    hookButton = MouseHookButton.None;
                                    break;
                                }
                            }

                            if (GlobalSettings.MouseHook != hookButton)
                            {
                                return;
                            }

                            Keys modifiers = (Keys)m.LParam;

                            if (GlobalSettings.MouseModifiers != modifiers)
                            {
                                return;
                            }

                            ActivateUsingMouse(true);
                        }
                        return;

                    case NativeMethods.CM_DESKTOPCLICK:
                        if (GlobalSettings.UseMouseActivation)
                        {
                            if (Manager != null)
                            {
                                if (context.HookActive)
                                {
                                    return;
                                }

                                if (GlobalSettings.DesktopClick)
                                {
                                    ActivateUsingMouse(true);
                                }
                            }
                        }
                        return;

                    case NativeMethods.WM_HOTKEY:
                        if (NativeMethods.IsMetroActive())
                        {
                            return;
                        }
                        if (GlobalSettings.UseKeyboardActivation)
                        {
                            if (Manager != null)
                            {
                                if (context.HookActive)
                                {
                                    return;
                                }

                                if (GlobalSettings.CircleSelector)
                                {
                                    if (ringKeys != null)
                                    {
                                        if (((int)m.WParam) == (ringKeys.Id))
                                        {
                                            Manager.SwitchRing();
                                        }
                                    }
                                }

                                if (hotKeys != null)
                                {
                                    if (((int)m.WParam) == (hotKeys.Id))
                                    {
                                        if (Manager.Visible)
                                        {
                                            if (NativeMethods.GetForegroundWindow() != Manager.Handle)
                                            {
                                                Manager.Visible = false;
                                                Manager.Rotate(0);
                                                ChangeVisibility();
                                                return;
                                            }
                                        }
                                        ChangeVisibility();
                                    }
                                }
                            }
                        }
                        return;

                    case NativeMethods.CM_SPLASHCLOSE:
                        if (splashScreen != null)
                        {
                            splashScreen.Dispose();
                            splashScreen = null;
                        }
                        break;

                    default:
                        break;
                    }
                    base.WndProc(ref m);
                }
            }
            catch (Exception ex)
            {
                TraceDebug.Trace(ex);
                if (!wasException)
                {
                    wasException = true;
                    throw new KrentoEngineException("Krento Engine Error: ", ex);
                }
            }
        }
        public void OrderATaxi()
        {
            var resultDelay = EnterAddresses();

            if (resultDelay != TimeSpan.Zero)
            {
                Thread.Sleep(resultDelay);
            }

            int startIndex = 23;

            KeyValuePair <IntPtr, WindowRectangle>[]
            windows = _windows.ToArray();

            Stopwatch nextDelay = Stopwatch.StartNew();

            for (int i = 0; i < windows.Length; i++)
            {
                int index = startIndex;
                if (nextDelay.IsRunning)
                {
                    nextDelay.Stop();
                    resultDelay = TimeSpan.FromMilliseconds(_clickManager
                                                            .TaxiOrderingClicks[index].Delay) -
                                  nextDelay.Elapsed;

                    if (resultDelay > TimeSpan.Zero)
                    {
                        Thread.Sleep(resultDelay);
                    }
                }

                // Запускаем поиск такси в первом окне.
                // Click Select Bolt
                PerformClick(windows[i].Value,
                             _clickManager.TaxiOrderingClicks[index++]);

                // Click Request Bolt
                PerformClick(windows[i].Value,
                             _clickManager.TaxiOrderingClicks[index++]);

                // Click OK in messagebox (only once)
                PerformClick(windows[i].Value,
                             _clickManager.TaxiOrderingClicks[index++]);

                // Click chevron-up button
                PerformClick(windows[i].Value,
                             _clickManager.TaxiOrderingClicks[index++]);

                // Click Call
                PerformClick(windows[i].Value,
                             _clickManager.TaxiOrderingClicks[index++]);

                // DoubleClick to copy number

                VirtualMouse.SendMouseDoubleClick(windows[i].Value
                                                  .GetScreenPoint(_clickManager.TaxiOrderingClicks[index]
                                                                  .Position));

                // Ожидание для гарантии, что номер успел скопироваться в буфер обмена.
                Thread.Sleep(1000);

                // Сохранение номера телефона водителя.
                SaveNumberFromBuffer();

                Thread.Sleep(_clickManager.TaxiOrderingClicks[index++].Delay);

                // Click Home
                PerformClick(windows[i].Value,
                             _clickManager.TaxiOrderingClicks[index++]);

                // Click Bolt icon
                PerformClick(windows[i].Value,
                             _clickManager.TaxiOrderingClicks[index], false);

                Stopwatch startTime = Stopwatch.StartNew();
                if (i + 1 < windows.Length)
                {
                    // Запускаем поиск такси в следующем окне, если такое есть.
                    // Click Select Bolt
                    PerformClick(windows[i + 1].Value,
                                 _clickManager.TaxiOrderingClicks[startIndex]);

                    // Click Request Bolt
                    PerformClick(windows[i + 1].Value,
                                 _clickManager.TaxiOrderingClicks[startIndex + 1]);

                    // Click OK in messagebox (only once)
                    PerformClick(windows[i + 1].Value,
                                 _clickManager.TaxiOrderingClicks[startIndex + 2],
                                 false);

                    // Запускаем отсчёт времени для следующего окна.
                    nextDelay = Stopwatch.StartNew();
                }

                startTime.Stop();
                resultDelay = TimeSpan.FromMilliseconds(_clickManager
                                                        .TaxiOrderingClicks[index++].Delay) -
                              startTime.Elapsed;

                if (resultDelay > TimeSpan.Zero)
                {
                    Thread.Sleep(resultDelay);
                }

                // Click Cancel
                PerformClick(windows[i].Value,
                             _clickManager.TaxiOrderingClicks[index++]);

                // Click Cancel ride
                PerformClick(windows[i].Value,
                             _clickManager.TaxiOrderingClicks[index++]);

                // Click reason for cancellation
                int reasonIndex          = new Random().Next(0, 6); // всего 6 причин
                int caseAbsolutePosition =
                    450 + 41 *
                    reasonIndex; // (y=450 - первая причина на экране с h=768)
                double caseRelativePosition =
                    caseAbsolutePosition / 768.0;

                Point point = windows[i].Value.GetScreenPoint(new PointF(0.5f,
                                                                         (float)(_clickManager.TaxiOrderingClicks[index].Position
                                                                                 .Y * caseRelativePosition)));

                VirtualMouse.SendLeftClick(point);
                Thread.Sleep(_clickManager.TaxiOrderingClicks[index].Delay);
            }
        }
        private void hanldeRequest(String result)
        {
            if (result.Contains("MUp"))
            {
                VirtualMouse.Move(0, -10);
            }
            else if (result.Contains("MRight"))
            {
                str_response = "mr";
                VirtualMouse.Move(10, 0);
            }
            else if (result.Contains("MDown"))
            {
                VirtualMouse.Move(0, 10);
            }
            else if (result.Contains("MLeft"))
            {
                VirtualMouse.Move(-10, 0);
            }
            else if (result.Contains("MRClick"))
            {
                ServiceExample.VirtualMouse.RightClick();
            }
            else if (result.Contains("MLClick"))
            {
                ServiceExample.VirtualMouse.LeftClick();
            }


            else if (result.Contains("Shutdown"))
            {
                Shutdown_Restart_LogOff_Lock.shutdownBtn_Click();
            }
            else if (result.Contains("Logoff"))
            {
                Shutdown_Restart_LogOff_Lock.logOffBtn_Click();
            }
            else if (result.Contains("Restart"))
            {
                Shutdown_Restart_LogOff_Lock.restartBtn_Click();
            }

            else if (result.Contains("Lock"))
            {
                Shutdown_Restart_LogOff_Lock.LockWorkStation();
            }
            else if (result.Contains("Shutdown_a"))
            {
                Shutdown_Restart_LogOff_Lock.shotShutdownBtn_Click();
            }

            else if (result.Contains("cmd_"))
            {
                String cmd_command = result.Substring(result.IndexOf("cmd_") + 4);
                // MessageBox.Show("CMd = " + cmd_command);
                try
                {
                    Process.Start("" + cmd_command);
                }

                catch (Exception e)
                {
                    //     MessageBox.Show("Err = " + e.Message );
                }
            }
            //        else if (result.Contains("killp_"))
            //        {

            //            addToLog("killing request = : ----" + result+"----");
            //            String pname = result.Substring(result.IndexOf("killp_") + 6, result.Length - result.IndexOf("killp_") + 6);

            //            pname = pname.Trim();

            //          addToLog("killing pname = ----" + pname+"----");
            //    //      MessageBox.Show("Pname = ." + pname+".");



            //            Process[] p_cmd = Process.GetProcessesByName("cmd");
            //            //addToLog("custom list retrived name as " + "cmd" + " = " + p_cmd.Length);


            //            Process[] p_notepad = Process.GetProcessesByName("notepad");
            //           // addToLog("custom list retrived name as " + "notepad" + " = " + p_notepad.Length);


            //          //  Process[] ps = Process.GetProcessesByName(pname);
            //          //  addToLog("no of listitems retrived name as ----" + pname + "---- = " + ps.Length);
            //            //   MessageBox.Show("Count of processes having name - "+pname +" = " + ps.Length );
            //            foreach (Process p in p_notepad)
            //            {
            //                addToLog("killing process" );
            //                p.Kill();
            //                //                  MessageBox.Show("in for");
            //            }

            ////            MessageBox.Show("OLD COunt = " + p_old.Length + "\n NEW COunt = " + p_new.Length);
            //        }

            else if (result.Contains("getp"))
            {
                str_response = "";
                Process[]     pAll  = Process.GetProcesses();
                List <String> mList = new List <String>();

                for (int i = 1; i < pAll.Length; i++)
                {
                    mList.Add(pAll[i].ProcessName);
                }

                mList.Sort();

                str_response = pAll[0].ProcessName + "";

                for (int i = 1; i < mList.Count; i++)
                {
                    str_response = str_response + "" + "@#" + mList[i];
                }

//                MyProcess p1 = new MyProcess("process1");



                //JsonArray jsonArray = new JsonArray();
                //jsonArray.Add(JsonValue.CreateNumberValue(116));
                //jsonArray.Add(JsonValue.CreateNumberValue(3.14159));
                //jsonArray.Add(JsonValue.CreateBooleanValue(true));
                //jsonArray.Add(JsonValue.CreateStringValue("abc"));
                //string jsonString = jsonArray.Stringify();
            }


            else
            {
                addToLog("in else ");
            }
        }