In many workplaces, the domain policy will not allow you to disable your screensaver. Often it's not even possible to adjust the time before the screensaver sets in. When the screensaver starts, you will have to login to the workstation again using ctrl+alt+del and then enter domain credentials.
When using multiple workstations, both physical and virtual, this process can be very time consuming and annoying during the work day, if you e.g. have to login to different machines every third minute.
Disable Screensaver is a small light utility that runs in the background and makes sure that the screensaver will not be activated automatically.
Disable Screensaver does not require any installation. Just place the standalone executable DisableScreensaver.exe in a directory and run it.
Disable Screensaver will query the default domain screensaver timeout value. Then behind the scenes, it will press the "Scroll Lock" button twice a second before the screensaver will start. This will reset the screensaver timeout value, and not in any way interfere with your workflow.
Using the Code
To be able to programatically press the "Scroll Lock" button, PInvoke is used:
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);
private static void PressScrollLock()
const byte vkScroll = 0x91;
const byte keyeventfKeyup = 0x2;
keybd_event(vkScroll, 0x45, 0, (UIntPtr)0);
keybd_event(vkScroll, 0x45, keyeventfKeyup, (UIntPtr)0);
PInvoke is also used to query the domain policy for the sceensaver timout:
private static extern bool SystemParametersInfo(int uAction, int uParam, ref int lpvParam, int flags);
public static Int32 GetScreenSaverTimeout()
Int32 value = 0;
SystemParametersInfo(14, 0, ref value, 0);