Tandem-like script

I have a question about Apple’s Tandem script that opens two Finder windows side-by-side. This is exactly the functionality that I want, but I find it annoying and distracting that the Finder windows open in the default size and position and only then move to the specified size and position. What I would like is for the new Finder window to open in the first place with the specified bounds.

Is this possible?

I tried changing this:

set this_window to make new Finder window
set the bounds of this_window to {left, top, right, bottom}

to:

set this_window to make new Finder window with properties {bounds:{left, top, right, bottom}}

but this doesn’t work. Finder ignores the bounds and opens the window with the default bounds.

Thanks for any help,
John

Assuming that Folder “A” exists on your desktop, and Folder “B” is inside of Folder “A”. This should work…

You’ll have to adjust the coordinates to place the windows where you want them. An easy way to do this is to “get the properties” of an open window, like this…

http://scriptbuilders.net

[This script was automatically tagged for color coded syntax by Script to Markup Code]

hth.

That works, but it doesn’t fix the problem of having the window appear and be visible before the correct dimensions are set (in other words, I see the window appear with the default bounds and then get redrawn with the new bounds).

Normally, I think, the way around this is to use “with properties” when you make the new window instead of making the window and then specifying the bounds. But this doesn’t seem to work with Finder.

What I want is for the windows to open cleanly with the specified bounds and not to have to watch it draw the windows and then redraw them with new bounds.

Do you see what I mean?

John

I see, try something like this…

http://scriptbuilders.net

[This script was automatically tagged for color coded syntax by Script to Markup Code]

This is one case where the recordable Finder was able to help me ;¬)

Here is what is strange. First run the script you suggest:

tell application “Finder”
make new folder with properties {name:“A”}
make new Finder window to folder “A” with properties {bounds:{40, 120, 425, 425}}
end tell

This makes a new folder “A” and sets its default window bounds.

Now close that window and try running this script:

tell application “Finder”
make new Finder window to folder “A” with properties {bounds:{200, 120, 425, 425}}
end tell

What happens now (for me, at least) is that Finder opens a new window to A, but uses the default bounds (40, 120, 425, 425) and not the specified bounds (200, 120, 425, 425). For some reason, Finder is ignoring the “with properties” clause if the folder already exists.

Strange, no? Or probably I am missing something.

John

I’m getting strange results also. – I’m in Panther. ;¬(

From my experience with Finder Window Manager</cheap plug>, I’ve found the way to do what you want is to reference the “container window”, not the “Finder window”:

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Interesting (and a useful cheap plug: FWM looks very cool).

But this slight modification to your script. First, I think the close Finder window 1 is redundant. In my case, anyway, when I open a folder in this way that is already open I do not get a new window, the current window moves (raising the question of how to open two windows in this manner if both point to the same folder). But anyway, here is a slight modification:


tell application "Finder"
	activate
	set the_folder to make new folder with properties {name:"A"}
	set {x1, x2, y1, y2} to {0, 44, 400, 100}
	repeat 5 times
		set bounds of container window of the_folder to {x1, x2, y1, y2}
		open the_folder
		delay 1
		--close Finder window 1
		set {x1, x2, y1, y2} to {(x1 + 100), (x2 + 100), (y1 + 200), (y2 + 200)}
	end repeat
	delete the_folder
end tell

If you run this script once, it works fine. But run it a second or third time and (at least for me, running 10.3) there is a funny glitch. The second time the script runs, the y2 variable will be ignored in the first iteration through the loop. In other words, the first time through the script you get what you expect: a small window gradually gettting bigger. But subsequent times, you get a tall window first which then gets small second and then gradually bigger.

Strange, eh?

Even stranger: try it without commenting out the close Finder window 1 line. Then it ignores the y2 bound altogether and always uses the same default height as it goes through the repeat loop.

What it means for me is that trying to set the window size this way doesn’t work reliably because sometimes Finder seems to ignore the the “y2” bound and uses the folder’s (previous) default height instead.

Any ideas?

John