I suffer from a strange thing. As I run the following script:
tell application “System Events”
tell process “Adobe Photoshop CS4”
click button “Cancel” of window “New”
end tell
end tell
I seet that it effects the button to be clicked but nothing happens and the dialog remains on. With some dialogs the script works fine (like Open dialog, which maybe a system dialog not Photoshop). Does not matter if I run it from AppleScript Editor or as an app. Is it maybe an OS bug? I have 10.6.8.
Enabling is chekced in universal access. Thanks if somebody has any idea.
Model: Mac Pro
AppleScript: 2.1.2
Browser: Firefox 24.0
Operating System: Mac OS X (10.6)
I think some buttons might use some other command like press. Try looking in the System Events library. Also, you can use Accessability Inspector from Xcode. When you move the cursor to the button, the info shows up in the window. It shows what commands you can use to make to do an action.
It might be better to do the commands in the script though. I’m not too good at that.
tell application "System Events"
tell process "Adobe Photoshop CS4"
set cancelPosition to position of button "Cancel" of window "New"
end tell
end tell
tell application "ASObjC Runner" to click button at cancelPosition
KOENIG Yvan (VALLAURIS, France) vendredi 20 septembre 2013 18:39:18
@Kel: I tried the perform action way, but same result… @Yvan: I downloaded the ASObjC Runner and tried the code, but not working. I modified a bit to be sure it clicks on the button, but still not working
tell application "System Events"
tell process "Adobe Photoshop CS4"
set cancelPosition to position of button "Cancel" of window "New"
set the first item of cancelPosition to (the first item of cancelPosition) + 10
set the second item of cancelPosition to (the second item of cancelPosition) + 10
end tell
end tell
tell application "ASObjC Runner" to click button at cancelPosition
The pointer goes there, but does not perform the click.
The “standard” shortcut for “Cancel” has always been Command-. while I’ve been a Mac user, hence my suggestion in post #5. I see though that pressing the Escape key also works, although Yvan’s script doesn’t on my machine. The Escape key’s better emulated with a ‘key code’ command:
tell application "System Events"
set frontmost of application process "Adobe Photoshop CS4" to true
key code 53
end tell
Thanks for the Cancel examples. Actually… I’d like to write a longer script for handling channels like:
Select a spot channel and set its fill color for a Pantone color. In Photoshop scripting reference there is no paramter for Pantone colorization of channels (the possible way is the CMYK, HSB, RGB colorization) but I need the Pantone.
That’s why I have choosen the GUI way to reach the above “Color Libraries” dialog. But it seems that there is problem on almost every CS4 dialog while GUI scripting. (This Cancel stuff was an example only.)
I have just tested on CS6 and everything works fine. But it seems there is a general problem with “click” in CS4 (unfortunatelly I have CS4 only at my workplace).