How to close folder? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Greast
Posts: 71
Joined: 24 Oct 2020, 19:01

How to close folder?

Post by Greast » 04 Oct 2022, 17:15

I want to close all folders that include this directory in it's link C:\Users\******\AppData\ ...
How can I do that? I tried to research and find solution, but I couldn't.
“You see things; you say, 'Why?' But I dream things that never were; and I say 'Why not?”
― George Bernard Shaw

User avatar
mikeyww
Posts: 26602
Joined: 09 Sep 2014, 18:38

Re: How to close folder?  Topic is solved

Post by mikeyww » 04 Oct 2022, 18:26

Hmm... I'm not sure what you mean. This closes windows but not folders. Folders don't really open or close; they are just there.

Code: Select all

WinGet, win, List, ahk_class CabinetWClass ahk_exe explorer.exe
Loop, %win% {
 hWnd := win%A_Index%
 For oWin in ComObjCreate("Shell.Application").Windows()
  If (oWin.HWND = hWnd && oWin.Document.Folder.Self.Path ~= "i)c:\\Users\\.+\\AppData\\")
   WinClose, ahk_id %hWnd%
}

Post Reply

Return to “Ask for Help (v1)”