Prevent screen from sleeping with C#
I have created a small C# console app to move the pointer around the screen, in the hope that this would prevent the screen from sleeping / locking after a few minutes. Unfortunately the screen still goes to sleep after a few minutes. Does anyone know if it's actually possible to write something in C# which will act like user input (either mouse or keyboard), and prevent the screen from sleeping / locking automatically? Here is what I have, which I thought might do the trick. class Program { [DllImport("user32.dll")] static extern bool SetCursorPos(int X, int Y); static Random rnd = new Random