Last active
March 23, 2024 18:09
-
-
Save krrr/3c3f1747480189dbb71f to your computer and use it in GitHub Desktop.
Windows screen brightness fine tune (autohotkey)
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
#,:: | |
AdjustScreenBrightness(-3) | |
Return | |
#.:: | |
AdjustScreenBrightness(3) | |
Return | |
AdjustScreenBrightness(step) { | |
service := "winmgmts:{impersonationLevel=impersonate}!\\.\root\WMI" | |
monitors := ComObjGet(service).ExecQuery("SELECT * FROM WmiMonitorBrightness WHERE Active=TRUE") | |
monMethods := ComObjGet(service).ExecQuery("SELECT * FROM wmiMonitorBrightNessMethods WHERE Active=TRUE") | |
minBrightness := 5 ; level below this is identical to this | |
for i in monitors { | |
curt := i.CurrentBrightness | |
break | |
} | |
if (curt < minBrightness) ; parenthesis is necessary here | |
curt := minBrightness | |
toSet := curt + step | |
if (toSet > 100) | |
return | |
if (toSet < minBrightness) | |
toSet := minBrightness | |
for i in monMethods { | |
i.WmiSetBrightness(1, toSet) | |
break | |
} | |
} |
Hey, I saw this script and I was wondering how to get the current brightness of the screen outside the function.
@Ahmad-f79 Does it work on Windows 11 too? I'm trying it but it shows the volume indicator instead
@Ahmad-f79 Does it work on Windows 11 too? I'm trying it but it shows the volume indicator instead
The below code works fine in Windows 11. You can adjust the brightness using Shift+Mouse Scroller Up/Down
.
;Shift + Mouse Scroller
+WheelDown::
AdjustScreenBrightness(-5)
Return
+WheelUp::
AdjustScreenBrightness(5)
Return
AdjustScreenBrightness(step) {
service := "winmgmts:{impersonationLevel=impersonate}!\\.\root\WMI"
monitors := ComObjGet(service).ExecQuery("SELECT * FROM WmiMonitorBrightness WHERE Active=TRUE")
monMethods := ComObjGet(service).ExecQuery("SELECT * FROM wmiMonitorBrightNessMethods WHERE Active=TRUE")
minBrightness := 5 ; level below this is identical to this
for i in monitors {
curt := i.CurrentBrightness
break
}
if (curt < minBrightness) ; parenthesis is necessary here
curt := minBrightness
toSet := curt + step
if (toSet > 100)
return
if (toSet < minBrightness)
toSet := minBrightness
for i in monMethods {
i.WmiSetBrightness(1, toSet)
break
}
}
@erbanku Thank you, yes I'm using that piece of code, but it does not let the brightness bar popup appear
I tried using the code posted by @Ahmad-f79 but it doesn't work (I'm on Windows 11)
@Rabelaiss Did you find a solution to display the Brightness OSD on W11 ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm not using this script anymore, and recommend this opensource uwp app: https://github.com/xanderfrangos/twinkle-tray