Change amount in Number of Tracks.
Is there a way to change the "Number of Tracks" and the "Name" in the New Tracks dialogue box? I seem to be having troubles with this.
I'm trying to trigger the amount with a prompt.
sf.ui.proTools.menuClick({
menuPath: ["Track", "New..."],
});
var ntDlg = sf.ui.proTools.dialogWaitForManual({
dialogTitle: 'New Tracks',
}).dialog;
var trkCount = prompt("How many tracks do you want?");
sf.ui.proTools.windows.whoseTitle.is('New Tracks').first.textFields.whoseTitle.is('Number of new tracks').first.elementSetTextAreaValue({
value: trkCount,
});
sf.ui.proTools.windows.whoseTitle.is('New Tracks').first.textFields.whoseTitle.is('Track Name').first.elementSetTextAreaValue({
value: "IVR",
});
sf.ui.proTools.focusedWindow.getFirstWithTitle("Create").elementClick();
Christian Scheuer @chrscheuer2020-11-25 01:20:18.092ZHi Mike,
What happens when you run this? Where do you get stuck?
If you're getting errors, it's better to use the script's "Help" button so we can see your log files :)
Mike Wax @mikewaxIt's actually not getting an error. The script runs all the way through, but doesn't change any of the parameters.
Here is a screen recording:
Christian Scheuer @chrscheuer2020-11-25 12:03:35.952ZAh gotcha. I think you need the Set Text Field with Text Area action instead :)
Christian Scheuer @chrscheuer2020-11-25 12:29:45.138ZI almost got that title right.
See @Kitch's new video here on how to do it :)
Christian Scheuer @chrscheuer2020-11-25 13:44:52.318ZAnd the follow-up video here on how to do it in a script:
- In reply tochrscheuer⬆:
Mike Wax @mikewaxHey Christian,
Thank you for the reference and thank you @Kitch for the great videos!
So this works great on entering the Track Name in the New Tracks window. However, i'm still not able to enter in the Number of Tracks, and i think i know why.
I don't think that input is considered a "text field". It functions more as a counter. I know in HTML, you can set different types to your inputs, and they function differently. I think PT might label this input as a "number" type input, as opposed to a "text" type input, and that's why the
elementSetTextFieldWithAreaValueisn't catching it....Just a theory?If that is the case, would there be a workaround available? Maybe using a filter in JavaScript?
Also, i was wondering what the difference is between using Set Value of Text Area vs. Set Value of Text Field with Text Area? And when is the best case to use either?
As always, thank you both for the continued help! I would not know how to run my life if i didn't have SoundFlow! LOL!!
And for updated reference, here's my code:
sf.ui.proTools.appActivate(); sf.ui.proTools.appWaitForActive(); sf.ui.proTools.menuClick({ menuPath: ["Track", "New..."], }); var ntDlg = sf.ui.proTools.dialogWaitForManual({ dialogTitle: 'New Tracks', }).dialog; // var trkCount = prompt("How many tracks do you want?"); sf.ui.proTools.windows.whoseTitle.is('New Tracks').first.textFields.whoseTitle.is('Number of new tracks').first.elementSetTextFieldWithAreaValue({ value: "5", }); sf.ui.proTools.windows.whoseTitle.is('New Tracks').first.textFields.whoseTitle.is('Track Name').first.elementSetTextFieldWithAreaValue({ value: "IVR", }); sf.ui.proTools.focusedWindow.getFirstWithTitle("Create").elementClick();
Kitch Membery @Kitch2020-11-26 00:01:51.628ZHi Mike,
Yes you are correct. I need to do another video on that Hahhaha. Entering in the numbers is a little more involved.
I'll get the code for you shortly :-)
Rock on!
Kitch Membery @Kitch2020-11-26 00:15:53.553Z2020-11-26 00:33:17.056ZHere you go Mike :-)
sf.ui.proTools.appActivateMainWindow(); const win = sf.ui.proTools.windows.whoseTitle.is('New Tracks').first; const numberField = win.textFields.whoseTitle.is('Number of new tracks').first; const numberOfTracks = '4'; if (numberField.value.invalidate().value.trim() !== numberOfTracks) { numberField.elementClick(); sf.keyboard.type({ text: numberOfTracks }); var i = 0; while (numberField.value.invalidate().value !== numberOfTracks) { sf.wait({ intervalMs: 50 }); }; }Due to the nature of the number field UI elements in Pro Tools, the way I entered text in the video does not work. The above script;
• Clicks on the number field element.
• Simulates the keyboard typing the number of tracks.
• Repeats checking the number field until the the number updates and once it is correct the script continuesThe while loop ensures that the text has been fully entered before moving on.
Hope that makes sense.
UPDATED
Mike Wax @mikewaxAmazing. This works exactly like it should!!
So this is just a much better way to do the actions of "simulate click at this position, than change the number"?
I updated the script to use a
promptso the user can specify how many tracks as well as utilized your video for changing the track name.Tested and working great! Thank you for your genius, @Kitch & @chrscheuer!
sf.ui.proTools.menuClick({ menuPath: ["Track", "New..."], }); sf.ui.proTools.windows.whoseTitle.is('New Tracks').first.elementWaitFor(); sf.ui.proTools.windows.whoseTitle.is('New Tracks').first.textFields.whoseTitle.is('Track Name').first.elementSetTextFieldWithAreaValue({ value: "IVR", }); var ivrCount = prompt("How many tracks do you need?"); const win = sf.ui.proTools.windows.whoseTitle.is('New Tracks').first; const numberField = win.textFields.whoseTitle.is('Number of new tracks').first; const numberOfTracks = ivrCount; if (numberField.value.invalidate().value.trim() !== numberOfTracks) { numberField.elementClick(); sf.keyboard.type({ text: numberOfTracks }); var i = 0; while (numberField.value.invalidate().value !== numberOfTracks) { sf.wait({ intervalMs: 50 }); }; } sf.ui.proTools.focusedWindow.getFirstWithTitle("Create").elementClick();