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(); }
public override void OnLeave() { base.OnLeave(); Character.PositionChanged -= OnPositionChanged; Character.PositionChanged -= OnPositionChangedMoveBack; KeyUtils.SendCharUp('w'); }
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; }); }); }
protected void SendKeyUp(char key, Action callback = null) { if (!IsActive) { return; } ActionManager.SendAction(() => { KeyUtils.SendCharUp(key); }, DELAY_BETWEEN_KEYS, callback); }
public override void OnLeave() { base.OnLeave(); Character.PositionChanged -= OnPositionChanged; KeyUtils.SendCharUp('w'); ScreenPosition.StopCalculateDirection(); timerStuck.Elapsed -= OnStuck; timerStuck.Stop(); }
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); }
private void PerformClickMove(Point screenPoint) { KeyUtils.SendCharUp('w'); ScreenPosition.StopCalculateDirection(); ActionManager.SendDelayedAction(0.1f, () => { ClickAt(screenPoint, () => { KeyUtils.SendCharDown('w'); }); }); }
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(); }); }); }
private void btnUp_Click(object sender, EventArgs e) { txt1.Focus(); KeyUtils.SendCharUp('r'); //sim.Keyboard.KeyUp(WindowsInput.Native.VirtualKeyCode.VK_R); }