Mounting Volumes, and then positioning windows in specific x/y spots

What’s up?

Thanks for all your help in the past. I was wondering if it was possible in OSX to script this:
Mount certain server volumes, and within those volumes, open certain folders (via prompt dialog), and then as you select the folder locations, that window is sized to a specific bounding area, as well as placed in a certain location on screen.

Thanks in advance.

For mounting server volumes, just do a search…it’s been covered many times before. And a hint for positioning Finder windows“ Hit “Record” in your script editor and drag/resize some windows.

-N

Cool, it mostly worked. But is there a way to make the finder window the “smaller” one? The one you get when you click the little rounded rectangle in the top right hand corner of the window?

Sorry, but the “search forums” thing really worked, and I found my answer to that question as well.

I continue to get this error

This is my current Script:

mount volume "afp://serverlocation" as user name "username"
tell application "Finder"
	activate
	
	make new Finder window to folder (choose folder with prompt "Choose Share Folder") of disk "Share"
	set toolbar visible of Finder windows to false
	set current view of Finder window 1 to list view
	set bounds of Finder window 1 to {330, 170, 575, 561}
	set position of Finder window 1 to {978, 557}
end tell


Of course the “server location” and “username” are filled in w/ correct info before running.

Know why I’m getting this error?

After working with this script, I now get no error. BUT now the folder window isn’t being resized/repositioned to the correct location. I record myself making the folder, and resizing it, and repositioning it. Then I copy/paste those x-y and w-h numbers into my script in order to make sure the positioning would be right. But when I run the script, it doesn’t put the new window in the right spot. Also, it’s not even opening the right folder! What am I doing wrong? Here’s my revised script:

mount volume "afp://serverlocation" as user name "username"
tell application "Finder"
	activate
	make new Finder window of (choose folder)
	set toolbar visible of Finder windows to false
	set current view of Finder window 1 to list view
	set bounds of Finder window 1 to {852, 507, 1109, 909}
	set position of Finder window 1 to {967, 543}
	
	
end tell


I have reworked the script to read as the following. However, I can never get my folders to be placed in the correct position. In fact, they are never really placed in the same location twice. Can someone help me? I attempted this script with folders on my desktop (thinking the server was messing with positioning) but that didn’t work either. Also, I’ve ran the ‘bounds of every window’ script I found in this forum, and copied the x1, x2, y1, y2 coords directly from the results window.

Thanks, here’s the script:

mount volume "afp://server/name" as user name "user"




tell application "Finder"
	activate
	
	set wamNetFolderPath to (choose folder with prompt "Select Wam!Net folder") --folder 1
	set wamNetStagingFolderPath to (choose folder with prompt "Select Wam!Net Staging folder") --folder 2
	set flightCheckedFolderPath to (choose folder with prompt "Select FlightChecked folder") --folder 3
	set tabProjectsFolderPath to (choose folder with prompt "Select TabProjects folder") --folder 4
	set oldDocsFolderPath to (choose folder with prompt "Select OldDocs folder") --folder 5
	set pdfRegionalAdFolderPath to (choose folder with prompt "Select PDFs on Reg.Ad") --folder 6
	set pdfGraphArchFolderPath to (choose folder with prompt "Select PDFs on GraphArch") --folder 7
	set pdfHardDriveFolderPath to folder "_PDFs_HD" of folder "Documents" of folder "user" of folder "Users" of startup disk --folder 8
	
	set toolbar visible of Finder windows to false
	
	--folder 1
	open wamNetFolderPath
	set toolbar visible of Finder windows to false
	set current view of Finder window 1 to list view
	set bounds of Finder window 1 to {0, 44, 224, 427}
	
	--folder 2
	open wamNetStagingFolderPath
	set toolbar visible of Finder windows to false
	set current view of Finder window 2 to list view
	set bounds of Finder window 2 to {225, 44, 540, 427}
	
	--folder 3
	open flightCheckedFolderPath
	set toolbar visible of Finder windows to false
	set current view of Finder window 3 to list view
	set bounds of Finder window 3 to {543, 44, 858, 427}
	
	--folder 4
	open tabProjectsFolderPath
	set toolbar visible of Finder windows to false
	set current view of Finder window 4 to list view
	set bounds of Finder window 4 to {861, 44, 1228, 427}
	
	--folder 5
	open oldDocsFolderPath
	set toolbar visible of Finder windows to false
	set current view of Finder window 5 to list view
	set bounds of Finder window 5 to {862, 451, 1228, 567}
	
	--folder 6
	open pdfRegionalAdFolderPath
	set toolbar visible of Finder windows to false
	set current view of Finder window 6 to list view
	set bounds of Finder window 6 to {225, 451, 539, 956}
	
	--folder 7
	open pdfGraphArchFolderPath
	set toolbar visible of Finder windows to false
	set current view of Finder window 7 to list view
	set bounds of Finder window 7 to {543, 451, 857, 956}
	
	--folder 8
	open pdfHardDriveFolderPath
	set toolbar visible of Finder windows to false
	set current view of Finder window 8 to list view
	set bounds of Finder window 8 to {862, 599, 1231, 955}
	
	
end tell



does anyone know why finder windows will not position themselves to the screen position I specify (via coords)?

Hi,

When you open a folder it becomes window 1. The index shows the front to back ordering. A constant way to reference windows is to use the window id.

set f to choose folder
tell application “Finder”
activate
open f
set window_ref to container window of f
set bounds of window_ref to {0, 44, 512, 384}
end tell

I’m not sure if this would work on your system, but you can try it if you like.

gl,

For something this repetitive, use a repeat loop:

mount volume "afp://server/name" as user name "user"
tell application "Finder"
	activate
	set all_prompts to {"Wam!Net folder", "Wam!Net Staging folder", "FlightChecked folder", "TabProjects folder", "OldDocs folder", "PDFs on Reg.Ad", "PDFs on GraphArch", "_PDFs_HD:"}
	set all_bounds to {{225, 44, 540, 427}, {543, 44, 858, 427}, {861, 44, 1228, 427}, {862, 451, 1228, 567}, {225, 451, 539, 956}, {543, 451, 857, 956}, {862, 599, 1231, 955}}
	set prompt_count to (count all_prompts)
	repeat with i from 1 to prompt_count
		if i < prompt_count then
			set this_folder to (choose folder with prompt ("Select " & (item i of all_prompts)))
		else
			set this_folder to (((path to documents folder) as Unicode text) & (item i of all_prompts)) as alias
		end if
		tell (make new Finder window to this_folder)
			set toolbar visible to false
			set current view to list view
			set bounds to (item i of all_bounds)
		end tell
	end repeat
end tell

Jon

PS If you’re using Mac OS X 10.3 or earlier, take a look at Finder Window Manager which allows you to precisely position windows, save and restore window sets, and more. Note: The current version of Finder Window Manager (v1.9.4) is not Mac OS X 10.4 (Tiger) compatible. While I am currently working on an update, I’ve hit some Finder-related bugs in the new OS and it may be a some time before I can release a fully-compatible Mac OS X 10.4 version.

that is exactly what I was trying to do. Thanks a lot!!! Can you explain a little about what is happening with the script? Also, if all you did was organize my previous script into a loop, why does yours actually place the folders in the correct position, while mine did not? I really appreciate the help.