How to prevent laptop screen brightness from changing when un/plugging battery power

brightness

When I am using my laptop, I continually adjust the screen's brightness based on the lighting conditions in the room (e.g. how much light is coming in from windows, etc.). But if I unplug the laptop or plug it back in, Windows looks at the default brightness setting in the power profile for "on battery" or "plugged in" and changes the brightness accordingly. This is a jarring experience and then I have to hunt down the ideal brightness for my current situation again, rather than getting on with my work.

I would like to make it so that plugging or unplugging the battery is not a trigger that adjusts the screen brightness at all. The screen brightness should only change when I adjust it myself. Does anybody know how this might be accomplished?

Edit: I have encountered this issue in both Windows Vista and Windows 7.

Best Answer

Ok, after few hours of brain excercies i have made this powershell script..here it is

while($true)
{

$a = Get-WmiObject -ns root/wmi -class wmiMonitorBrightNess
$a1 = $a.Currentbrightness

$b = Get-WmiObject -ns root/wmi -class batterystatus
$b1 = $b.poweronline

start-sleep 1

$b = Get-WmiObject -ns root/wmi -class batterystatus
$b2 = $b.poweronline

If ($b2 -ne $b1)
{
$c = Get-WmiObject -ns root/wmi -class wmiMonitorBrightNessMethods
$c.WmiSetBrightNess(0,$a1)
}

}

Copy in notepad and save with ".ps1" extension.

What it does is, it frequently checks for the power state plugged in or not. If power state is changed it will restore the previous brightness value.

I have tested this in my laptop with Win8.1, works fine.

  • You can adjust the responsiveness by modifying start-sleep value (currently it is 1 second)

  • To run this script Powershell execution policy must be changed from default.

  • This script is only theoretical example, in practice the powershell windows will remain open, may be problematic for some. I am not discussing the ways to hide the window.