No internet connection
  1. Home
  2. How to

Track Output window follow track selection

By samuel henriques @samuel_henriques
    2020-09-09 15:54:02.519Z

    Hello,
    I'm using this script to keep the track output window open and changing to the last selected track, and works fine.
    Could anyone help me change it so it would;

    1.work only if the Output window is open; at this time if the window is closed it opens it;
    2: only on any track that start with these words; a loose thing, I guess
    " _MUSICA" and " _FX".

    Thank you so much

    var lastFocusedTrackName;
    
    function main() {
        try {
    
            var newName = sf.ui.proTools.selectedTrackNames[0];
            if (newName === lastFocusedTrackName || newName === undefined) return;
    
            lastFocusedTrackName = newName;
    
            sf.ui.proTools.selectedTrack.trackOutputToggleShow();
            
            
    
        } 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("isScrollToFocusedTrackRunning", main, 500, 5000);
    
    
    Solved in post #7, click to view
    • 15 replies
    1. Just clarifying..
      So what should happen if the track output window is open and you're on a "_FX.." track but you move to a track that's not a "_FX" track. Should it then close the output window? Or just not change the output window and leave it open?

      1. samuel henriques @samuel_henriques
          2020-09-09 16:12:53.452Z

          Hey Christian,
          Forgot that one.
          I would like it to stay open.
          for example, I can select an _FX and if I click a dialog the _FX 's output window will still be there.
          Thank you, that was fast

          1. Ok, so to be sure, you just want the script changed so that it doesn't open the track output window?

            1. You should be able to change this:

               sf.ui.proTools.selectedTrack.trackOutputToggleShow();
              

              To this:

              if (sf.ui.proTools.mainTrackOutputWindow.invalidate().exists && sf.ui.proTools.selectedTrack.outputWindowButton.value.invalidate().value !== 'open')
                  sf.ui.proTools.selectedTrack.trackOutputToggleShow();
              
              
              1. samuel henriques @samuel_henriques
                  2020-09-09 17:21:01.406Z

                  Perfect that's one of the things.
                  Now, when its open, only follow the track selection of tracks whose name start with " _MUSICA" and " _FX".

                  thank you

                  1. Then, change it to:

                    if (sf.ui.proTools.mainTrackOutputWindow.invalidate().exists && sf.ui.proTools.selectedTrack.outputWindowButton.value.invalidate().value !== 'open' && (newName.indexOf(' _MUSICA') == 0 || newName.indexOf(' _FX') == 0))
                        sf.ui.proTools.selectedTrack.trackOutputToggleShow();
                    
                    ReplySolution
                    1. samuel henriques @samuel_henriques
                        2020-09-09 17:36:36.574Z

                        Sorry, It's not following any now.

                        thank you for your patience

                        1. It's likely you need to adjust the names as quoted in the script. You put them as a space followed by an underscore and then the letters. If you didn't mean to put in a space, remove it in the script.

                          1. samuel henriques @samuel_henriques
                              2020-09-09 17:54:04.366Z

                              Awesome !!!!

                              Thank you so much

                      • In reply tochrscheuer:
                        NN Leyers @NickLeyers_old_acc
                          2020-12-02 10:20:40.325Z

                          I like the idea of this script. I use the main script as well, but have extra macro's to bypass the script. A little bulcky compared to this: open or close the output window.
                          But if I add this line to my script, I'm getting this error: Could not get UIElement for AxPtMainTrackOutputWindow: Could not find floating window for track output

                          I don't know why it does that, but I think it has got something to do with focussing on my edit screen. Is it possible that stream decks take of focus of the edit screen when I assign them to change on window triggers? Or is it something else?

                          1. NN Leyers @NickLeyers_old_acc
                              2020-12-02 12:08:47.111Z

                              Found it. My track view window at the left was hidden. For another reason I have to figure out, it keeps hiding itself randomly :-)

                    2. Erik Griekspoor @Erik_Griekspoor
                        2021-12-29 14:50:14.914Z

                        This is a great script! Is there a way to cancel just this script when its running?

                        1. I seem to remember there's another thread somewhere that has a companion script to go with it where you can toggle the behavior on/off.

                          1. Erik Griekspoor @Erik_Griekspoor
                              2021-12-30 13:03:12.269Z

                              Ok thanks, I can't find it though, can you?

                              1. Change the main function to:

                                function main() {
                                    try {
                                        if (globalState.isFollowTrackOutputBypassed) return;
                                
                                        var newName = sf.ui.proTools.selectedTrackNames[0];
                                        if (newName === lastFocusedTrackName || newName === undefined) return;
                                
                                        lastFocusedTrackName = newName;
                                
                                        sf.ui.proTools.selectedTrack.trackOutputToggleShow();
                                        
                                        
                                
                                    } catch (err) {
                                    }
                                }
                                

                                And then for the bypass toggling script:

                                globalState.isFollowTrackOutputBypassed = !globalState.isFollowTrackOutputBypassed;