I found a solution to move the cursor via this URL in my Windows-Form app.
How to move mouse cursor using C#?
but as i want to run infinitely but with a break so that when i want to stop it, it should stop here is what i'm trying to achieve.
private void btnMove_Click(object sender, EventArgs e)
{
//int i = 0;
while (true)
{
//i++;
Cursor = new Cursor(Cursor.Current.Handle);
Cursor.Position = new Point(Cursor.Position.X - 40, Cursor.Position.Y - 40);
Thread.Sleep(5000);
Cursor.Position = new Point(Cursor.Position.X + 40, Cursor.Position.Y + 40);
}
//Task t = new Task(() =>
//{
//});
//t.Start();
}
It works but freezes my code. I just want to run it, and whenever i want to stop it, it should stop not freeze.