Page 1 of 1

Close a specific folder after inactivity?

Posted: 30 Apr 2024, 13:48
by wastingpenguins
I want Windows to automatically close a specific folder in File Explorer, either after only that folder experiences inactivity (preferred), or after a period of inactivity with the PC as a whole. I guess probably the folder would be closed based on its specific title. As a last resort, it would be okay if all File Explorer folders were closed after a period of inactivity.

Is this possible?

To explain: I want to make sure work folders are closed when not in use so that my kid doesn't accidentally (or intentionally) mess with them when he uses my PC.

Re: Close a specific folder after inactivity?

Posted: 30 Apr 2024, 16:47
by mikeyww
Hello,

You could set a timer to check :arrow: A_TimeIdlePhysical. When it exceeds a certain value, you can WinClose.

Re: Close a specific folder after inactivity?

Posted: 03 May 2024, 13:51
by wastingpenguins
mikeyww wrote:
30 Apr 2024, 16:47
Hello,

You could set a timer to check :arrow: A_TimeIdlePhysical. When it exceeds a certain value, you can WinClose.

Thank you, I'm having trouble getting it to work. Would anyone be able to help me with this script?

For example, close a folder called "Work" if inactive for 5 minutes.

Thank you.

Re: Close a specific folder after inactivity?

Posted: 03 May 2024, 14:06
by mikeyww

Code: Select all

#Requires AutoHotkey v1.1.33.11

dir           := "utils" ; Window title of File Explorer
closeAfterMin := 5

#Persistent
#InstallKeybdHook
#InstallMouseHook
Process Priority,, B
closeAfterMS  := 60000 * closeAfterMin
winTitle      := dir " ahk_class CabinetWClass"
SetTimer Check, 5000
Check:
ToolTip % A_TimeIdlePhysical
If WinExist(winTitle) && A_TimeIdlePhysical > closeAfterMS {
 WinClose
 SoundBeep 1500
}
Return