I want to be able to move the mouse cursor by means of C# code. Surprisingly there isn't any useful link or previously asked SO question about the same.
What I really want? Just some help to write a console app that runs in a while (true) {...} loop and moves the mouse every five or so minutes.
while (true) {
MoveMouseToRandomPosition(); //Move mouse to multiple random positions
Thread.Sleep(5 * 60 * 1000); //Go to sleep for the next five minutes
}
What I really really want? Be able to run this console app when I am working from home on a light day so that my status in outlook does not go Yellow (which means that I have been 'Away' for more than five minutes).
Guys, please do not take this as a 'Give me teh codez' question. Hints are perfectly fine. I can code the hints myself.
In WinForms you can do it using the Cursor object.
private void MoveCursor()
{
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);
}
Cursor.Position Property
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With