Last active
November 18, 2020 21:36
-
-
Save TLMcode/b56c71ef4785f1ef8daada9c36a38db4 to your computer and use it in GitHub Desktop.
Change Display Brightness using AHk & WMI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Variables | |
Increments := 10 ; < lower for a more granular change, higher for larger jump in brightness | |
CurrentBrightness := GetCurrentBrightNess() | |
; Hot Keys | |
F6::ChangeBrightness( CurrentBrightness -= Increments ) ; decrease brightness | |
F7::ChangeBrightness( CurrentBrightness += Increments ) ; increase brightness | |
; Functions | |
ChangeBrightness( ByRef brightness, timeout = 1 ) | |
{ | |
if ( brightness > 0 && brightness < 100 ) | |
{ | |
For property in ComObjGet( "winmgmts:\\.\root\WMI" ).ExecQuery( "SELECT * FROM WmiMonitorBrightnessMethods" ) | |
property.WmiSetBrightness( timeout, brightness ) | |
} | |
else if ( brightness >= 100 ) | |
{ | |
brightness := 100 | |
} | |
else if ( brightness <= 0 ) | |
{ | |
brightness := 0 | |
} | |
} | |
GetCurrentBrightNess() | |
{ | |
For property in ComObjGet( "winmgmts:\\.\root\WMI" ).ExecQuery( "SELECT * FROM WmiMonitorBrightness" ) | |
currentBrightness := property.CurrentBrightness | |
return currentBrightness | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment