@Kitch @Chris_Shaw Currently I use this function
function navigateTrack({ direction, repetitions }) {
for (let i = 0; i < repetitions; i++) {
if (direction === 'Up') {
sf.ui.proTools.getMenuItem("Edit", "Selection", "Extend Edit Up").elementClick();
sf.ui.proTools.getMenuItem("Edit", "Selection", "Remove Edit from Bottom").elementClick();
}
if (direction === 'Down') {
sf.ui.proTools.getMenuItem("Edit", "Selection", "Extend Edit Down").elementClick();
sf.ui.proTools.getMenuItem("Edit", "Selection", "Remove Edit from Top").elementClick();
}
}
}
But scripts are moving too fast for it. Hoping you can help build a way that instead uses track index.
In the meeting I think you said:
"Getting all the info about the selected tracks and the track number and then from there adding whatever needs to be added."
And Chris you said :
'Let the next track index be the first track and count number of tracks from there'
Thanks guys!
- Kitch Membery @Kitch2023-03-01 21:27:42.787Z2023-03-01 21:34:57.600Z
Fun!!!!
/** * @param {object} obj * @param {'Down'|'Up'} obj.direction * @param {number} [obj.repetitions] */ function navigateTracks({ direction, repetitions = 1 }) { //Activate Pro Tools Main window sf.ui.proTools.appActivateMainWindow(); //Invalidate the main window sf.ui.proTools.mainWindow.invalidate(); //Get the visible track names let visibleTrackNames = sf.ui.proTools.visibleTrackNames; //Get the selected track names let selectedTrackNames = sf.ui.proTools.selectedTrackNames; //Get the selected track count let selectedTrackCount = sf.ui.proTools.selectedTrackCount; let trackIndexOffset = direction === "Down" ? selectedTrackCount : selectedTrackCount * -1; //Make a lookup table for the tracks with indexes indexes let trackLookup = visibleTrackNames.map((name, index) => ({ name, index, })); //Get the target track indexs let targetTrackIndexes = trackLookup.filter(track => selectedTrackNames.some(name => name === track.name)) .map(track => track.index + (trackIndexOffset * repetitions)); //Use the lookup table to get the target track names let targetTrackSet = targetTrackIndexes.map(index => trackLookup[index].name); //Select the target tracks sf.ui.proTools.trackSelectByName({ names: targetTrackSet }); } navigateTracks({ direction: "Down", //repetitions: 2 });
Updated :-)
Kitch Membery @Kitch2023-03-01 21:29:07.259Z
@Owen_Granich_Young
FYI The repetitions argument is optional with a default value of 1.- In reply toKitch⬆:
Kitch Membery @Kitch2023-03-01 21:31:26.395Z
@Owen_Granich_Young, Stand by for update with improved variable naming.
- OIn reply toOwen_Granich_Young⬆:Owen Granich-Young @Owen_Granich_Young
Thank you!
waaaay snappier, now to go replace the old function it like half a dozen scriptsKitch Membery @Kitch2023-03-01 21:56:56.533Z
Yay!!! UI automation wins over keyboard simulation once again!!! :-)