No internet connection
  1. Home
  2. How to
  3. Pro Tools

Pro Tools Main Output Window Name

By Kostas Stylianou @Kostas_Stylianou
    2024-06-16 13:03:31.437Z

    hi, i want to create a script that checks if the Main Output Window is Pro Tools is open and if it is not it opens it for the selected track. I tried to use a code that works for Izotope RX Modules but i think i dont have the correct name for the Output Window and i dont know how to get the correct name. Here is the code:

    const trackOutputWindow = sf.ui.proTools.windows.whoseTitle.is("MainTrackOutputWindow").first;

    if (trackOutputWindow.exists) {

    }
    else {

    //Calling command "Open Track Output Window" ProTools Package
    sf.soundflow.runCommand({
        commandId: 'user:ckp49i4j60000a2100yfwywgf:ckou1qcq600a8zv108tupvk6b',
        props: {}
    });
    

    }

    Is there a way to get the name of the window, or should i change my approach?
    also when i run the command it goes to the else part without giving me any errors

    Solved in post #2, click to view

    Linked from:

    1. Platane Joystick
    • 6 replies
    1. Hey @Kostas_Stylianou,

      Something simple like this should do:

      if (!sf.ui.proTools.mainTrackOutputWindow.exists) {
          sf.ui.proTools.selectedTrack.trackOutputToggleShow();
      }
      
      ReplySolution
      1. KKostas Stylianou @Kostas_Stylianou
          2024-06-17 09:59:23.912Z

          thanks, it works as expected. But now i have another question is there a way to see if the open "mainTrackOutputWindow" corresponds to the selected track? Because i want to add an "else" to the if statement you made that checks if the "mainTrackOutputWindow" is the one for the selected track and if not then it should use the "sf.ui.proTools.selectedTrack.trackOutputToggleShow();" action to open it. Thanks again for your time and effort.

          1. Chad Wahlbrink @Chad2024-06-17 15:10:10.381Z

            Hey @Kostas_Stylianou!

            You can accomplish this by using the built in command for "Open Track Output Window" in the Pro Tools Package > Track Input, Output, & Pan.

            This command ensures the track output window is shown for the current selected track via the code:
            
            if (!sf.ui.proTools.isRunning) throw `Pro Tools is not running`;
            
            sf.ui.proTools.appActivateMainWindow();
            
            sf.ui.proTools.selectedTrack.trackOutputToggleShow();
            
            
            As an example, the following code is a more manual way of checking the conditions you are asking about, but `sf.ui.proTools.selectedTrack.trackOutputToggleShow();` essentially does all of these steps automatically.
            
            if (!sf.ui.proTools.isRunning) throw `Pro Tools is not running`;
            
            sf.ui.proTools.appActivateMainWindow();
            sf.ui.proTools.mainWindow.invalidate();
            
            let outputWin = sf.ui.proTools.mainTrackOutputWindow; 
            
            // Current Track Name
            let currentTrack = sf.ui.proTools.selectedTrack.invalidate().normalizedTrackName;
            
            // If output window doesn't exist, open it. 
            if (!outputWin.exists) {
                sf.ui.proTools.selectedTrack.trackOutputToggleShow();
            } 
            // Else if output window is open, and current track name doesn't match the name associated with the output window, then open the output window for the current track
            else if (outputWin.exists && currentTrack !== sf.ui.proTools.mainTrackOutputWindow.buttons.whoseTitle.startsWith("Track selector").first.value.value){
                sf.ui.proTools.selectedTrack.trackOutputToggleShow();
            }
            
            1. Chad Wahlbrink @Chad2024-06-17 15:16:11.231Z

              You may also like this built-in command to have the Output Window Follow the Selected Track:

              This is found in Pro Tools Package > Views & Windows > Output Window: Follow Selected Track. Once you run this script, it will remain active until you quit and restart SoundFlow (or your computer), or you run the "Stop All Running Commands" command:

              Side note: the Output Window: Follow Selected Track command currently has some bugs on Sonoma that the team is following.

              1. KKostas Stylianou @Kostas_Stylianou
                  2024-06-19 10:09:50.584Z2024-09-12 03:15:33.299Z

                  Hi, i tested the 2nd script you gave me in your last reply and it is perfect for me. So thank you very very much. Before i wrote about this topic i had tested the "Output Window: Follow Selected Track" command and it did not fit my needs because the only way to stop the Output Window form popping up was to restart soundflow, which is not ideal for me. So i tried to change it a bit with some scripts that i saw in another thread, but it did not work as expected.
                  This is the code for the main action:

                  var lastFocusedTrackName;
                  
                  function main() {
                      try {
                  
                          if (globalState.autoOpenSelectedTrackOutputPanMixerPaused) return;
                  
                          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' });
                  
                      } 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("isFollowFocusedTrackRunning", main, 500, 5000);
                  

                  and the change is this part:

                  if (globalState.autoOpenSelectedTrackOutputPanMixerPaused) return;
                  

                  and the helper scripts for enabling or disabling it are this:

                  globalState.autoOpenSelectedTrackOutputPanMixerPaused = true;
                  

                  and this:

                  globalState.autoOpenSelectedTrackOutputPanMixerPaused = false;
                  

                  I used them in with separate triggers for each of the 3 parts.

                  and although the main script was running fine, i had to press the triggers for stopping several times before it stoped and once it stoped i wasn't able to get it running again unless i restarted soundflow. This is why i went the more manual way. Also my OS is Sonoma 14.4 so this might be the problem. Im happy now with what you created and i'm considering doing something similar for the sends. if i need any help ill contact you.

                  thanks again for the help

                  1. Chad Wahlbrink @Chad2024-06-19 18:24:20.516Z

                    Hey @Kostas_Stylianou!

                    I'm glad the script I shared was helpful.

                    For future posts, view this tutorial on sharing code on the forum:
                    How to quote code in the SoundFlow forum.

                    ↑ Formatting helps keep the code excerpts clearer for everyone.

                    The script you just shared seems to work as expected on macOS 12.7.5. I could try using it on Sonoma 14.4 next time I use that machine.

                    But yes, as mentioned previously, we are currently monitoring a bug with some runForever-style scripts in Sonoma. As such, if you are running Sonoma, I'd suggest avoiding runForever scripts for the time being– unless you are comfortable manually stopping all running commands and restarting the runforever script as you work.