Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find the screen brightness with cmd on Windows?

Tags:

batch-file

cmd

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?

like image 837
The ATLAS CGZ Avatar asked Dec 23 '22 23:12

The ATLAS CGZ


2 Answers

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>)"
like image 98
braggPeaks Avatar answered Jan 24 '23 10:01

braggPeaks


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

like image 27
tukan Avatar answered Jan 24 '23 11:01

tukan