Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Reference: https://www.reddit.com/r/AutoHotkey/comments/rog13v/comment/hq96cky/
- ; ## Autoexecution ##
- #Persistent
- Menu, Tray, Icon, %A_ScriptDir%\images\icon.ico
- #SingleInstance Force
- SetBatchLines -1
- SetTimer tDim, 250
- vBrt := 255 ; Initial Brightness (Don't change!)
- ; #### Play Area Variables ####
- vDur := 1 ; Number of minutes to wait
- vMin := 70 ; Minimum dimness level (0-254)
- dRng := 4 ; Dimming frame skip (lower/slower)
- dDly := 15 ; Number of ms between dimming frames
- uRng := 8 ; Lighting frame skip (lower/slower)
- uDly := 15 ; Number of ms between lighting frames (0/Instant)
- wWidth := 10320 ; Total width of all displays
- wHeight := 1440 ; Total height of all displays
- xPos := -3440 ; Starting position of leftmost display
- yPos := 0 ; Starting position of leftmost display
- ; #### Gui Build ####
- Gui Dimmer:New, +AlwaysOnTop +ToolWindow -Caption +E0x20
- Gui Color, 000000
- Gui Dimmer:Show, NoActivate x%xPos% y%yPos% w%wWidth% h%wHeight%, Dimmer
- WinSet Transparent, 0, Dimmer
- Gui Hide
- ; #### Main Code ####
- tDim:
- ; Check for both mouse movement and keyboard activity
- If (A_TimeIdle > (vDur * 60000) || A_TimeSincePriorHotkey > (vDur * 1000)) && !fChk {
- MouseGetPos mX, mY
- BlockInput MouseMove
- MouseMove wWidth, wHeight, 0
- Gui Dimmer:Show, NoActivate
- WinSet AlwaysOnTop, On, Dimmer
- If fU {
- SetTimer tU, Off
- fU := 0
- }
- SetTimer tD, % dDly
- fD := 1, fChk := 1
- } Else If (A_TimeIdle < 200) && fChk {
- MouseMove mX, mY, 0
- BlockInput MouseMoveOff
- If fD {
- SetTimer tD, Off
- fD := 0
- }
- If !uDly {
- WinSet Transparent, % 255 - (vBrt := 255), Dimmer
- } Else {
- SetTimer tU, % uDly
- fU := 1
- }
- While fU {
- ; Allow other events to be processed during the delay
- Critical, Off
- Sleep, 10
- Critical, On
- }
- WinSet AlwaysOnTop, Off, Dimmer
- Gui Dimmer:Hide
- fChk := 0
- }
- Return
- ; ##### Timers ######
- tD:
- vBrt -= dRng
- If (vBrt <= vMin)
- vBrt := vMin
- WinSet Transparent, % 255 - vBrt, Dimmer
- If (vBrt = vMin) {
- SetTimer tD, Off
- fD := 0
- }
- Return
- tU:
- vBrt += uRng
- If (vBrt >= 255)
- vBrt := 255
- WinSet Transparent, % 255 - vBrt, Dimmer
- If (vBrt = 255) {
- SetTimer tU, Off
- fU := 0
- }
- Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement