Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Closing a simple explorer window after operations


  • Please log in to reply
6 replies to this topic
Michael2222
  • Members
  • 95 posts
  • Last active: Nov 09 2015 03:47 PM
  • Joined: 27 May 2009

This is hopefully a simple question, but I can't seem to get it.

 

I do a bunch of operations, and then an explorer window is still open for a simple folder. It's not a program window or anything else with a title in the window.

 

I just want to close it. "WinClose" does not seem to work, and there is the added problem that I want to make absolutely sure that I only close that window (I think it would be currently active after the other steps) and not another window that I happen to have open.

 

Thanks in advance for ideas - it sounds really simple, but I'm just not getting it.



girlgamer
  • Moderators
  • 3263 posts
  • Last active: Feb 01 2015 09:49 AM
  • Joined: 04 Jun 2010
While (WinExist("ahk_Class CabinetWClass"))
{  Winclose, ahk_class CabinetWClass
   Sleep 2000
}
msgbox,0x1000,,All explorer windows closed
exitapp


The universe is a wondrous place! The faster you create unbreakable code, the faster the universe creates people that can break it. All scripting follows the rule Rule Of Twos -- 1) Good, 2) Fast 3) Cheap -- pick any Two.
I guarantee absolutely nothing about any code I provide except that it works in my machine. ●
MMO Fighter   KeyLooperDemo   Key Spammer   TinyClickRecorder  GGs Password Generator.ahk
For the newest version of AutoHotkey and some killer scripts go here.
Rock-on%20kitten.gif


Michael2222
  • Members
  • 95 posts
  • Last active: Nov 09 2015 03:47 PM
  • Joined: 27 May 2009

Thanks for the help - it does close the window that was open.

 

Unfortunately, it closes all explorer windows, which I definitely don't want to do. I wanted to be careful that ONLY the window open from the transfer operations is closed so that I don't lose data in other explorer windows that happen to be open.

 

Your version gets closer, though, and maybe I can tweak it to do what I want.



bruno
  • Members
  • 635 posts
  • Last active: Nov 04 2015 02:26 PM
  • Joined: 07 Mar 2011

why selecting Sleep 2000 not 1000 or 3000? ;)



Jackie Sztuk _Blackholyman
  • Spam Officer
  • 3757 posts
  • Last active: Apr 03 2016 08:47 PM
  • Joined: 28 Feb 2012
Did you Try Winclose, A as this will close the active window
Helping%20you%20learn%20autohotkey.jpg?d

[AHK] Version. 1.1+ [CLOUD] DropBox ; Copy [WEBSITE] Blog ; About

Michael2222
  • Members
  • 95 posts
  • Last active: Nov 09 2015 03:47 PM
  • Joined: 27 May 2009

Did you Try Winclose, A as this will close the active window

 

That did the trick, thanks.



girlgamer
  • Moderators
  • 3263 posts
  • Last active: Feb 01 2015 09:49 AM
  • Joined: 04 Jun 2010

I chose 2000 so I could actually see the individual windows close  instead of closing a whole bunch of them very

fast. As you may notice the script comes with the caveat that I was using the ahk_class. In testing I opened a number

explorer windows to make sure the method worked correctly before posting. He wanted a winclose but never said

specifically what window. so this did the job on all of them. The actual window title can be sussed from the folder

that is open. That wasn't specified either. For this test I opened 5 Explorer windows to different folders and had

the routine check the windows titles. 

WinGet, vwinID, List, ahk_class CabinetWClass
MsgBox,0x1000,,there are %vWinID% windows of CabinetWClass open.
Loop, %vWinID%
{ x := vWinID%A_Index%
  WinGetTitle, wt, ahk_id %x%
  msgBox,0x1000,, index=%a_Index% of %vWinID%`nwt=%wt%
}
ExitApp

Using this method you gain the ability to close any one of the windows using it's Instance ID (ahk_id)

or by using it's title regardless if it is the active or topmost window in the list. This does not close the

windows, it simply identifies them for future operations.


The universe is a wondrous place! The faster you create unbreakable code, the faster the universe creates people that can break it. All scripting follows the rule Rule Of Twos -- 1) Good, 2) Fast 3) Cheap -- pick any Two.
I guarantee absolutely nothing about any code I provide except that it works in my machine. ●
MMO Fighter   KeyLooperDemo   Key Spammer   TinyClickRecorder  GGs Password Generator.ahk
For the newest version of AutoHotkey and some killer scripts go here.
Rock-on%20kitten.gif