Script suggestion - Inactive window Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Nuramz

Script suggestion - Inactive window  Topic is solved

21 Apr 2017, 07:24

I am looking for a code that can help to close inactive windows. My system gets too slow when lot of windows stay open. So thinking of a script that can close inactive windows based on time it remained inactive. A newbie, so need help.

Thanks,
Rohwedder
Posts: 7626
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Script suggestion - Inactive window

22 Apr 2017, 02:08

Hallo,
the script must be started before the windows.

Code: Select all

#Persistent
GroupAdd, DoNotCloseThisWindows, ahk_class Progman
GroupAdd, DoNotCloseThisWindows, ahk_class Shell_TrayWnd
LiveTime = 60000 ;Live Time in ms
TestInterval = 2000
Nr = 1
NrMax := 10 + LiveTime//TestInterval ;10 = tolerance
SetTimer, Testing, %TestInterval%
Return
Testing:
	WinGet, AktivID, ID, A
	IFWinNotActive, ahk_group DoNotCloseThisWindows
	{
		ID%Nr% := AktivID
		LastActiveTime%AktivID% := A_TickCount
	}
	Else
		ID%Nr% =
	Nr := (Nr=NrMax)? 1:Nr+1
	CloseID := ID%Nr%
	IF !CloseID
		Return
	If (CloseID <> ClosedId)
		If (LastActiveTime%CloseID% <= (A_TickCount - LiveTime))
		{
			WinClose, ahk_ID %CloseID%
			ClosedId := CloseId
		}
	Else ;the Window does not want to be closed!
		WinActivate, ahk_ID %ClosedID%
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, Lamron750 and 260 guests