How to write the code correctly?
I run the application Photoshop in the automator
I’m waiting for it to fully load
Then I press 10 times Tab and press Enter.
I’ve tried that:
Looks like that part doesn’t work. Because Tab starts to click before the application is fully loaded. What’s wrong? Thanks!
repeat until application launch
delay 0.5 end repeat delay 0.5
3
Answers
This is the answer:
I don’t know much about Photoshop, but I know that it has a loading screen. I tried the following code in Affinity Photo which is a similar product to Photoshop.
The
repeat until theBool
checks if the loading screen is over by checking if some menu item exists which isn’t available when the loading screen is open. If the"Close"
and the"File"
don’t work in Photoshop, you may choose something else.Most likely, the OP does not understand the main thing: GUI scripting (in this case, sending 10 tabs, and then Enter, that is, keystroke tab and keystroke return in AppleScript language) only works with the frontmost window. And the launch command launches an application without bringing its window to the front.
The correct approach is 1) use the activate application "Photoshop" command 2) use the make new document command, 3) check if the new window exists, 4) send keystroke commands. In the Automator, the Run AppleScript action should be something like this:
NOTE: not tested, because PhotoShop.app is not installed on my Mac. I am ready to correct my script, if needed. In general, the question is not quite clear.