Scripts Fails to Open Track Rename Window
Title
Scripts Fails to Open Track Rename Window
What do you expect to happen when you run the script/macro?
This macro opens the track rename window, then copies the track name to comments.
Are you seeing an error?
it is, all of a sudden, failing to open the track rename window. it was working earlier tonight...
@Error invoking soundflow.runCommand (COPY TRACK NAME TO COMMENTS: Line 5)
@Error running command package:cksm7ejw1000tw610pz5q280d ( COPY TRACK NAME TO COMMENTS, OPEN TRACK RENAME WINDOW: Line 11)
SoundFlow.Shortcuts.AXUIElementException: Couldn't get count of attribute 'AXChildren' of element with title '', role '': kAXErrorInvalidUIElement
What happens when you run this script?
it falis to open the track rename window and the script stops. it was working earlier and i changed nothing in my system.
How were you running this script?
I used a Stream Deck button
How important is this issue to you?
4
Details
{ "inputExpected": "This macro opens the track rename window, then copies the track name to comments. ", "inputIsError": true, "inputError": "it is, all of a sudden, failing to open the track rename window. it was working earlier tonight...\n\n@Error invoking soundflow.runCommand (COPY TRACK NAME TO COMMENTS: Line 5)\n @Error running command package:cksm7ejw1000tw610pz5q280d ( COPY TRACK NAME TO COMMENTS, OPEN TRACK RENAME WINDOW: Line 11)\n SoundFlow.Shortcuts.AXUIElementException: Couldn't get count of attribute 'AXChildren' of element with title '', role '': kAXErrorInvalidUIElement", "inputWhatHappens": "it falis to open the track rename window and the script stops. it was working earlier and i changed nothing in my system.", "inputHowRun": { "key": "-MpfwmPg-2Sb-HxHQAff", "title": "I used a Stream Deck button" }, "inputImportance": 4, "inputTitle": "Scripts Fails to Open Track Rename Window" }
Source
//Macro converted to script
//Calling command "ACTIVATE PRO TOOLS MAIN WINDOW SCRIPT" from package "HOCC PT COMMANDS"
sf.soundflow.runCommand({
commandId: 'package:cksdph4og000cqm1073fh0ilu',
props: {}
});
//Calling command "MIX / EDIT WINDOW SWITCH SCRIPT PT 1" from package "HOCC PT COMMANDS"
sf.soundflow.runCommand({
commandId: 'package:ckz287qax000ojn100cps3ncf',
props: {}
});
//Calling command "OPEN TRACK RENAME ON SELECTED" from package "HOCC PT COMMANDS"
sf.soundflow.runCommand({
commandId: 'package:cksm7ejw1000tw610pz5q280d',
props: {}
});
//Calling command "Select All" from package "undefined" (installed from user/pkg/version "srAasovvDiQacRZ2mcId4RrOA8R2/ckp49i4j60000a2100yfwywgf/cl7ifcvv10000cz108r31chrd")
sf.soundflow.runCommand({
commandId: 'user:ckp49i4j60000a2100yfwywgf:ckt90h5f100008a10ilhfochy#ckt4xvj5o000u3n10h2dz6gle',
props: {}
});
//Calling command "Copy" from package "undefined" (installed from user/pkg/version "srAasovvDiQacRZ2mcId4RrOA8R2/ckp49i4j60000a2100yfwywgf/cl7ifcvv10000cz108r31chrd")
sf.soundflow.runCommand({
commandId: 'user:ckp49i4j60000a2100yfwywgf:ckt90h5f100008a10ilhfochy#ckt4xiomm00083n10ynrq3wsf',
props: {}
});
sf.keyboard.press({
keys: "tab",
});
//Calling command "Paste" from package "undefined" (installed from user/pkg/version "srAasovvDiQacRZ2mcId4RrOA8R2/ckp49i4j60000a2100yfwywgf/cl7ifcvv10000cz108r31chrd")
sf.soundflow.runCommand({
commandId: 'user:ckp49i4j60000a2100yfwywgf:ckt90h5f100008a10ilhfochy#ckt4xiy5700093n10q9mqlgiv',
props: {}
});
//Calling command "PRESS RETURN" from package "HOCC PT COMMANDS"
sf.soundflow.runCommand({
commandId: 'package:cl2t3uu2b0004nk10cvbschfs',
props: {}
});
//Calling command "MIX / EDIT WINDOW SWITCH SCRIPT PT 2" from package "HOCC PT COMMANDS"
sf.soundflow.runCommand({
commandId: 'package:ckz288ebn000pjn10oezm6xbo',
props: {}
});
Links
User UID: yesbmwLVy0dRQLFNZzxo8kQx4ri2
Feedback Key: sffeedback:yesbmwLVy0dRQLFNZzxo8kQx4ri2:-NFC-RXTfCEs0Gydhb9n
- Ben Rubin @Ben_Rubin
At other times, this script will fail to move to the next track in the Track Rename window via Command-Return or Command-Right-Arrow. The key command works fine when I do it manually but it fails during the script. And it's not every time, frustratingly intermittent.
Chris Shaw @Chris_Shaw2022-10-25 19:07:30.891Z2022-10-25 23:32:03.621Z
Hey Ben,
Without seeing all of the code in the referenced commands it won't be possible to see where things are going wrong.The good news is @samuel_henriques wrote an excellent and blindingly fast script that will copy the track names of all selected tracks to the comments field. I use it constantly.
It also will clear the comments on selected tracks if you have the alt/option key held down.
(If you're using a keyboard trigger you'll need to assign two triggers this script to get the alt function - one without the alt key and one with.)function setComments(hasAlt) { sf.ui.proTools.appActivateMainWindow() sf.ui.proTools.invalidate() //Get selected Tracks const selectedTracks = sf.ui.proTools.selectedTrackHeaders //Scrool to view first track selectedTracks[0].trackScrollToView() // Open rename window selectedTracks[0].popupButtons.first.mouseClickElement({ clickCount: 2 }) // Wait for rename window sf.ui.proTools.windows.whoseTitle.is(selectedTracks[0].popupButtons.first.value.invalidate().value).first.elementWaitFor(); //Get the elements of text fields and buttons const [trackName, comments] = sf.ui.proTools.focusedWindow.invalidate().textFields.map(x => x) const [ok, cncl, pr, next] = sf.ui.proTools.focusedWindow.buttons.map(x => x) // Loop all tracks for (let i = 0; i < selectedTracks.length; i++) { if (hasAlt) { // Clear comments comments.elementSetTextFieldWithAreaValue({ value: '', }); } else { // Set track name in Cmments while (true) { if (trackName.value.invalidate().value != comments.value.invalidate().value) { comments.elementSetTextFieldWithAreaValue({ value: trackName.value.invalidate().value, }); sf.wait({ intervalMs: 5 }) } else { break; } }; }; // If its the last track press ok, else press next if (i === selectedTracks.length - 1) { ok.elementClick() } else { next.elementClick() }; }; }; const hasAlt = event.keyboardState.hasAlt setComments(hasAlt)
Chris Shaw @Chris_Shaw2022-10-25 19:17:28.447Z
Generally speaking, avoid using keyboard presses in your scripts - they're not as reliable as using SF to press UI elements (buttons etc). In this particular case it's best to use the Click UI Element action to click the "Next" button in the track rename window instead of cmd-return or command down.
- In reply toChris_Shaw⬆:
Ben Rubin @Ben_Rubin
Finally tried this script, wow!!! Thanks @Chris_Shaw and @samuel_henriques!!! Insanely fast!
Ben Rubin @Ben_Rubin
@samuel_henriques there are some situations where I want to copy the track name but keep what's in the comments and append the track name BEFORE what's already there. Can you recommend how to accomplish this?
thx
bsamuel henriques @samuel_henriques
Hello Ben,
Just posted on the original thread.
Copy track name and paste to PT scribble strip...
- In reply toBen_Rubin⬆:
Ryan DeRemer @Ryan_DeRemer
Hi Ben,
One thing I can see here (which speaks to the reliability of the script) is that you are using quite a few keyboard simulations here. That will generally be less reliable than using UI automation, which is what SoundFlow is focused on doing. It is encouraged that you avoid using keyboard/mouse simulation wherever possible. For example, tabbing to the next text field should be dropped in favor of the "Set Value of Text Field with Text Area" action. Copy/Paste actions should be handled using the "Menu Click" action rather than Cmd+C, etc. Moving between tracks in the Rename dialog should use the "Click UI Element" on the "Previous" or "Next" buttons, rather than using Cmd+Right.
It seems to be failing to open the Rename dialog. There is a known bug with Pro Tools 2022.9 where popup menus accessed at the bottom of the window (where you get the down arrow to scroll through the menu) will produce a weird UI bug. It does seem to affect SoundFlow's ability to read the menu items properly. This is a Pro Tools 2022.9 flaw, not a flaw in SoundFlow. This is the macro version of the workaround I've been using. You can insert this before the "OPEN TRACK RENAME ON SELECTED" command. This will scroll the track to the top of the window and allow the popup menu to function properly.
More fundamentally, the command you're using to open the Rename dialog in the first place doesn't open the rename dialog that allows for moving between tracks (if you right click the track and select "Rename...", you'll see there are no options for "Previous" or "Next"). That is likely causing instability as well. The Rename dialog you're looking for is the one you open by double-clicking the the track header, which can be accomplished using the "Mouse Click" action.
Hope this helps!
- In reply toBen_Rubin⬆:Ben Rubin @Ben_Rubin
@Chris_Shaw and @Ryan_DeRemer, thanks for your help and advice with this. Excellent improvements to be made to my scripts.
However, I posted this script so someone could take a look at the logs for me. While clunky, at times the script would work just fine and sometimes fail. I think that something is wrong with my system when Pro Tools is not in focus when it should be. happens with other scripts as well. That's why sometimes I'm getting weird UI errors and even sometimes Soundflow tells me it can't find Pro Tools! Weird stuff fails in the background as well. It's all in the logs I'm sure.
Ryan DeRemer @Ryan_DeRemer
Hey Ben,
I took a look at the logs before my original response, so I can see what was happening at least the last time you ran the macro. In that instance, it seems like it failed due to the Pro Tools bug I mentioned. I don't see any other reason based on the available information. If you can share a screen recording of it failing that could help fill in some blanks.
Pro Tools not being focused when it should be, at least when using SoundFlow, for me has usually been the result of not activating the main window directly after the dialogs. This happens anytime there's a dialog or app open, since the OS does not recognize these as "focused" (you'll notice that the PT menus are still what appear at the top even when you're working in an SF app). You're in a tough spot because you're compiling commands that may not necessarily play well together.
- In reply toBen_Rubin⬆:Ben Rubin @Ben_Rubin
Hey @samuel_henriques, reviving this old thread here because, i dont know if it's a change in PT or just a bug, but now when I run this script, it opens a weird version of the track rename dialog that does not have Previous or Next. If I actually double-click on a track header in pro tools, the correct dialog comes up, but if i run the script, this is what comes up and the script fails:
Any ideas on how to get around this and get the expected dialog up?
thanks
benBen Rubin @Ben_Rubin
I am now noticing that this is the dialog that comes up if you choose "rename..." from right-clicking on the track name, rather than double-clicking. But unless Im wrong, this script is supposed to do the double-click.
samuel henriques @samuel_henriques
Hello Ben,
try replacing line 13:
selectedTracks[0].popupButtons.first.mouseClickElement({ clickCount: 2 })
with:
selectedTracks[0].titleButton.mouseClickElement({ relativePosition: { x: 5, y: 5 }, clickCount: 2 })
Ben Rubin @Ben_Rubin
thanks! that worked.