centering finder file copy progress window?

Hi,

Is this possible? I have a simple applescript that runs without a window and uses the finder to copy some files. The script begins … tell application finder … and it uses duplicate to copy the files. The progress bar window appears top left of the screen and I’d like it centered.

Thanks.

You can use this (be careful, though):

do shell script "defaults delete com.apple.finder CopyProgressWindowLocation" --> force prefs to re-write
do shell script "defaults write com.apple.finder CopyProgressWindowLocation '20,200'"

The {0,0} points are the upper left corner.

Thanks JJ,

To use this I see I’d need to check the screen res first to find the center point. I don’t know how to do that in AppleScript either so if this is the only way I think I’ll leave it as it is. I assume this changes the progress window default position for the whole system. I was hoping it would just be a matter of using a ‘center’ argument or command.

Cheers.

There are several methods to calculate the screen resolution:

--> METHOD 1
set prefs to read alias ((path to startup disk as text) & "Library:Preferences:com.apple.windowserver.plist")
set off1 to (offset of "<key>Width</key>
				<integer>" in prefs) + 30
set off2 to (offset of "</integer>
			</dict>
		</array>
	</array>
</dict>
</plist>
" in prefs) - 1
set width to text from character off1 of prefs to character off2 of prefs as number
set off1 to (offset of "<key>Height</key>
				<integer>" in prefs) + 31
set off2 to (offset of "</integer>
				<key>IODisplayLocation" in prefs) - 1
set height to text from character off1 of prefs to character off2 of prefs as number
{width, height}


--> METHOD 2
tell application "System Events"
	tell process "Finder"
		repeat with i from 1 to the count of windows
			if the position of window i is {0, 0} then
				return the size of window i
			end if
		end repeat
	end tell
end tell


--> METHOD 3
{word 3 of (do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep -w Width") as number, ¬
	word 3 of (do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep -w Height") as number}

You can also use Jon’s Commands (screen size of (screen list)'s item 1) and XTool.osax (screen resolution).
You can also manipulate the copy “window” itself, but you must enclose then the “duplicate” command in a “ignoring application responses” statement, so you can manipulate it while it exists :wink:

tell application "Finder"
	ignoring application responses
		duplicate alias "path:to:dir:"
	end ignoring
	delay 1 --> wait some moments
	set bounds of window "Copy" to {x1,y1,x2,y2} --> or "front window", assuming it will be the frontmost window
end tell