I want to stop my monitor to stop sleep (which is driven by company policies). Below is the code I am using for that
while (true)
{
this.Cursor = new Cursor(Cursor.Current.Handle);
Cursor.Position = new Point(Cursor.Position.X - 50, Cursor.Position.Y - 50);
Cursor.Clip = new Rectangle(this.Location, this.Size);
System.Threading.Thread.Sleep(2000);
this.Cursor = new Cursor(Cursor.Current.Handle);
Cursor.Position = new Point(Cursor.Position.X + 50, Cursor.Position.Y + 50);
Cursor.Clip = new Rectangle(this.Location, this.Size);
}
I can see mouse moving without While loop. But with while it moves mouse only once and then it restrict the mouse to move to right side.
Is there any better way to do it?