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)
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
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
Thanks once again Stefan, for coming to my rescue.
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