r/applescript • u/5-fingers • May 18 '22
Help me with this script please!
So I'm trying to create a bit of apple script that will execute a keyboard shortcut on a remote computer (over a network). The shortcut is shift+Cmd+n. The application is called Timax2
Ive got as far as the script shown in the image.
........ But when I run it I get the syntax error "Application isnt running"..... I know the obvious question is "is the application running on the remote computer?!" And, Yes it is.
The script works if I run it on locally with the app on the same machine the script is run from (removing the "of machine "eppc://10.0.0.33"" bit)
I know the networking connection is ok as I can run a script to "tell "finder" of machine "eppc://10.0.0.33" sleep"
So any suggestions?
View all comments
Show parent comment
1
u/estockly Jun 02 '22
That would fail because the process receiving the UI commands must be frontmost. I'm sure we agree on that point.
The correct format for a UI scripting command is:
tell application <target application name> to activate
tell application "System Events"
tell process <target application name>
<do ui stuff here>
end tell
end tell
end tell
If you omit the "tell process ..." then, yes, System Events will resolve it, but that will take longer and may require timeouts and may still cause the command to fail.