Hello! thanks in advance for any help. When I run this script, i get this error:
error “System Events got an error: Can’t get button "Render" of window "Audio Suite: Reverse" of process "Pro Tools".” number -1728 from button “Render” of window “Audio Suite: Reverse” of process “Pro Tools”
here’s the script:
tell application “System Events”
tell process “Pro Tools”
set frontmost to true
if exists (window “AudioSuite: Reverse”) then
click button “Render” of window “Audio Suite: Reverse”
else
click menu item “Reverse” of menu of menu item “Other” of menu “AudioSuite” of menu bar 1
click button “Render” of window “Audio Suite: Reverse”
end if
end tell
end tell
This could be similar to the issue I just had trying to mess with a text field of one of Audacity’s windows here:
https://macscripter.net/viewtopic.php?id=46993
Basically, the design of the software itself has to support the automation protocol of AppleScript natively in order to automate it through AppleScript. However there are work arounds as you will see with my issue. Just by putting in a
tell application "Script Editor" to activate
tell application "Logic Pro" to activate
Helped get access to the text field for me in Audacity.
In order to debug certain things you can do
return every UI element
while within the scope of that UI element and it will show you all the names of the things you can access with AppleScript.
Hi. Welcome to MacScripter.
There are two main problems when resorting to GUI Scripting, both of which stem from the fact that you’re not scripting the target application itself, but scripting System Events to send messages into the application’s user interface.
Firstly, you have to know exactly where in a window’s or menu’s internal structure the element you want to address occurs. This may vary from situation to situation, user preference to user preference, application version to application version, or system version to system version. However, once you’ve located it, you’re usually OK for a while.
Secondly, the script only gets direct feedback about its commands to System Events. So System Events might acknowledge that it’s carried out a ‘click’ command and the script will move on. But the application receiving the click will often need more time to respond to it (it may have to draw a whole new window) before it’s ready for the script’s next action. Since it doesn’t report back directly to the script, the only way the script can find out when it’s ready is to keep telling System Events to check for an expected change in the application’s GUI structure.
Your error message suggests that the “Render” button either doesn’t exist (unlikely!) or that it’s located somewhere deeper in the window’s internal structure. Whenever I need to write a GUI script, I use a version of the script here to find out the GUI-Scriptable structure of the window and/or menu bar involved. It can take a few seconds to complete if there are a lot of data, but it eventually opens a window in TextEdit with the structure laid out as a tabbed list. Hope it’s of some help.
Thanks guys. The interesting thing is when I run the script, it definitely starts to work. Locates the window, and tries to access the button. I agree it could be quirks in the OS version and the software version.
It’s frustrating in that I basically copied this script of another tutorial site, and the comments are populated with users saying it works great. Unfortunately I have not been able to get a response to questions in that site.
I will attempt to try some of these suggested ideas and report back if they help.
thanks!
For see, I downloaded Pro Tools First.
Your script behaved flawlessly when I changed the name of the process:
tell application "System Events"
tell process "Pro Tools First" # EDITED
set frontmost to true
if exists (window "AudioSuite: Reverse") then
click button "Render" of window "Audio Suite: Reverse"
else
click menu item "Reverse" of menu of menu item "Other" of menu "AudioSuite" of menu bar 1
click button "Render" of window "Audio Suite: Reverse"
end if
end tell
end tell
The events log was :
tell application "System Events"
set frontmost of process "Pro Tools First" to true
exists window "AudioSuite: Reverse" of process "Pro Tools First"
--> false
click menu item "Reverse" of menu of menu item "Other" of menu "AudioSuite" of menu bar 1 of process "Pro Tools First"
--> {menu item "Reverse" of menu "Other" of menu item "Other" of menu "AudioSuite" of menu bar item "AudioSuite" of menu bar 1 of application process "Pro Tools First"}
click button "Render" of window "Audio Suite: Reverse" of process "Pro Tools First"
--> button "Render" of window "Audio Suite: Reverse" of application process "Pro Tools First"
end tell
Résultat :
button "Render" of window "Audio Suite: Reverse" of application process "Pro Tools First" of application "System Events"
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) dimanche 28 juillet 2019 17:32:26
wow I will check this out.
This morning, I installed the macros in KeybaordMaestro, and installed third party applescripts.
Now, I am able to successfully run the scripts vie the KM editor. If I hit “try” in KM, while the reverse macro is selected, protools faithfully launches audio suite reverse, processes selected audio and then closes the reverse window.
However, now I find i cannot get any hot key to trigger the script. When i use the hotkey, it seems like it tries to access the audiosuite menu, but then i hear a system beep like an invalid instruction was met.
Then if i re-trigger the macro from within KeyboardMaestro editor, it works perfectly, followed by several system pop ups…
System events got an error: Can’t get window “Audio suite: Reverse” of application “Pro Tools” -1728
So my limited understanding tells me the macros and scripts are fine, but for some reason, accessing via a hot key trigger in Keyboard Maestro changes the way the script is executed in relation to protools gui. Very weird issue.
I am on osx 10.10.3 running protools 11.3. I really can’t upgrade my system at this time because PT11 isn’t compatible with higher systems of OSX.
any insight on this would be quite helpful.
thanks,
John
I don’t know Keyboard Maestro.
Maybe you must add an instruction activating Pro Tools at the very beginning of your script.
tell application "Pro Tools First" to activate # ADDED
-- the original code
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) dimanche 28 juillet 2019 18:23:20
This is the same problem as with my issue that I posted originally.
If you try to do
tell application "Some Other Application" to activate
tell application "Your Application Name" to activate
Then it should see the UI elements of the window in question. Check this conversation for context:
https://macscripter.net/viewtopic.php?pid=196757#p196757
I had the same issue where if I ran the script twice then it would work. So I did the above code after I had brought up the window and it executed the following code on the window correctly.
tell application "System Events"
tell process "Pro Tools First" # EDITED
set frontmost to true
--its never going to see that the window exists; its always running the else
if exists (window "AudioSuite: Reverse") then
tell application "Safari" to activate
tell application "Pro Tools First" to activate
click button "Render" of window "Audio Suite: Reverse"
else
click menu item "Reverse" of menu of menu item "Other" of menu "AudioSuite" of menu bar 1
tell application "Safari" to activate
tell application "Pro Tools First" to activate
click button "Render" of window "Audio Suite: Reverse"
end if
end tell
end tell
This is probably all that you need to do to get it to work
tell application "System Events"
tell process "Pro Tools First"
--get the window up
click menu item "Reverse" of menu of menu item "Other" of menu "AudioSuite" of menu bar 1
end tell
end tell
--reset the windows
tell application "Safari" to activate
tell application "Pro Tools First" to activate
tell application "System Events"
tell process "Pro Tools First"
--do the action
click button "Render" of window "Audio Suite: Reverse"
end tell
end tell