This script will minimize any inactive windows after n seconds. The reason for this is that I have a lot of windows open normally, and just forget they are there. This allows for a much cleaner workspace.
Its working OK for me now and with the time settings currently in place, it takes about 1 minute for an app to become minimized when in the background.
Change the filter section to match your apps.
#Persistent DetectHiddenWindows, Off SetTimer, CheckIfActive, 1000 return CheckIfActive: WinGet, id, list, , , Program Manager Loop, %id% { StringTrimRight, this_id, id%a_index%, 0 WinGetTitle, title, ahk_id %this_id% WinGet, id_min, ID, ahk_id %this_id% WinGet, minim , MinMax, ahk_id %this_id% ;blank If title = continue ;filter If (title = "Desktop Coral" or title = "Serence Klipfolio") continue ; if minimized, restart on new app If minim = -1 continue ; if active task, reset counter to 0 IfWinActive, ahk_id %id_min% { wininactive%ID_min% = 0 continue } ; if counter is less than 60, add 1 or minimize and reset If wininactive%ID_min% < 60 { If wininactive%ID_min% = wininactive%ID_min% = 0 wininactive%ID_min% += 1 } Else { WinMinimize, ahk_id %id_min% wininactive%ID_min% = 0 } } return