Skip to content

Instantly share code, notes, and snippets.

@anonymous1184
Last active May 15, 2024 13:57
Show Gist options
  • Save anonymous1184/9761e07daeb9e7dd2ac169eb4024f065 to your computer and use it in GitHub Desktop.
Save anonymous1184/9761e07daeb9e7dd2ac169eb4024f065 to your computer and use it in GitHub Desktop.
Brightness changer + OSD

; Version: 2022.11.17.1
; Usage and examples: https://redd.it/owgn3j
Brightness(Offset) {
static last := ""
wmi := ComObjGet("winmgmts:\\.\root\WMI")
if (last = "") {
last := wmi.ExecQuery("SELECT * FROM WmiMonitorBrightness")
.ItemIndex(0)
.CurrentBrightness
}
DetectHiddenWindows On
hWnd := DllCall("FindWindowA", "AStr","NativeHWNDHost", "Ptr",0, "Ptr")
PostMessage 0xC028, 0x037,,, % "ahk_id" hWnd
brightness := Min(100, Max(0, last + Offset))
if (brightness = last)
return
last := brightness
wmi.ExecQuery("SELECT * FROM WmiMonitorBrightnessMethods")
.ItemIndex(0)
.WmiSetBrightness(0, brightness)
ObjRelease(wmi)
}
@Lorenzo501
Copy link

Lorenzo501 commented Oct 21, 2023

automatically regulate

Is completely out of the scope (this is for manual adjustment). Most likely there should be tools for that, and others that overlap with HDR stuff.

Thanks so much, you were right and now I no longer need to bother with the javascript bookmark!
There is one chrome extension that does this: "Sites Dimmer - sharp brightness reduction". Paired with "Dark Reader" it does an amazing job.
I'm now using "Dark Reader" to affect only several websites that I've configured it for and I made sure that "Sites Dimmer - sharp brightness reduction" wasn't affecting those, but any other website with bright colors will be set to 85% brightness automatically.
Why I'm still using "Dark Reader" is b/c I quite like the custom dark theme that I have for some websites. So using both is really nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment