I have a code that I am writing that can change the screen brightness according to user input, but this is based around the current screen brightness. Is there a way to obtain the screen brightness as an integer from command prompt?
In the past I have tried to do this by using the Power Config utility in cmd, but it failed. I tried looking it up and didn't find anything for Windows. The nearest solution I found was for IOS and Android.
I got lost after trying the following:
C:\Users\[me]>powercfg /q | find "(Display brightness)"
Power Setting GUID: aded5e82-b909-4619-9949-f5d71dac0bcb (Display brightness)
C:\Users\[me]>
I expected a value for screen brightness like '45' or '45%' to be returned, but it gave me a display ID instead. What do I do?
Query screen brightness
powershell -Command "Get-Ciminstance -Namespace root/WMI -ClassName WmiMonitorBrightness | Select -ExpandProperty "CurrentBrightness""
Change screen brightness
powershell -Command "(Get-WmiObject -Namespace root/WMI -Class WmiMonitorBrightnessMethods).WmiSetBrightness(1,<YOUR_BRIGHTNESS_INTEGER>)"
You were close. Here is how you do it.
The format of powercfg is:
POWERCFG -SETDCVALUEINDEX <SCHEME_GUID> <SUBGROUP_GUID> <SETTING_GUID> value
To find out your information:
For <SCHEME_GUID>
:
powercfg /q | findstr Scheme
Power Scheme GUID: a3e508ca-5ab1-4c55-bee1-9edfb71ba0a4 (HP Optimized (recommended))
For <SUBGROUP_GUID>
and <SETTING_GUID>
:
powercfg /q | findstr Display
Subgroup GUID: 7516b95f-f776-4464-8c53-06167f40ca19 (Display)
Power Setting GUID: aded5e82-b909-4619-9949-f5d31dac0bcb (Display brightness)
Now with the GUID values and brightness in percentage - lets say 23% - like this:
powercfg -SetDcValueIndex a3e508ca-5ab1-4c55-bee1-9edfb71ba0a4 7516b95f-f776-4464-8c53-06167f40ca19 aded5e82-b909-4619-9949-f5d31dac0bcb 23
Edit: To view current britness level:
Check your current settings with the GUID
: aded5e82-b909-4619-9949-f5d71dac0bcb
Just let the powercfg /q > current_settings.txt
. Will save the output to current_settings.txt
file and there search for the aded5e82-b909-4619-9949-f5d71dac0bcb
.
For example mine:
Power Setting GUID: aded5e82-b909-4619-9949-f5d71dac0bcb (Display brightness)
Minimum Possible Setting: 0x00000000
Maximum Possible Setting: 0x00000064
Possible Settings increment: 0x00000001
Possible Settings units: %
Current AC Power Setting Index: 0x00000046
Current DC Power Setting Index: 0x00000032
The value denotes the percentage (%). The increment can be done by 1% (as you can see).
There is even MSDN page about the brightness
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With