I have a new PC that doesn't support S3 sleep, only S0. I am working on a small application to initiate various modes of sleep on command. When I run powercfg -a, it tells me the only available sleep mode is S0 (I have hibernate disabled as I don't want to use it because it takes to long to wake).
I have found the following WIN32 API function that will cause the PC to go into the same sleep state as pressing Start, Shutdown, Sleep:
SendMessage(application_handle, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF);
This turns off the monitor and keyboard backlight. The PC's power light stays on and the fan sounds like it is still running, but my understanding is that this is part of the new "modern standby" which doesn't actually put the computer to sleep (where the fan shuts off and the power light blinks).
I have also set Windows Settings, Power settings as follows:
- Turn off monitor after [5 minutes]
- Put my device to sleep after [Never]
The reason I do this is if you allow the computer to go to "sleep" after some inactive period, Task Scheduler no longer runs tasks like overnight backups, etc. Leaving the sleep setting set to "never" allows Task Scheduler to run those tasks properly.
So these settings turn of the monitor by putting the computer into a state that is different than what happens when you use: Start, Shutdown, Sleep.
It would seem logical at first glance that:
SendMessage(application_handle, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF);
would only turn off the monitor, similar to the 5 minute timeout, but instead, it seems to more closely emulate the kind of sleep caused by Start, Shutdown, Sleep on my PC.
Does anyone know a programmatic (i.e. Win32 API) way to emulate the monitor turning off that doesn't go into the deeper sleep state? Basically, I'm looking for a way to programmatically initiate the sleep mode that Windows initiates when the Windows Power settings above trigger after 5 minutes of inactivity (just shutting off the monitor).
Thanks!
According to Entry to Modern Standby, there is no Win32 API to let Windows enter Modern Standby.
And according to Display, sleep, and hibernate idle timers, you can use SC_MONITORPOWER to Turn off the display but Modern Standby means putting the computer to sleep with the display being immediately powered down.