No internet connection
  1. Home
  2. Support

How to verify if an audio suite plugin is already open?

By Dustin Harris @Dustin_Harris
    2019-10-01 20:12:32.840Z

    Hi! I'm working on a script that opens the RX7 connect plugin, but I want to make an if statement that skips opening the plugin if it's already open. How do I verify if the window is not open?
    would it be:
    (sf.ui.proTools.getFloatingWindowWithTitleStartingWith("Audio Suite: RX 7 Connect") == null)
    ?

    Thanks!
    Dustin

    Solved in post #4, click to view
    • 9 replies
    1. Dustin Harris @Dustin_Harris
        2019-10-01 23:28:16.051Z

        Found it by creepin' on other plugins!

        var panel = sf.ui.proTools.getFloatingWindowWithTitleStartingWith("Audio Suite: RX 7 Connect");
        if (panel.exists) throw 'RX7 Connect is already open';

        1. Great Dustin - thanks for posting the solution :)

          1. Christian Scheuer @chrscheuer2019-10-02 07:18:27.416Z2019-10-02 16:59:19.820Z

            You can also do this:

            var asWin = sf.ui.proTools.getAudioSuiteWindow("RX 7 Connect");
            if (!asWin.exists) {
                asWin = sf.ui.proTools.audioSuiteOpenPlugin({
                    category: "Noise Reduction",
                    name: "RX 7 Connect",
                }).window;
            }
            
            //Now you can use asWin as expected...
            asWin.audioSuiteSelectPreset({
                presetMenuPath: ['.....']
            });
            asWin.audioSuiteSetOptions({
                processingInputMode: 'ClipByClip',
                processingOutputMode: 'CreateIndividualFiles',
            });
            asWin.audioSuiteRender();
            
            Reply1 LikeSolution
            1. Dustin Harris @Dustin_Harris
                2019-10-02 10:37:19.451Z

                Oh that is way more functional! Thanks!!

                1. In reply tochrscheuer:
                  Dustin Harris @Dustin_Harris
                    2019-10-02 14:32:42.846Z

                    Ok so interestingly, the above code seems to always return !asWin.exists = true. In my example the last step in opening the plugin is to toggle the target button (to keep the plugin open). When I run the code several times I get several instances of RX7 Connect on top of each other. Maybe I'm doing something wrong though?

                    sf.ui.proTools.appActivateMainWindow();

                    var asWin = sf.ui.proTools.getAudioSuiteWindow("Audio Suite: RX 7 Connect");
                    if (!asWin.exists) {
                    asWin = sf.ui.proTools.audioSuiteOpenPlugin({
                    category: "Noise Reduction",
                    name: "RX 7 Connect",
                    }).window;
                    }
                    //else {}
                    asWin.audioSuiteSetOptions({
                    processingInputMode: "ClipByClip",
                    processingOutputMode: "CreateIndividualFiles",

                    });
                    asWin.buttons.whoseTitle.is('Target button').first.elementClick();

                    I tried wrapping the text in a code block, hopefully it works? :)

                    1. Thanks @Dustin_Harris, that's my bad. There was a mistake in the first line (I've edited the script now)

                      The first line should be:

                      var asWin = sf.ui.proTools.getAudioSuiteWindow("RX 7 Connect");
                      
                      1. Dustin Harris @Dustin_Harris
                          2019-10-02 20:39:22.637Z

                          I must be doing something wrong, even with the amended command, !asWin.exsists is always true, and new windows always open.

                          // make pro tools the active window sf.ui.proTools.appActivateMainWindow();

                          // check if the plugin is already open
                          var asWin = sf.ui.proTools.getFloatingWindowWithTitleStartingWith("RX 7 Connect");
                          if (!asWin.exists){
                          // Verify if IF statement is triggered
                          log('If Statement triggered');

                          //open plugin as var asWin is not existing
                          var asWin = sf.ui.proTools.audioSuiteOpenPlugin({
                              category: 'Noise Reduction',
                              name: "RX 7 Connect"
                              }).window;
                          
                          }
                          

                          //if not, open the plugin and save the plugin window to the "asWin" variable

                          else{}
                          asWin.audioSuiteSetOptions({
                          processingInputMode: "ClipByClip",
                          processingOutputMode: "CreateIndividualFiles",

                          });
                          asWin.buttons.whoseTitle.is('Target button').first.elementClick();


                          `
                          EDIT

                          OF COURSE I figured it out 30sec after I hit send on the last message. replace getFloatinWindow... with getAudioSuiteWindow :)

                          1. ZZach McNees @Zach_McNees
                              2024-01-06 20:17:06.817Z

                              I can't quite seem to get this working with an Auto Align Post macro. It's working great, but it keeps opening a new instance of AAP every time, when I'd prefer it just check if there's one open first. Did anyone successfully get this working? Here's my current code:

                              // get window
                              var asWin = sf.ui.proTools.getAudioSuiteWindow("Auto-Align Post");

                              //Open the plugin
                              asWin = sf.ui.proTools.audioSuiteOpenPlugin({
                                  category: 'Other',
                                  name: "Auto-Align Post"
                              }).window;

                              //Set processing options
                              asWin.audioSuiteSetOptions({
                                  processingInputMode: "ClipByClip",
                                  processingOutputMode: "CreateIndividualFiles"
                              });

                              // // Set Handle length to 4
                              // asWin.textFields.whoseTitle.is('Processing Handle Length in Seconds').first.elementClick();
                              // sf.keyboard.type({
                              // text: "4",
                              // });
                              // sf.keyboard.press({
                              // keys: "return",
                              // });

                              //Select Key Input
                              sf.ui.proTools.firstAudioSuiteWindow.popupButtons.whoseTitle.is('Key Input').first.popupMenuSelect({
                              menuPath: ["1 DIA 1"],
                              });

                              ///Analyze
                              // asWin.getFirstWithTitle("Analyze").elementClick();

                              ///Wait till analyze done
                              // sf.ui.proTools.waitForNoModals();

                              //Render
                              asWin.audioSuiteRender();

                              // // Close Window
                              // sf.ui.proTools.viewCloseFocusedFloatingWindow();

                              1. Dustin Harris @Dustin_Harris
                                  2024-01-06 20:42:11.503Z

                                  here's how I'm doing that same thing... adjust the end of it to suit your needs in terms of key input and processing modes :)

                                      let asWin = sf.ui.proTools.getAudioSuiteWindow('Auto-Align Post');
                                  
                                      if (!asWin.exists) {
                                  
                                          function getCategoryName() {
                                              let flatCategories = sf.ui.proTools.getMenuItem('AudioSuite').children.first.children.allItems;
                                              let categories = flatCategories.map(n => n.title.value);
                                              let manufacturerView = categories.includes('Sound Radix');
                                              return (manufacturerView) ? 'Sound Radix' : 'Other';
                                          }
                                  
                                          asWin = sf.ui.proTools.audioSuiteOpenPlugin({
                                              category: getCategoryName(),
                                              name: "Auto-Align Post"
                                          }).window;
                                      }
                                  
                                      while (!asWin.exists) sf.wait({ intervalMs: 50 });
                                  
                                  
                                      asWin.audioSuiteSetOptions({
                                          processingInputMode: "EntireSelection",
                                          processingOutputMode: "CreateContinuousFile",
                                      });