Follow up on previous post regarding SSL script for Pro Tools
Title
Follow up on previous post regarding SSL script for Pro Tools
What do you expect to happen when you run the script/macro?
Hello again. The script is supposed to bank the SSL UF1 to the selected channel, and also the SSL UC1 as it will open an SSL plugin on that channel, if one is instantiated.
Are you seeing an error?
What happens when you run this script?
The script succeeds in banking the UF1, but the SSL plugin GUI does not open, and therefore the UC1 does not bank to the selected channel.
How were you running this script?
I used a keyboard shortcut within the target app
How important is this issue to you?
5
Details
{ "inputExpected": "Hello again. The script is supposed to bank the SSL UF1 to the selected channel, and also the SSL UC1 as it will open an SSL plugin on that channel, if one is instantiated. ", "inputIsError": false, "inputWhatHappens": "The script succeeds in banking the UF1, but the SSL plugin GUI does not open, and therefore the UC1 does not bank to the selected channel.", "inputHowRun": { "key": "-Mpfwh4RkPLb2LPwjePT", "title": "I used a keyboard shortcut within the target app" }, "inputImportance": 5, "inputTitle": "Follow up on previous post regarding SSL script for Pro Tools" }
Source
var lastFocusedTrackName;
globalState.isFollowFocusedTrackPaused = false;
function main() {
try {
if (globalState.isFollowFocusedTrackPaused) return;
var newName = sf.ui.proTools.selectedTrackNames[0];
if (newName === lastFocusedTrackName || newName === undefined) return;
//This ulitmately makes UF8 follow as well as a work around for banking
const selectedTrackName = sf.ui.proTools.selectedTrackNames[0];
globalState.selectedTracksJT = selectedTrackName;
//log(globalState.selectedTracksJT);
//function scrollToTrack(trackName) {
sf.ui.proTools.appActivateMainWindow();
var originalClipboardText = sf.clipboard.getText().text || '';
sf.ui.proTools.menuClick({ menuPath: ["Track", "Scroll to Track..."] });
sf.ui.proTools.confirmationDialog.elementWaitFor();
sf.clipboard.setText({ text: selectedTrackName });
sf.ui.proTools.menuClick({ menuPath: ['Edit', 'Paste'] });
sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is("OK").first.elementClick();
sf.clipboard.setText({ text: originalClipboardText, });
lastFocusedTrackName = newName;
const pluginName1 = 'SSL Native Channel Strip 2';
const group1Visible = sf.ui.proTools.getMenuItem('View', 'Edit Window Views', 'Inserts A-E').isMenuChecked;
const group2Visible = sf.ui.proTools.getMenuItem('View', 'Edit Window Views', 'Inserts F-J').isMenuChecked;
const insertButtons = sf.ui.proTools.selectedTrack.invalidate().insertButtons.slice(group1Visible ? 0 : 5, group2Visible ? 10 : 5);
const eqButton = insertButtons.find(b => b.exists && b.value.invalidate().value.includes(pluginName1));
if (eqButton) {
eqButton.elementClick();
}
} catch (err) {
}
}
function runForever(name, action, interval, timeout) {
var now = (new Date).valueOf();
if (now - globalState[name] < timeout) throw 0; //Exit if we were invoked again inside the timeout
globalState[name] = now;
sf.engine.runInBackground(function () {
try {
while (true) {
sf.engine.checkForCancellation();
globalState[name] = (new Date).valueOf();
action();
sf.wait({ intervalMs: interval, executionMode: 'Background' });
}
} finally {
globalState[name] = null;
}
});
}
runForever("OpenPluginFollowTrackSelection", main, 500, 5000);
Links
User UID: i0dn0LsNB2g67fCGbY2wGHitTPu2
Feedback Key: sffeedback:i0dn0LsNB2g67fCGbY2wGHitTPu2:-O1v3Tk66xNlpiKBXQxw
Feedback ZIP: TZSvfqFlsSTXkn+sbPzLN/3iXzx0TcJ9LvJaRhJMJ/7/3qL9zXDoPorr1AtuFamP6mOVggJIl4FW1DQSJpkpcDIPWafsxlzJz+takMvwSTLdSG9rQpMJ7f3IfRp2iDRee+Wti06zjLUhL5K7ptlb5uRqknq2THid2n+OPpHqQloU5fHlPfW+NotHFpN36kxg1XBtvqBOqsrzECblc6Vn5+aMOOcLzn2L5QHiKrKeUSyXzoA9vWSytwXOGdls6iNBpmWN+F0DOG3Tl50Qtfb+MrMqB+t/pjanC1c+4b8NqppGqLC3OdSa2IXQisTpUij0kOUgwnBJ2F7WrG8taHSMcA==
- Chris Shaw @Chris_Shaw2024-07-16 18:22:30.023Z2024-07-16 19:16:06.874Z
I did a bunch of refactoring here.
sf.ui.proTools.selectedTrackNames[0]
was assigned to two different variables (newName
was redundant).- It isn't necessary to use the clipboard to fill in the confirmation dialog window text field. This was probably your issue. When you set the clipboard you need to follow it with a
sf.clipboard.waitForText()
before pasting the clipboard contents. - I renamed some of the variables to more accurately describe what they are.
- I put the scroll to track routine into a function so that the main function is easier to read
- Finally, I added a routine to determine if the plugin on the selected track is already open - if it is the insert button won't be clicked (which would close it).
Hopefully this should do it. I don't have the SSL Native plugin (or the SSL hardware surfaces) so I used the EQ3 7-Band to test the script and it worked as expected:
function scrollToSelectedTrack(selectedTrackName) { sf.ui.proTools.appActivateMainWindow(); sf.ui.proTools.menuClick({ menuPath: ["Track", "Scroll to Track..."] }); const confirmationDialogWin = sf.ui.proTools.confirmationDialog; sf.ui.proTools.confirmationDialog.elementWaitFor(); confirmationDialogWin.textFields.first.elementSetTextFieldWithAreaValue({ value: selectedTrackName, useMouseKeyboard: true }); sf.ui.proTools.confirmationDialog.buttons.whoseTitle.is("OK").first.elementClick(); } function isPluginOpen(pluginInsertButton) { const insertNames = "ABCDEFGHIJ"; const insertLetter = pluginInsertButton.title.value.slice(-1); const insertNumber = insertNames.indexOf(insertLetter) const insertSelectorButton = sf.ui.proTools.selectedTrack.insertSelectorButtons[insertNumber]; const isPluginOpen = insertSelectorButton.value.value.includes("open") return (isPluginOpen) } var lastFocusedTrackName; globalState.isFollowFocusedTrackPaused = false; function main() { if (globalState.isFollowFocusedTrackPaused) return; const selectedTrackName = sf.ui.proTools.selectedTrackNames[0]; if (selectedTrackName === lastFocusedTrackName || selectedTrackName === undefined) return; scrollToSelectedTrack(selectedTrackName) lastFocusedTrackName = selectedTrackName; const pluginName1 = 'SSL Native Channel Strip 2'; const areInsertsAeVisible = sf.ui.proTools.getMenuItem('View', 'Edit Window Views', 'Inserts A-E').isMenuChecked; const areInsertsFjVisible = sf.ui.proTools.getMenuItem('View', 'Edit Window Views', 'Inserts F-J').isMenuChecked; const visibleInsertButtons = sf.ui.proTools.selectedTrack.invalidate().insertButtons.slice(areInsertsAeVisible ? 0 : 5, areInsertsFjVisible ? 10 : 5); const pluginInsertButton = visibleInsertButtons.find(b => b.exists && b.value.invalidate().value.includes(pluginName1)); if (pluginInsertButton && !isPluginOpen(pluginInsertButton)) { pluginInsertButton.elementClick(); } } function runForever(name, action, interval, timeout) { var now = (new Date).valueOf(); if (now - globalState[name] < timeout) throw 0; //Exit if we were invoked again inside the timeout globalState[name] = now; sf.engine.runInBackground(function () { try { while (true) { sf.engine.checkForCancellation(); globalState[name] = (new Date).valueOf(); action(); sf.wait({ intervalMs: interval, executionMode: 'Background' }); } } finally { globalState[name] = null; } }); } runForever("OpenPluginFollowTrackSelection", main, 500, 5000);
Chris Shaw @Chris_Shaw2024-07-16 18:30:12.367Z
I also removed the try/catch block. You should only use them if absolutely necessary
- In reply toChris_Shaw⬆:DDr Jack @drjack69
Hi Chris. Many thanks for taking the time to rejig this for me. Unfortunately, it’s still not working. It’s definitely doing something with the insert points, because it’s throwing tracks around to where they shouldn’t be. It’s also giving: Error: GetTrackSelectionAction on line 62 But I had a bit of an idea, would it be possible to alter the code so that it scrolls to selected track, and then opens insert J on each channel/track, rather than looking for the plugin? I typically put my SSL 360 plugins in that slot anyway, and I suppose it would also mean I wouldn’t have to add each plugin to the script. I’m utterly useless at this sort of thing, and I’m very grateful for your taking time to help.
Chris Shaw @Chris_Shaw2024-07-16 20:40:11.080Z2024-07-16 22:35:21.877Z
Are you using this in the edit window or mix window?
Most, if not all, SF scripts are meant to be used in the edit window.Chris Shaw @Chris_Shaw2024-07-16 22:34:09.007Z
It should work if the edit window window is open along with the edit window but it will definitely fail if the edit window is closed.
- DDr Jack @drjack69
Hi Chris. Thanks again for replying. It’s not working in either window. I tried both your script and the one I had before in both windows, and neither pulls the plugin up, but both scroll to selected track in both windows. When using sonoma, the older script would do it in both windows, but then I got the contextual menus bug. I’m wondering whether it’s possible to just open insert J rather than look for the plugin by name. That would arguably be a better solution for me. Many many thanks for helping me.
Chris Shaw @Chris_Shaw2024-07-17 17:25:27.473Z
It'd be very helpful if you could post a screen recording of what's happening. I can't figure out why it isn't working on your setup. Perhaps it's something to do with the SSL controllers which I don't have access to.
- DDr Jack @drjack69
I don’t think it’s anything to do with the SSL controllers as the UC1 snaps to whatever plugin (that’s supported) is open, which is why I want the script to open the SSL plugin on the selected track. The UF1 is only working as a HUI so I can’t see how that would affect the script.
I’ll film a video of what it’s doing for you and post it when I can. Thanks again for taking time to help me.
- In reply todrjack69⬆:Chris Shaw @Chris_Shaw2024-07-17 17:21:45.819Z
Chris Shaw @Chris_Shaw2024-07-17 17:22:19.882Z
I'm not on Sonoma so I'm not sure how to proceed here.
- DDr Jack @drjack69
To clarify, Chris, I’m running Ventura. It was working on Sonoma but I couldn’t access the contextual menus. Think you guys have the menu issue as a known issue… -1189 as memory serves. But I rolled back to Ventura and I’m running PT 2024.3. I really appreciate your continued looking into this for me.
Chris Shaw @Chris_Shaw2024-07-17 18:55:23.137Z
I'm running Ventura as well which is why I'm puzzled.
- DDr Jack @drjack69
Hi Chris. In trying to make videos for you, I appear to have made it work. It works in both windows, but you have to have the inserts viewable in the edit window otherwise it doesn’t work in either window. I’m not sure why, but it works perfectly when you do. Thank you!!! I don’t mind having the inserts viewable in the edit window anyway, so that’s problem solved!! Thanks again, you’re a genius! Just one more question for you, if I want to add the other SSL plugins, where (and how) would I put them in the code?
- In reply toChris_Shaw⬆:
Kitch Membery @Kitch2024-07-17 17:32:32.721Z
I'll take a look when I have a chance, it might not be today though. :-)