Use this script to automatically dimm your display to a specified brightness when you are inactive, and increase brightness again as soon as you start using your pen.
You can set the dimming timer, specify brightness when active and when inactive as well as add more triggers for staying active.
(Not all code is mine)
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#Persistent
; SCRIPT FOR AUTO-DIMMING:
Timer1()
Hotkey, ~LButton, Timer1
Hotkey, ~RButton, Timer1
Hotkey, ~Space, Timer1 ; YOU CAN ADD MORE TRIGGERS IN THIS FASHION
Hotkey, Esc, Exit_script ; EDIT HOTKEY TO EXIT SCRIPT QUICKLY HERE
Dimming() {
ChangeBrightness( 0 ) ;BRIGHTNESS WHEN INACTIVE
}
Brightening() {
ChangeBrightness( 90 ) ;BRIGHTNESS WHEN ACTIVE
}
Timer1() {
Brightening()
SetTimer, Dimming, 20000 ;TIMER BEFORE SCREEN DIMMS
}
; 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
}
Exit_script() {
Exitapp
}
P.S. I left some extra code in there for advanced users to make use of if they want to modify the script.