public void MoveMouse(int x, int y) { CoordinatePackage input = new CoordinatePackage { x = x, y = y }; if (!backgroundWorker1.IsBusy) { backgroundWorker1.RunWorkerAsync(input); } }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { CoordinatePackage value_received = e.Argument as CoordinatePackage; for (int i = 0; i < 2500; i++) { Cursor.Position = new Point(Cursor.Position.X + value_received.x, Cursor.Position.Y + value_received.y); Thread.Sleep(8); if (backgroundWorker1.CancellationPending) { return; } } }