No internet connection
  1. Home
  2. How to

Open plugin by name triggered by track selection

By Joel K @Joel_K
    2021-08-02 19:44:02.496Z2021-08-02 22:05:04.645Z

    Hi,
    I'm trying to figure out how to open a specific plugin (SSL Channel Strip 2 in my case) on the selected track automatically. I have found the following scripts by Christian Scheuer, I imagine they could be combined somehow? Any help would be much appreciated!

    Plugin open by name:

    const pluginName = '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.insertButtons.slice(group1Visible ? 0 : 5, group2Visible ? 10 : 5);
    
    const eqButton = insertButtons.find(b => b.exists && b.value.invalidate().value.includes(pluginName));
    if (!eqButton) throw `Could not find plugin "${pluginName}" on selected track`;
    
    eqButton.elementClick();
    

    And track selection as a trigger, but in this case for output toggle which I don't need:

    var lastFocusedTrackName;
    
    function main() {
        var newName = sf.ui.proTools.selectedTrackNames[0];
        if (newName === lastFocusedTrackName || newName === undefined) return;
    
        lastFocusedTrackName = newName;
    
        sf.ui.proTools.selectedTrack.trackOutputToggleShow();
    }
    
    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("isFollowFocusedTrackRunning", main, 500, 5000);
    

    If I could get this to work I would be in heaven..

    Solved in post #4, click to view
    • 59 replies

    There are 59 replies. Estimated reading time: 50 minutes

    1. J
      In reply toJoel_K:
      Joel K @Joel_K
        2021-08-04 09:35:41.839Z

        Have been trying to figure this out for hours and hours now.. Not being a programmer, I don't even know if I'm trying to do something that could even work haha.. Does anyone know if this is doable?

        1. samuel henriques @samuel_henriques
            2021-08-05 15:39:38.137Z2021-08-05 15:49:40.889Z

            Hello @Joel_K,

            Try this.

            var lastFocusedTrackName;
            
            function main() {
                try {
            
                    var newName = sf.ui.proTools.selectedTrackNames[0];
                    if (newName === lastFocusedTrackName || newName === undefined) return;
            
                    lastFocusedTrackName = newName;
            
            
                    const pluginName = '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(pluginName));
                    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);
            
            
            
            ReplySolution
            1. JJoel K @Joel_K
                2021-08-05 17:35:36.167Z

                Oooh man! It works flawlessly! You can't imagine how much this is going to speed up my workflow. Thank you so much for helping me out!

                1. samuel henriques @samuel_henriques
                    2021-08-05 17:37:33.103Z

                    Awesome it works, really happy to help out.

                    1. Yo @samuel_henriques if you have the time, think about Templating this to user assigned plugin, and putting it in the store. I think it'd be VERY POPULAR. Just relinked it in the forum to a guy who said 'i'd litterally get sound flow for this feature.'

                      1. RRafael Villafane @Rafael_Villafane
                          2021-10-07 22:34:20.728Z

                          Yes! I'm that guy, and i do plan to get Soundflow for this feature alone!

                          1. samuel henriques @samuel_henriques
                              2021-10-08 21:34:58.749Z

                              Hello @Rafael_Villafane and @Owen_Granich_Young,

                              here you go, search for "Open Plug-in by Name Follow Track Selection" in the store.

                              Enjoy.

                              1. RRafael Villafane @Rafael_Villafane
                                  2022-11-30 05:46:22.809Z2022-11-30 06:33:35.348Z

                                  Hi Samuel, just installed Soundflow (absolute newb here) and was able to add your command to my Pro Tools deck. It seems to work fine on ONE track in the session, but it does not work on any other track (Edit or Mix window). If i select a channel strip on any track in the session and then select this particular track, the plugin window opens, and both UC1 and UF8 go this this one track. If i select any other track in the session, CS2 does not open, so 'track follow' does not work.

                                  Very sorry to take your time with this, i'm obviously doing something wrong but i've repeated this on every track in the session (about 50) and same thing. But if i select this one track, no matter where i am in the session, it follows perfectly.

                                  Thank you very much for your time and sorry for the inconvenience.

                                  1. Kitch Membery @Kitch2022-12-07 03:47:02.918Z

                                    Hi @Rafael_Villafane,

                                    Great to meet you today.

                                    I just tried out @samuel_henriques script and it seems to be working well for me.

                                    One thing that you may want to check is that "Link Track and Edit Selection" is enabled in Pro Tools

                                    The button looks like this.

                                    You can also enable it from the "Options" menu in SoundFlow.

                                    I hope that helps. Let me know if that does not fix the issue. :-)

                                    Rock on!

                                    1. RRafael Villafane @Rafael_Villafane
                                        2022-12-09 07:21:08.902Z2022-12-10 20:09:37.093Z

                                        Hi @Kitch, the pleasure was mine, thank you very much for your time and patience. To answer your question, "Link Track and Edit Selection" was selected, no problem there, but i think i figured it out. When SSL released UC1 it controlled one plugin (CS2), but they recently released the 4KB (plugin emulation of their 4K console) so UC1 now controls both plugins. Long story short, UC1 does in fact, follow any track with the CS2 plugin, but not the tracks with 4KB. So sorry for the confusion. I use 4KB more than CS2 these days, that's why i thought it only worked on that one track, but it does work on all tracks with CS2 (on both Mix and Edit windows)! So sorry for the misinformation.

                                        Anyway, might it be possible to modify the command so that it opens whichever one of the two plugins is present when a channel is selected, or maybe to open whichever plugin is on insert B or C? I'm beginning to see how incredibly useful SoundFlow can be w/Pro Tools but if i'm honest, what actually attracted me to SoundFlow was that one command. I'm a newb, still unable to edit commands but i'd be happy to pay someone for their time to modify that command if that's possible. Sorry for the long winded post, and thanks again for your great help!

                                        1. Kitch Membery @Kitch2022-12-09 07:41:23.129Z

                                          You're welcome Raphael! And absolutely this can be done!

                                          Try this:

                                          const pluginName1 = 'EQ3 1-Band';
                                          const pluginName2 = 'EQ3 7-Band';
                                          
                                          let lastFocusedTrackName;
                                          
                                          function main() {
                                              try {
                                                  let newName = sf.ui.proTools.selectedTrackNames[0];
                                                  if (newName === lastFocusedTrackName || newName === undefined) return;
                                          
                                                  lastFocusedTrackName = newName;
                                          
                                                  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 targetInsertButton = insertButtons.find(b => {
                                                      const getInsertButton = (pluginName) => b.value.invalidate().value.includes(pluginName);
                                                      return b.exists && getInsertButton(pluginName1) || getInsertButton(pluginName2);
                                                  });
                                          
                                                  if (targetInsertButton) {
                                                      targetInsertButton.elementClick();
                                                  }
                                              } catch (err) { }
                                          }
                                          
                                          function runForever(name, action, interval, timeout) {
                                              let 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, 250, 5000);
                                          

                                          Just change the pluginName1 and pluginName2 values so they match the SSL plugin names you want to open.

                                          Rock on!

                                          1. RRafael Villafane @Rafael_Villafane
                                              2022-12-10 06:47:24.612Z2022-12-10 08:21:16.855Z

                                              Hi Kitch, i attempted to make a keyboard trigger with your command suggestion. Started from scratch, copy/pasted your command, edited the two plugin names to reflect the two SSL's plugs, was careful to name them exactly as they appear in SSL's plugin descriptions, saved it, recorded the keystroke, limited the trigger to Pro Tools, tried it on a session and it only opened one of the two plugins (CS2), so i suspect the command wasn't actually recorded and SF was still reacting to Samuel Henriques' previous command which only opens CS2 (macro saved on a deck which i operated from an Iphone). I'm utterly useless with SF and embarrassed to keep taking your time like this. Is there a way i could pay someone for a one on one to help me get started, at least with the basics? So sorry for the inconvenience sir. Thanks again for your time.

                                              1. samuel henriques @samuel_henriques
                                                  2022-12-10 10:55:01.021Z2022-12-10 12:08:42.394Z

                                                  Hello Rafael,
                                                  I'm sure PT is pulling our leg on this one,
                                                  The easiest way for this to fail is the plugin name, pro tools shows one thing but lets SF read a different name.
                                                  Make a new empty script and use this code to get all the names from the selected track, so you can copy paste on Kitch's script. If it's still failing, please make a screen recording so I can see if there is anything else the script is missing.

                                                  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);
                                                  log(insertButtons.map(pn => pn.value.invalidate().value))
                                                  
                                                  1. RRafael Villafane @Rafael_Villafane
                                                      2022-12-10 19:08:54.412Z

                                                      Thank you very much for your time Samuel, will try it tonight! Two questions:
                                                      Your original script opens CS2 perfectly on both, Mix and Edit Windows. Your new addendum mentions 'Edit Window' twice, but no Mix window. Do you think this might work on both Edit and Mix windows, as your previous command does?

                                                      And, where do i paste it? Do i substitute line 1 and 2 on Kitch's command

                                                      with the new script, or just add it to Kitch's script, and if so, where on his command?

                                                      Thanks again.

                                                      1. samuel henriques @samuel_henriques
                                                          2022-12-10 19:31:50.051Z

                                                          I'll check about working on mix and edit, I don't remember if it would work.
                                                          But first lets figure out the name thing.
                                                          The bit I set you last will log the correct name for the plugin.
                                                          Then you need to copy/paste the plugin names you are looking to open on kitch's, replacing the EQ3 1-Band and 7-Band.

                                                          1. RRafael Villafane @Rafael_Villafane
                                                              2022-12-10 19:39:43.335Z

                                                              OK so i paste your last bit on top of Kitch's command, and then replace EQ3 1-Band and 7-Band with the SSL plugs, correct? Thanks again!

                                                              1. samuel henriques @samuel_henriques
                                                                  2022-12-10 20:06:35.559Z

                                                                  sorry, thats not it. I didn't explain properly.
                                                                  Let's try another way.
                                                                  Send me the names you are using now.

                                                                  And could you run the bit I sent you on an empty script and copy/paste the log here.
                                                                  Run it on the track that works, then select the one that doesn't work and run it again.
                                                                  it should give something like this for each track:

                                                                • RRafael Villafane @Rafael_Villafane
                                                                    2022-12-10 20:17:40.598Z2022-12-10 20:23:51.818Z

                                                                    You explained perfectly. My bad, sorry. So i just run your bit to get the correct names of the plugins. Then i copy the correct names on to Kitch's script, correct?

                                                                    BTW the names i entered were:
                                                                    SSL Native Channel Strip 2 and SSL 4K B

                                                                    1. samuel henriques @samuel_henriques
                                                                        2022-12-10 20:27:15.324Z

                                                                        thats it, hopefully there is some space or letter different.

                                                                        1. RRafael Villafane @Rafael_Villafane
                                                                            2022-12-10 20:29:25.781Z

                                                                            Perfect, will try it tonight. Thank you so much.

                                                                            1. OOwen Granich-Young @Owen_Granich_Young
                                                                                2022-12-10 21:30:57.789Z2022-12-10 22:28:02.106Z

                                                                                @samuel_henriques food for though as I'm quietly following along on this. Well, actually 2 thoughts.

                                                                                ONE - Triggering the script should be a toggle - First button press should enable the runforever and then 2nd button press toggle it back off. I know someone (maybe you) recently built this for the OUTPUT window version of this script and I've been using it a lot more because of it.

                                                                                TWO - What if we took the chance of 'user error' out of this script entirely. So the first time the script is run it runs the user through a prompt to the tune of let pluginName = sf.ui.prompt {search and prompt from all plugins here} then it either stores that as globalstate or Json? This way people can't mispell or anything else.

                                                                                @Rafael_Villafane question for you, is your EQ plugin always in the same insert slot on every track wether it's CS2 or 4KB? If so it might make more sense in your case for the script to open whatever plugin is on a specific insert.

                                                                                anyways just food for thought as I've been getting the updates on this post and am always curious to keep following.

                                                                                1. RRafael Villafane @Rafael_Villafane
                                                                                    2022-12-10 21:39:47.197Z2022-12-11 19:30:36.566Z

                                                                                    @Owen_Granich_Young Yes, i always make sure to use the same insert slot, whether CS2 or 4KB. Thank you.

                                                                                2. RRafael Villafane @Rafael_Villafane
                                                                                    2022-12-11 03:17:08.618Z2022-12-12 22:24:40.972Z

                                                                                    Hi @samuel_henriques @Kitch I ran the script. Here's a copy of the log. It seems the names were correct?

                                                                                    [
                                                                                    "unassigned",
                                                                                    "SSL Native Channel Strip 2",
                                                                                    "unassigned",
                                                                                    "unassigned",
                                                                                    "unassigned"
                                                                                    ]

                                                                                    [
                                                                                    "unassigned",
                                                                                    "SSL 4K B",
                                                                                    "unassigned",
                                                                                    "unassigned",
                                                                                    "unassigned"
                                                                                    ]

                                                                                    I copy/pasted the names to make sure there was no error, onto Kitch's script. Ran the script and only the tracks with CS2 opened, but not the tracks with 4KB. I tried writing the plugin names with single quote marks (as per Kitch's script e.g. 'SSL 4K B') and with double quote marks (as per the logs e.g "SSL 4K B"). No luck either way.

                                                                                    Kitch's edited command now starts like this:

                                                                                    const pluginName1 = 'SSL Native Channel Strip 2';
                                                                                    const pluginName2 = 'SSL 4K B';

                                                                                    I hope this is of some help. Thank you again for your time.

                                                                                    1. Kitch Membery @Kitch2022-12-12 22:46:30.921Z

                                                                                      Hi @Rafael_Villafane,

                                                                                      Quick question. Since these are two individual plugins. do they both exist on a single track? Or is there only one SSL plugin on each track?

                                                                                      The script only opens the first of the SSL plugins that it finds on the track.

                                                                                      Let me know.

                                                                                      1. RRafael Villafane @Rafael_Villafane
                                                                                          2022-12-12 23:21:12.425Z

                                                                                          Thank you @Kitch, only one SSL channel strip plug per track. The two logs i posted were separate tracks.

                                                                                      2. RRafael Villafane @Rafael_Villafane
                                                                                          2022-12-12 22:28:30.449Z

                                                                                          Hi @samuel_henriques, just wondering if there's a script that might open whichever plugin is in a particular insert slot? I always use the same slot for the SSL channel strips. Thank you for your time. BTW i did as you asked a couple of days ago (see previous post).

                                                                                          1. There's this one here
                                                                                            Insert X follows track selection #post-3

                                                                                            Here it is for INSERT 1 and Output window (sorry I think it needs that part to be able to know and follow the way it's built) If you press the button once the Run forever starts running. You can turn it off by pressing it again.

                                                                                            TRACK MUST BE AT LEAST SMALL SIZE for it to work. Micro breaks it.

                                                                                            var lastFocusedTrackName;
                                                                                            
                                                                                            globalState.runAutoFollowOutputWin = !globalState.runAutoFollowOutputWin
                                                                                            
                                                                                            function main() {
                                                                                                try {
                                                                                            
                                                                                                    var newName = sf.ui.proTools.selectedTrackNames[0];
                                                                                                    if (newName === lastFocusedTrackName || newName === undefined) return;
                                                                                            
                                                                                                    lastFocusedTrackName = newName;
                                                                                            
                                                                                                    if (sf.ui.proTools.selectedTrack.outputWindowButton.value.invalidate().value !== 'open')
                                                                                                        sf.ui.proTools.selectedTrack.trackOutputToggleShow({ onError: 'Continue' });
                                                                                                        sf.ui.proTools.selectedTrack.trackInsertToggleShow({
                                                                                                        insertNumber: 1,
                                                                                                        targetValue: "Enable",
                                                                                                        onError: "Continue",
                                                                                                        });
                                                                                            
                                                                                                } 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 && globalState.runAutoFollowOutputWin) {
                                                                                                            sf.engine.checkForCancellation();
                                                                                                            globalState[name] = (new Date).valueOf();
                                                                                            
                                                                                                            action();
                                                                                            
                                                                                                            sf.wait({ intervalMs: interval, executionMode: 'Background' });
                                                                                                        }
                                                                                                    } finally {
                                                                                                        globalState[name] = null;
                                                                                                    }
                                                                                                });
                                                                                            }
                                                                                            
                                                                                            runForever("isFollowFocusedTrackRunning", main, 500, 5000);
                                                                                            
                                                                                            
                                                                                            

                                                                                            Maybe someone more skilled than me can show how to do it without also showing output window, and bomb proof it for track heights?

                                                                                            1. samuel henriques @samuel_henriques
                                                                                                2022-12-12 23:03:06.088Z2022-12-13 09:30:25.345Z

                                                                                                Hello Rafael,
                                                                                                Sorry this is taking so long, it's rare but sometimes there are small details that are hard to figure out.
                                                                                                I'm still intrigued why it doesn't work for you, could you make a screen capture of the script working for one track but failing on the other, please?

                                                                                                In the mean time, here's a variation of the initial script:

                                                                                                const pluginNames = ['SSL Native Channel Strip 2', 'SSL 4K B'];
                                                                                                
                                                                                                
                                                                                                let lastFocusedTrackName;
                                                                                                
                                                                                                function main() {
                                                                                                    try {
                                                                                                        let newName = sf.ui.proTools.selectedTrackNames[0];
                                                                                                        if (newName === lastFocusedTrackName || newName === undefined) return;
                                                                                                
                                                                                                        lastFocusedTrackName = newName;
                                                                                                
                                                                                                        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 targetInsertButton = insertButtons.find((b, i) => {
                                                                                                            const getInsertButton = (pluginNameArr) => pluginNameArr.includes(b.value.invalidate().value);
                                                                                                            const isOpen = sf.ui.proTools.selectedTrack.insertSelectorButtons[i].value.invalidate().value === "open"
                                                                                                
                                                                                                            return b.exists && !isOpen && getInsertButton(pluginNames);
                                                                                                        });
                                                                                                
                                                                                                        if (targetInsertButton) {
                                                                                                            targetInsertButton.elementClick();
                                                                                                        }
                                                                                                    } catch (err) { }
                                                                                                }
                                                                                                
                                                                                                function runForever(name, action, interval, timeout) {
                                                                                                    let 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();
                                                                                                                if (globalState[name] === null) return;
                                                                                                                globalState[name] = (new Date).valueOf();
                                                                                                
                                                                                                                action();
                                                                                                
                                                                                                                sf.wait({ intervalMs: interval, executionMode: 'Background' });
                                                                                                            }
                                                                                                        } finally {
                                                                                                
                                                                                                            globalState[name] = null;
                                                                                                        }
                                                                                                    });
                                                                                                }
                                                                                                
                                                                                                
                                                                                                
                                                                                                let nameThisRunForever = "OpenPluginNameFollowTrackSelection"
                                                                                                
                                                                                                // Run Script
                                                                                                if (!globalState[nameThisRunForever]) {
                                                                                                
                                                                                                    runForever(nameThisRunForever, main, 250, 5000);
                                                                                                
                                                                                                
                                                                                                } else { //Stop script
                                                                                                    log("stop: " + nameThisRunForever);
                                                                                                    globalState[nameThisRunForever] = null
                                                                                                
                                                                                                }
                                                                                                

                                                                                                And here a version that only opens insert number, change it to the one you want on line 1

                                                                                                let insertSlotNumber = 2
                                                                                                
                                                                                                let lastFocusedTrackName;
                                                                                                
                                                                                                function main() {
                                                                                                    try {
                                                                                                        let newName = sf.ui.proTools.selectedTrackNames[0];
                                                                                                        if (newName === lastFocusedTrackName || newName === undefined) return;
                                                                                                
                                                                                                        lastFocusedTrackName = newName;
                                                                                                
                                                                                                        sf.ui.proTools.selectedTrack.trackInsertToggleShow({
                                                                                                            insertNumber: insertSlotNumber,
                                                                                                            targetValue: "Enable",
                                                                                                        });
                                                                                                    } catch (err) { }
                                                                                                }
                                                                                                
                                                                                                function runForever(name, action, interval, timeout) {
                                                                                                    let 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();
                                                                                                                if (globalState[name] === null) return;
                                                                                                                globalState[name] = (new Date).valueOf();
                                                                                                
                                                                                                                action();
                                                                                                
                                                                                                                sf.wait({ intervalMs: interval, executionMode: 'Background' });
                                                                                                            }
                                                                                                        } finally {
                                                                                                
                                                                                                            globalState[name] = null;
                                                                                                        }
                                                                                                    });
                                                                                                }
                                                                                                
                                                                                                
                                                                                                
                                                                                                let nameThisRunForever = "OpenPluginInsertNFollowTrackSelection"
                                                                                                
                                                                                                // Run Script
                                                                                                if (!globalState[nameThisRunForever]) {
                                                                                                
                                                                                                    runForever(nameThisRunForever, main, 250, 5000);
                                                                                                
                                                                                                
                                                                                                } else { //Stop script
                                                                                                    log("stop: " + nameThisRunForever);
                                                                                                    globalState[nameThisRunForever] = null
                                                                                                
                                                                                                }
                                                                                                
                                                                                                1. samuel henriques @samuel_henriques
                                                                                                    2022-12-12 23:21:45.068Z

                                                                                                    Made an update to the first one I just posted, just so it would't close the opened plug-in if already opened.

                                                                                                    1. RRafael Villafane @Rafael_Villafane
                                                                                                        2022-12-12 23:25:25.284Z

                                                                                                        Thank you so much @samuel_henriques, will try them both tonight and report back. And will try to make the screen capture as well.

                                                                                                        Thanks again for your time!

                                                                                                        1. RRafael Villafane @Rafael_Villafane
                                                                                                            2022-12-13 04:52:03.999Z2022-12-13 18:09:07.291Z

                                                                                                            @samuel_henriques @Kitch

                                                                                                            Hi Samuel, your first command worked perfectly! Haven't tried the 2nd one (open by insert #) but the 1st one works great! Can i post about this on Gearslutz? I know more than one will be happy.

                                                                                                            BTW Kitch's original command seems to work now as well, so i won't be able to send you the screen capture of it not working. Could it be that Samuel's script is working when i think it's Kitch's? I gave them both different triggers, and even when i bypass the App, selecting a track activates both plugins, so i'm not sure what's happening but both plugs now follow track selection on UF8 or screen, flawlessly, Thank you so much for this! One last question, is there a way to deactivate the triggers if necessary? Bypassing the App doesn't seem to do it.

                                                                                                            Thank you both very, very much, and sorry to have taken your time with this.

                                                                                                            1. Kitch Membery @Kitch2022-12-13 05:45:49.916Z

                                                                                                              Great to hear, @Rafael_Villafane! :-)

                                                                                                              It just dawned on me why my script did not work.

                                                                                                              The type of Scripts we are using here are slightly different to standard SoundFlow commands. "Run Forever" scripts like this one run in the background and continue running until they are stopped. There is a high possibility the original script that Samuel shared was still running in the background blocking the script I shared, as it is using the same globalState name "OpenPluginFollowTrackSelection" as the original.

                                                                                                              But so glad it's working for you now. :-)

                                                                                                              @samuel_henriques, do you have the script to stop/start the "OpenPluginFollowTrackSelection" Run Froever script. (If not I'll make one).

                                                                                                              Till then, Rafael, you can use "Control + Shift + Escape" to cancel "all" running scripts.

                                                                                                              Rock on!

                                                                                                              1. RRafael Villafane @Rafael_Villafane
                                                                                                                  2022-12-13 06:15:31.918Z2022-12-13 08:40:01.379Z

                                                                                                                  Thanks again @Kitch and @samuel_henriques!

                                                                                                                  I don't have the script to stop/start the "OpenPluginFollowTrackSelection" Run Forever script". Is that a separate command, or would it be part of the same command? Meantime i will do "Control + Shift + Escape".

                                                                                                                  Again, thank you so much... you just turbocharged both SSL controllers. Incredible. This is huge (for me at least). I hope SSL is watching.

                                                                                                                  BTW for your other UC1/UF8 users, there's a PT command (CTRL+SHIFT+ mouse click on PT track name) that will force UF8 to look at that track in Pro Tools. So that, + your commands are about as close to automatic track follow as it gets, i'm kind of shocked. I'm new to Soundflow but i can guarantee i have seen no better customer service in the industry than you all, and i've been around for awhile.

                                                                                                                  1. In reply toKitch:
                                                                                                                    samuel henriques @samuel_henriques
                                                                                                                      2022-12-13 09:34:41.350Z2022-12-13 09:52:16.473Z

                                                                                                                      It could be the run forever, I couldn't find another way to make it fail.
                                                                                                                      Just updated the ones I posted with a stop function. When you run once it works, when you run it again it will stop.
                                                                                                                      @Rafael_Villafane post away as you want, this is indeed a cool script, but I can't call it mine as if I remember Christian made the base for this (the run forever bit) and I've been adapting it as needed.

                                                                                                                      1. RRafael Villafane @Rafael_Villafane
                                                                                                                          2022-12-13 18:06:42.953Z

                                                                                                                          Thank you again Samuel, will try your script with start/stop tonight. Please thank Christian for me if you get a chance. You guys rock, thanks a million.

                                                                                                                          1. RRafael Villafane @Rafael_Villafane
                                                                                                                              2022-12-15 02:29:17.565Z2022-12-15 02:43:00.710Z

                                                                                                                              @samuel_henriques Hi Samuel, just tried your script with the stop function. When i run it, it opens both plugins fine. When i run it again, it stops opening 4KB but continues to open CS2. When i run "Stop All Running Commands", it does stop both plugs from opening. Am i doing something wrong?

                                                                                                                              Thank you sir.

                                                                                                                              1. RRafael Villafane @Rafael_Villafane
                                                                                                                                  2022-12-15 02:41:45.711Z

                                                                                                                                  @samuel_henriques Please disregard the previous message (about 4KB stopping, but not CS2). I shut Pro Tools down, rebooted and it all works fine. Sorry sir!

                                                                                                                                  1. samuel henriques @samuel_henriques
                                                                                                                                      2022-12-15 03:03:50.405Z

                                                                                                                                      awesome!
                                                                                                                                      btw, with this version if you decide you need more plugins to open, just add more names, separated with commas with name between quotes.

                                                                                                                                      1. RRafael Villafane @Rafael_Villafane
                                                                                                                                          2022-12-16 17:04:38.473Z

                                                                                                                                          Thank you @samuel_henriques! If SSL releases another channel strip i'll do that! Other than that scenario i can't foresee needing to open any other plugins that way, but thank you so much for the tip! BTW i have a good friend who is a well known acoustician down here and also does a lot of post work. Have told him about SoundFlow. Thank you all so much for your help, it really was a game changer.

                                                                                                                                          1. samuel henriques @samuel_henriques
                                                                                                                                              2022-12-16 18:02:54.929Z

                                                                                                                                              Awesome!

                                                                                                                                              1. hi forum - Thank you @Rafael_Villafane for turning me onto this thread via Gearspace.

                                                                                                                                                Complete rookie/idiot when it comes to this stuff. So from what I understand using the above script will allow what I'm trying to do in Pro Tools. Couple quick questions before I dive in....
                                                                                                                                                A) Do I need the Pro version of Soundflow or will the Avid version work?
                                                                                                                                                B) Are 'triggers' start/stop of this command pretty self explainable once I setup Soundflow?

                                                                                                                                                Just trying to see what I'm diving into here, before I screw anything up and make my workflow even harder. LOL. Thank you in advance and happy holidays :)

                                                                                                                                                1. RRafael Villafane @Rafael_Villafane
                                                                                                                                                    2022-12-21 00:06:30.766Z2022-12-25 08:12:48.712Z
                                                                                                                                                    1. If you have a subscription with Avid, the Avid version is free - and it comes with a pretty long demo period of the Pro version. If you want to use Iphone/Ipad or Stream Deck you will need the Pro version - you can experiment with the demo. If you just need triggers (Macros on your keyboard) you'll do fine with the Avid version, but you won't have access to the store (users, some of them famous, offer ready made commands, etc.) . My suggestion is to get the Avid version (which comes with the Pro demo) and before the demo is done you'll know if you need the Pro version.

                                                                                                                                                    2. If you copy/paste @Samuel_Henriques script to a new command and make a trigger, when you click the trigger (which is defined by you) the command will work - when clicked again it will stop. Watch this video: https://www.youtube.com/watch?v=keu057Byy6A

                                                                                                                                                    I'm a newb myself but if you get stuck i'll be happy to help you, at least with this command, which IMO is a Godsend for anyone with UC1/UF8 and Protools. BTW there are several videos like the one on the link on youtube which cover what you can do with Soundflow!

                                                                                                                                                    Cheers!

                                                                                                                                                    1. Thank you so much Rafa I will follow your guidance here, and report back if I get lost. Glad to know that the Avid version will suffice... So once the 'pro' version trial expires... does the script stay in place? Or would I have to subscribe at that point? Much appreciated and happy holidays to all -Anthony

                                                                                                                                                      1. RRafael Villafane @Rafael_Villafane
                                                                                                                                                          2022-12-22 06:20:08.196Z2022-12-24 03:13:50.187Z

                                                                                                                                                          @califloridaproductio 99% sure the triggered commands keep working on the Avid version, but i suggest you play with the pro version on Iphone/Ipad or Streamdeck. If you're a guy that uses many shortcuts, pushing 1 labeled button is a lot easier than remembering and typing bunches of trigger commands on your keyboard. Just from playing with the pro version, i get why people go for it. I think it's $9 a month and if you leave town for awhile you can pause your subscription, so there's no paying for 'dead' time. Their customer service is pretty unbelievable as well. Sorry if i sound like an ad bro, but SF rocks. Cheers.

                                                                                                                                      2. RRafael Villafane @Rafael_Villafane
                                                                                                                                          2022-12-24 04:26:51.622Z2022-12-24 09:05:15.923Z

                                                                                                                                          @samuel_henriques Hi Samuel, for some reason the 'open plugin name follow track selection' command stopped working. When i select a track it no longer opens the plugin. When i run the command again, the "stop: OpenPluginNameFollowTrackSelection" message does appear, but when i run it again, nothing happens. It worked flawlessly til tonight, so i deleted the command, made a new one with the same same trigger and nothing. I tried bypassing and reopening Soundlfow, quitting and restarting Soundflow, shutting down and rebooting the computer and nothing. Have been at it for over an hour. I'm sure it's operator error but i can't figure out why - any help would really be appreciated! Thank you for your time sir.

                                                                                                                                          1. samuel henriques @samuel_henriques
                                                                                                                                              2022-12-24 09:17:13.926Z

                                                                                                                                              Hello Rafael, could you make a screen recording of it failing please?

                                                                                                                                              1. RRafael Villafane @Rafael_Villafane
                                                                                                                                                  2022-12-25 03:50:59.489Z2022-12-25 19:02:28.611Z

                                                                                                                                                  @samuel_henriques Hi Samuel, went to the studio awhile ago, booted up and the command worked perfectly. All i did was shut down last night - booted up today and it worked. Last night i did shut down as well, but when i booted up it didn't work. So sorry to take your time with this. Should i delete the message i wrote last night, to not confuse the others who might be reading? I'm on Mojave... beginning to think that might be a problem. Thank you and so sorry to take your time. May you and the entire Soundflow family have wonderful holidays.

                                                                                                                                                  1. samuel henriques @samuel_henriques
                                                                                                                                                      2022-12-26 17:23:54.815Z

                                                                                                                                                      I think it's ok. Hopefully it's fixed now.

                                                                                                                                                • Hi gents back here with some issues 🫠 I had the following working fine early last year on my i9 MBP.

                                                                                                                                                  1. Clicking a track name in Pro Tools (on mix window) would bring up any SSL channel strip (SSL 4KE, 4KB, Channel Strip 2, PA 9000J and Waves 4KE)

                                                                                                                                                  2. Clicking a track name in Pro Tools (on mix window) would focus to that track in the edit window, and also my SSL UF* Faders would bank to that track.

                                                                                                                                                  3. If I'm not mistaken I had it working where track would focus, and faders would bank by pressing select button on my UF8 as well. (not 100% sure though if I always had to click the track name on my screen.) Getting old LOL

                                                                                                                                                  Sometime last year with the latest PT updates, the banking was no longer working. Now, nothing is working with the original script.... as I recently upgraded and did a fresh install of everything on a Mac Studio M2 Ultra.

                                                                                                                                                  Any ideas what may have changed, how to diagnose, and get this working again?

                                                                                                                                                  *Also another strange issue I'm getting.... frequently Pro Tools will not keep a menu bar folder list open after clicking. (Meaning for example I click File at top of menu bar and normally the File menu options appear and stay on the screen. Now I click and it's open, but closes by the time I can select anything in the menu.) This only happens with SoundFlow open, and I can fix it by restarting Pro Tools... but often the behavior will appear again after a short while.

                                                                                                                                                  If it helps PT 2024.3.1
                                                                                                                                                  Sonoma 14.5
                                                                                                                                                  100% silicon native (no rosetta)

                                                                                                                                                  1. Chad Wahlbrink @Chad2024-06-10 14:43:42.187Z

                                                                                                                                                    Hey @califloridaproductio!

                                                                                                                                                    I have not had a chance to check out updating Samuel's script just yet. However, I did want to note that we are tracking an issue with "runForever" scripts, like the one in this thread, on macOS Sonoma 14.5. I believe the "strange behavior" you mentioned at the end of your post is related to scripts using that mechanism.

                                                                                                                                                    Significant changes to context menus in Pro Tools 2024.3 were made to make broader functionality work with Sonoma. RunForever scripts seem to work correctly on Ventura, so it seems to be a Sonoma-specific change.

                                                                                                                                                    This thread will be updated with any updates on changing this behavior on Sonoma.

                                                                                                                                                    Best,
                                                                                                                                                    Chad

                                                                                                                                                    1. Hi Chad :) Thanks for the response appreciate it!
                                                                                                                                                      I'm pretty much dead in the water here using SoundFlow, hopefully @samuel_henriques can pop through and take a look at the script, and your team will find the Sonoma bugs.

                                                                                                                                                      I have a sub active until end of month, I had just reactivated my subscription as I was working on this.... since my Avid trial had run out. If there's anything you can do while I wait for a fix would be super grateful! 🙏

                                                                                                                                                      1. Chad Wahlbrink @Chad2024-06-10 20:30:45.342Z

                                                                                                                                                        If you can post the version of the script you currently use, I can try it on my Sonoma system.

                                                                                                                                                        The context menu behavior you noted on Sonoma will make this script a bit challenging, but we will update this thread once we have made some headway on those Sonoma-specific issues. It may still be usable if you'd be willing to toggle it on and off. Note that most of SoundFlow's functionality currently works with Sonoma, but this specific script (along with a handful of others like it) is the outlier. Also, for anyone else reading this, runForever scripts like this should still work on Monterey and Ventura.

                                                                                                                                                        As for banking tracks, does adjusting any of these settings help with that? If "Scroll to Track" Banks Controllers is selected, you should be able to bank by Shift+Control Clicking a track name.

                                                                                                                                                        1. Thanks so much for the quick reply - I'm trying to use the same script from Dec 13, 2022 from Samuel above. Only change was I added a couple more plugins on my old system in the top pluginNames section.

                                                                                                                                                          Per the scrolling yes I have that checked, and indeed Shift/Ctrl/click banks. Is it possible to make a Macro that will bank with one-click... (I tried using the Select button Midi CC#15 on the SSL UF8 to no avail. Also haven't had luck trying other keystrokes, or combos. I tried using SoundFlow, Pro Tools Key Shortcuts, and Apple's on Key shortcuts menu and haven't found an adequate solution yet. There was a point on my i9 where I would click the track name in the mixer window and UF8 scrolll... :(
                                                                                                                                                          I had all this setup a couple years ago after days of DEEP Diving and tweaking... now jumping back in I'm lost LMAO Appreciate this forum, and SoundFlow... tempting me to get a StreamDeck for real!

                                                                                                                                                          1. samuel henriques @samuel_henriques
                                                                                                                                                              2024-06-10 22:36:49.201Z

                                                                                                                                                              Hello, i just tried it on Ventura and still works. (this one, Open plugin by name triggered by track selection #post-29).
                                                                                                                                                              So It might really be the Sonoma issue @Chad is referring to. Unfortunately I don't have any Sonoma to try it on.

                                                                                                                                                              1. Chad Wahlbrink @Chad2024-06-12 17:11:31.577Z

                                                                                                                                                                Hey @califloridaproductio!

                                                                                                                                                                Can you please ensure that there are no errors in the plugin names declared at the top of the script?

                                                                                                                                                                // Do all of these spellings match what shows in the Pro Tools plugin menu for you? 
                                                                                                                                                                const pluginNames = ['SSL Native Channel Strip 2', 'SSL 4K B'];
                                                                                                                                                                

                                                                                                                                                                The script seems to work as expected, except for that Sonoma specific bug where it conflicts with the right click context menus that I mentioned before (again, we are tracking that, but don't have an official timeline to fix it).

                                                                                                                                                                Here's a video from my Sonoma system:

                                                                                                                                                                1. Chad Wahlbrink @Chad2024-06-12 17:18:41.132Z

                                                                                                                                                                  As for banking with a single action, you can bank to the selected track with this:

                                                                                                                                                                  // Bank to the selected track in Pro Tools
                                                                                                                                                                  sf.ui.proTools.selectedTrack.titleButton.mouseClickElement({ isControl: true, isShift: true, relativePosition:{x:5, y:5}});
                                                                                                                                                                  

                                                                                                                                                                  Or, if your mouse supports it, you could set up "mouse button 3" to select and bank using one click from an extra mouse button:

                                                                                                                                                                  // Get Current Mouse Position
                                                                                                                                                                  const currentMouse = sf.mouse.getPosition().position;
                                                                                                                                                                  // Click at Current Mouse Position with Control and Shift
                                                                                                                                                                  sf.mouse.click({position:currentMouse, isControl:true, isShift:true,  });
                                                                                                                                                                  
                                                                                                                  2. S
                                                                                                                    In reply toJoel_K:
                                                                                                                    SoundFlow Bot @soundflowbot
                                                                                                                      2024-06-09 22:07:12.458Z

                                                                                                                      This report was now added to the internal issue tracked by SoundFlow as SF-1189

                                                                                                                      1. S
                                                                                                                        In reply toJoel_K:
                                                                                                                        SoundFlow Bot @soundflowbot
                                                                                                                          2024-10-29 00:40:45.888Z

                                                                                                                          Linked issue SF-1189 updated: The bug in which Pro Tools context/popup menus could disappear if a SoundFlow script (or any other software) would be sending a message to Pro Tools, has been fixed in Pro Tools 2024.10.

                                                                                                                          1. S
                                                                                                                            In reply toJoel_K:
                                                                                                                            SoundFlow Bot @soundflowbot
                                                                                                                              2024-10-29 00:41:09.314Z

                                                                                                                              The linked internal issue SF-1189 has been marked as Done