increase or decrease brightness
Posted: Feb 23rd, ’19, 16:18
change the default shortcut used for brightness because I'm using another app called flux and i can't use Ctrl + wheelup/down
All-in-One Automation Software
https://www.fastkeysautomation.com/forum/
https://www.fastkeysautomation.com/forum/viewtopic.php?t=840
Code: Select all
#NoEnv
#Persistent, On
#SingleInstance, Force
#WinActivateForce
#NoTrayIcon
; Change Volume with the mouse wheel on the taskbar
DetectHiddenWindows, On
SetTitleMatchMode, 2
MouseIsOver(WinTitle)
{
MouseGetPos,,, Win
return WinExist(WinTitle . " ahk_id " . Win)
}
#If MouseIsOver("ahk_class Shell_TrayWnd")
WheelUp::Send, {Volume_Up}
WheelDown::Send, {Volume_Down}
#If
; Change Brightness with the mouse wheel on the right edge of the screen
CoordMode Mouse, Screen
$WheelUp::
mouseGetPos,x
if (x >= A_ScreenWidth - 1)
AdjustScreenBrightness(3)
else
Send {WheelUp}
Return
$WheelDown::
mouseGetPos,x
if (x >= A_ScreenWidth - 1)
AdjustScreenBrightness(-3)
else
Send {WheelDown}
Return
; Code for Adjusting Screen
AdjustScreenBrightness(step) {
static 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")
for i in monitors {
curr := i.CurrentBrightness
break
}
toSet := curr + step
if (toSet < 10)
toSet := 10
if (toSet > 100)
toSet := 100
for i in monMethods {
i.WmiSetBrightness(1, toSet)
break
}
}