2
Answers

turn OFF screen saver programmatically

learner learner

learner learner

14y
10.9k
1
[DllImport("User32.dll")]
public static extern int SendMessage
(IntPtr hWnd,
uint Msg,
uint wParam,
uint lParam);

public const uint WM_SYSCOMMAND = 0x112;
public const uint SC_SCREENSAVE = 0xF140;

public enum SpecialHandles
{
HWND_DESKTOP = 0x0,
HWND_BROADCAST = 0xFFFF
}

public static void TurnOnScreenSaver()
{
SendMessage(
new IntPtr((int)SpecialHandles.HWND_BROADCAST),
WM_SYSCOMMAND,
SC_SCREENSAVE,
0);
}

this code works fine. i found it from this forum.

i need another method like TurnOnScreenSaver() that stops the screen saver. That is i wanna turn on the screen saver first (already done) then on a specific condition i wanna turn off the screen saver and continue the process(on and off)
Answers (2)