Photoshop Zoom Control

Hi everyone,

I am trying to control zoom level in Photoshop CS5.

It’s not directly scriptable, but I’m really close to doing it through GUI scripting. I can insert my desired zoom level (right now it’s 100%, but that will vary later) into the zoom level box below the photo, and then…

I need to be able to press enter in order for Photoshop to actually read and use the value. I’ve tried using “keystroke return” and “keycode 36”, but I might not be using it in the right place. Anyone have any ideas?

Here’s what I have so far:

tell application "Adobe Photoshop CS5"
	set docName to name of current document
end tell

tell application "System Events"
	set windowList to name of every window of application process "Adobe Photoshop CS5"
	set i to 1
	set listLength to count of windowList
	repeat until i = 0
		if text item i of windowList contains docName then
			set docWindow to text item i of windowList as string
			set i to 0
		else if i = listLength then
			set i to 0
		else
			set i to i + 1
		end if
	end repeat
	set zoomBox to text field 1 of window docWindow of application process "Adobe Photoshop CS5"
	set value of zoomBox to "100%"
	
end tell

Thanks so much. Love MacScripter.
Alex

How about replacing:

set zoomBox to text field 1 of window docWindow of application process "Adobe Photoshop CS5"
	set value of zoomBox to "100%"

with

	tell application "Adobe Photoshop CS5" to activate
	keystroke "1" using command down

That works for me. Or you could just put “activate” after the first tell statement. I’ve found that having the program in the front is a must for GUI scripting.

Browser: Safari 533.19.4
Operating System: Mac OS X (10.6)

Thanks divster!
That is a much more elegant solution…

Model: iMac
AppleScript: 2.1.2
Browser: Firefox 6.0
Operating System: Mac OS X (10.6)