Ejemplo n.º 1
0
        private void OnUpdate(object sender, ElapsedEventArgs e)
        {
            timerUpdate.Stop();
            string activeWindow = WinUtils.GetActiveWindow();

            if (activeWindow == null || (activeWindow != Constants.KO_WINDOW && !activeWindow.Contains("Microsoft Visual Studio")))
            {
                btnStop_Click(null, null);
                return;
            }

            if (upDirection.IsZero())
            {
                TrySetUpDir();
            }

            SetCurrentPosition();

            distanceToDestination = Math.Abs((destination - currentPos).Length);
            if (distanceToDestination <= lengthDiffForReachingDestination)
            {
                Console.WriteLine("DONE!!!!");
                btnStop_Click(null, null);
                return;
            }
            else if (isMoving && ShouldReajustPosition())
            {
                isMoving = false;
                KeyUtils.SendCharUp('w');
                currentDirectionStartPoint = currentPos;
                StartMove();
            }
            timerUpdate.Start();
        }
Ejemplo n.º 2
0
 public override void OnLeave()
 {
     base.OnLeave();
     Character.PositionChanged -= OnPositionChanged;
     Character.PositionChanged -= OnPositionChangedMoveBack;
     KeyUtils.SendCharUp('w');
 }
Ejemplo n.º 3
0
        private void Move(EDirection direction, Action onCompleted = null)
        {
            this.onMoveCompleted = onCompleted;
            this.direction       = direction;
            KeyUtils.SendCharUp('w');
            startPos = Character.Position;
            double angle    = GetAngleForDirection();
            Point  newPoint = ScreenPosition.RotateDirection(initialDirection, angle);

            ActionManager.SendDelayedAction(0.25f, () =>
            {
                ClickAt(newPoint, () =>
                {
                    if (!IsActive)
                    {
                        return;
                    }
                    timerStuck.Start();
                    ScreenPosition.SetClickPoint(newPoint);
                    KeyUtils.SendCharDown('w');
                    Character.PositionChanged -= OnMove;
                    Character.PositionChanged += OnMove;
                });
            });
        }
Ejemplo n.º 4
0
 protected void SendKeyUp(char key, Action callback = null)
 {
     if (!IsActive)
     {
         return;
     }
     ActionManager.SendAction(() => { KeyUtils.SendCharUp(key); }, DELAY_BETWEEN_KEYS, callback);
 }
Ejemplo n.º 5
0
 public override void OnLeave()
 {
     base.OnLeave();
     Character.PositionChanged -= OnPositionChanged;
     KeyUtils.SendCharUp('w');
     ScreenPosition.StopCalculateDirection();
     timerStuck.Elapsed -= OnStuck;
     timerStuck.Stop();
 }
Ejemplo n.º 6
0
 private void btnStop_Click(object sender, EventArgs e)
 {
     lastAngle = 0;
     timerUpdate.Stop();
     isMoving = false;
     distanceToDestination = 0;
     KeyUtils.SendCharUp('w');
     upDirection = new Vector(0, 0);
     initialPos  = new Vector(0, 0);
     currentDirectionStartPoint = new Vector(0, 0);
 }
Ejemplo n.º 7
0
 private void PerformClickMove(Point screenPoint)
 {
     KeyUtils.SendCharUp('w');
     ScreenPosition.StopCalculateDirection();
     ActionManager.SendDelayedAction(0.1f, () =>
     {
         ClickAt(screenPoint, () =>
         {
             KeyUtils.SendCharDown('w');
         });
     });
 }
Ejemplo n.º 8
0
 private void PerformClickMove(Point screenPoint)
 {
     Debug.Log("Perform click move: " + screenPoint);
     previousClickPoint = screenPoint;
     KeyUtils.SendCharUp('w');
     ScreenPosition.StopCalculateDirection();
     isMoving = false;
     ActionManager.SendDelayedAction(0.1f, () =>
     {
         ClickAt(screenPoint, () =>
         {
             isMoving = true;
             KeyUtils.SendCharDown('w');
             ScreenPosition.SetClickPoint(screenPoint);
             isStuck = false;
             timerStuck.IntervalSeconds = settings.TimeBeforeStuck;
             timerStuck.Elapsed        += OnStuck;
             timerStuck.Restart();
         });
     });
 }
Ejemplo n.º 9
0
 private void btnUp_Click(object sender, EventArgs e)
 {
     txt1.Focus();
     KeyUtils.SendCharUp('r');
     //sim.Keyboard.KeyUp(WindowsInput.Native.VirtualKeyCode.VK_R);
 }