Tuesday, November 7, 2017

How to enable/disable Windows 10 battery saver in program?

Leave a Comment

I'm writing a small program to save my laptop's battery, and I can now switch between power schemes using PowerSetActiveScheme.

The next step is to control the battery saver in Windows 10. Though I can read the state of it using GetSystemPowerStatus, I can't find a way to enable/disable it programmatically. Are there any functions in Windows API to do this?

3 Answers

Answers 1

Most probably you can do it Linux-way, by calling a system app named PowerCfg through ShellExecuteEx():

powercfg /setdcvalueindex SCHEME_CURRENT SUB_ENERGYSAVER ESBATTTHRESHOLD 100 powercfg /setactive scheme_current 

This means that the energy saver is activated even when the battery percentage equals 100%. SUB_ENERGYSAVER and its sub-GUID ESBATTTHRESHOLD are described here.

Answers 2

You seem to be out of luck. MSDN docs show no API through which the battery saver could be controlled. Examining SettingsHandlers_OneCore_BatterySaver shows that only GetSetting is exposed. Even SetPowerState in WMI Win32_Battery is not implemented -- I know this is not exactly what you need, but it shows that Microsoft has not gotten around to exposing the battery-related functionality. At this point, instead of reverse-engineering the button click, your best bet is probably to emulate it with something like AutoHotKey, however beware of the pitfalls with that.

Answers 3

You can follow this step by step tutorial

Click or tap the “Battery saver” tile to activate or deactivate it.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment