Hello.
I have included a script that changes the input assignments of the selected track in the script I am creating.
//input assign to AT1
sf.ui.proTools.selectedTrack.groups.whoseTitle.is("Audio IO").first.popupButtons.whoseTitle.is("Audio input popup").first.popupMenuSelect({
menuPath: ["search..."],
});
This script is working fine in my environment.
However, in my friend's environment, this did not work, and
//input assign to AT1
sf.ui.proTools.mainWindow.groups.allItems[8].groups.whoseTitle.is("Audio IO").first.popupButtons.first.popupMenuSelect({
menuPath: ["search..."],
});
this works fine.
What is the difference between these two scripts?
And which is the more robust script?
Please teach me.
Thank you.
- Raphael Sepulveda @raphaelsepulveda2021-04-28 18:29:46.218Z
Hello Yujiro!
The following script should work on both your systems:
sf.ui.proTools.selectedTrack.groups.whoseTitle.is("Audio IO").first.popupButtons.first.popupMenuSelect({ menuPath: ["search..."], });
This is the script that works for you but without
whoseTitle.is("Audio input popup")
.In this case, it's not necessary to specify this information since the title of this popup button seems to have changed from one version of Pro Tools to another and can also vary depending on the current input.
Since we know it's the first popup button in the Audio IO group, we can address it by index and it will find the element every time.
This would be the most robust way to go about this since it's using SoundFlow's
selectedTrack
property, which knows what track is currently selected. In your second script, you used:sf.ui.proTools.mainWindow.groups.allItems[8]
which only addresses the second track on the edit window.Hope that helps!
Yujiro Yonetsu @Yujiro_Yonetsu
I see!
Does this mean that the robustness of the system is increased by not describing parts that do not need to be described?
This is very meaningful for future scripting. Thank you!Raphael Sepulveda @raphaelsepulveda2021-04-29 01:08:15.805Z
Yes, sort of. The UI Element picker can sometimes give you extra information that may not be required to address the UI Element. This was an example in which we could away with that. Other times we do need to keep the details in there. Experimenting with this will better inform you when and when not to do it!