Trouble scripting the CS3 suite

G’day scripters

I’ve just got the CS3 suite and need to GUI script many of the Apps.

Starting with Photoshop, which now sports two Print windows, I tried to close the open window when finished printing.

However, everything I tried was to no avail.

I nned to close the window without a saving dialog box popping up, can anyone please advise me as to the correct context?

Regards

Santa


set pathToDesktopTemp to path to desktop
tell application "Finder"
	set TheName to "Untitled-3.psd"
	tell application "Adobe Photoshop CS3"
		try
			activate
			open file (pathToDesktopTemp & TheName as text) showing dialogs never
			delay 2
			tell application "System Events" to tell process "Adobe Photoshop CS3"
				keystroke "p" using command down
				tell window "Print"
					keystroke return
					keystroke return
				end tell
			end tell
			close document TheName saving no
			
		on error theError
			display dialog theError
		end try
	end tell
end tell

Model: G5 1.8 GHz
AppleScript: 2.1.1
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Hi Santa,

I don’t have CS3 (yet), but in general it’s more reliable to press buttons with GUI scripting
e.g. click button “OK” of window 1 instead of using keystroke return.
I would also play with short delays for all windows actions to have a solid status of the window

Thanks Stefan

The printing part works fine, it’s the close statement that’s giving me hassles.

Santa

Model: G5 1.8 GHz
AppleScript: 2.1.1
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

I’ve also tried this script to close the window.

The “‘w’ using command” works, but the click on “Don’t Save” in the resultant window does not. The button flashes, but the click doesn’t register.

I think there’s real problems with CS3.


set pathToDesktopTemp to path to desktop
tell application "Finder"
	set TheName to "Untitled-3.psd"
	tell application "Adobe Photoshop CS3"
		try
			activate
			open file (pathToDesktopTemp & TheName as text) showing dialogs never
			delay 2
			tell application "System Events" to tell process "Adobe Photoshop CS3"
				keystroke "p" using command down
				tell window "Print"
					keystroke return
					keystroke return
				end tell
				delay 4
				keystroke "w" using command down
				delay 1
				click button "Don't Save" of window "Adobe Photoshop"
			end tell
			
		on error theError
			display dialog theError
		end try
	end tell
end tell

Many don’t… buttons have a key equivalent cmd-d and some have cmd-n

Thanks once again Stefan, for coming to my rescue. :smiley:

Command-d worked fine.

For posterity, the script now works like this…


set pathToDesktopTemp to path to desktop
tell application "Finder"
	set TheName to "Untitled-3.psd"
	tell application "Adobe Photoshop CS3"
		try
			activate
			open file (pathToDesktopTemp & TheName as text) showing dialogs never
			delay 2
			tell application "System Events" to tell process "Adobe Photoshop CS3"
				keystroke "p" using command down
				tell window "Print"
					keystroke return
					keystroke return
				end tell
				delay 4
				keystroke "w" using command down
				delay 1
				keystroke "d" using command down
				
			end tell
			
		on error theError
			display dialog theError
		end try
	end tell
end tell