March 2, 200718 yr I always end up with too many open windows and would like to write a script which would close all but the same two windows. I have been trying to use the window names returned by the windownames function as variable to do a loop which would close one window after the other except the two I want open. I can't figure out how to assign the result of the windownames function as a variable. The variable should then be assigned to the SelectWindow function. Thanks for any help yknot
March 2, 200718 yr Try this, it's a bit messy but... Allow User Abort[off] Set Error Capture[on] Freeze Window SetVariable[ $n ; 2 ] SetVariable[ $windows ; Substitute( ¶ & WindowNames & ¶ ; ["¶The Window You want kept open here¶" ; ¶ ] ; ["¶The Second Window You want kept open here¶" ; ¶]) ] Loop Exit Loop If[ $n > valueCount($windows) ] Select Window[ Name: GetValue( $windows ; $n ) ; CurrentFile ] If[ Get(LastError) = 0 ] Close Window End If SetVariable[ $n ; $n + 1 ] End Loop Edited March 2, 200718 yr by Guest
March 3, 200718 yr Author Tnx for the quick reply. Have not had a chance to write the script yet but would much appreciate a bit of explanation of this line: SetVariable[ $windows ; Substitute( ¶ & WindowNames & ¶ ; ["¶The Window You want kept open here¶" ; ¶ ] ; ["¶The Second Window You want kept open here¶" ; ¶]) ] yknot
March 3, 200718 yr SetVariable[ $windows ; Substitute( ¶ & WindowNames & ¶ ; ["¶The Window You want kept open here¶" ; ¶ ] ; ["¶The Second Window You want kept open here¶" ; ¶]) ] Your don't want to close two particular windows so we're eliminating them from the list of windows to close.
March 3, 200718 yr A bit different approach I've used, in a script: Loop Exit Loop If [ ValueCount ( WindowNames ( Get ( FileName ) ) ) = 1 ] Close Window [ Current Window ] End Loop Go to Layout [ “MyHome” ] Set Window Title [ Current Window; New Title: Get ( LayoutName ) ]
March 3, 200718 yr But that just closes every window except for one... And then sets it to a default location, i suppose it might be suitable but...
March 3, 200718 yr I find it easier to clean up after myself after each layout/window switch. If this isn't tracked, you can run into 1) record lock issues and 2) system running out of resources and freezing up. You can use the same windows ... just perform layout switches. You can even rename your windows to the other window you are replacing/closing, thus switching horses mid-stream. You can test if a window is open and just bring it to the front if so; as compared to always opening a new one. So the best defense is a good offense - consider tracking them to begin with. LaRetta
Create an account or sign in to comment