No internet connection
  1. Home
  2. How to

How to close only window the target button is enabled?

By Yujiro Yonetsu @Yujiro_Yonetsu
    2021-09-05 04:40:18.710Z

    Hello, teachers!

    I have several plugin windows open, and I only want to close the one with the target button enabled.
    What are the possible methods?

    I tried

    
    var tartgetStatus = sf.ui.proTools.windows.whoseTitle.is("Plug-in: FabFilter Pro-Q 3").first.buttons.whoseTitle.is("Target button").first.value.invalidate().value;
    
    log(targetStatus)
    
    

    When I try this, the status does not show anything, so does the target button not have a value?

    Please let me know if you have a solution.

    Best regards.

    Solved in post #9, click to view
    • 12 replies
    1. Kitch Membery @Kitch2021-09-09 21:50:00.983Z

      Hi @Yujiro_Yonetsu

      Unfortunately you are correct in your findings. Pro Tools does not report the target button's "Selected" state. :-(

      1. In reply toYujiro_Yonetsu:
        samuel henriques @samuel_henriques
          2021-09-10 12:16:50.872Z2021-09-10 12:25:21.050Z

          Hello Yujiro,

          Unfortunately, that's the case.

          Now, if you want do close all but one audioSuite window.
          Select/ focus the one you want to keep open and run this script.
          It will close all audioSuite windows not selected/ focused
          If any of the windows is the same plugin as the one you want to keep open, all the instances of that plugin won't close.

          sf.ui.proTools.appActivateMainWindow()
          
          const selectedAudiosuite = sf.ui.proTools.firstAudioSuiteWindow.title.invalidate().value
          
          sf.ui.proTools.floatingWindows.whoseTitle.startsWith('Audio Suite').allItems.forEach(function (win) {
              try {
                  if (win.title.value != selectedAudiosuite) {
                      win.windowClose();
                  }
              } catch (err) { }
          });
          
          1. Yujiro Yonetsu @Yujiro_Yonetsu
              2021-09-11 03:02:33.194Z

              Thank you for your answer!

              But what I want to do is not about the Audio suite, but about the insert plugin window.
              Is there any way to apply this?

              1. samuel henriques @samuel_henriques
                  2021-09-11 09:06:17.630Z

                  here you go, this will close all but the first / focused plug-in

                  sf.ui.proTools.appActivateMainWindow()
                  
                  const [focusedPlug, ...others] = sf.ui.proTools.floatingWindows.whoseTitle.startsWith('Plug-in:').map(x => x)
                  
                  
                  others.forEach(function (win) {
                      try {
                          win.windowClose();
                      } catch (err) { }
                  });
                  
                  1. Yujiro Yonetsu @Yujiro_Yonetsu
                      2021-09-11 16:27:05.128Z

                      Thank you.

                      I verified the script I was taught.
                      I'm still trying to figure out that script.

                      However, the movement seems to be the opposite of what I want.
                      How can I use the script you gave me to make it work the other way around?
                      I want to close only the plugin window that is in focus.

                      Please teach me!!!

                      1. samuel henriques @samuel_henriques
                          2021-09-11 18:23:17.511Z

                          Hello Yujiro,
                          I apologise, completely misread your first post.

                          try this,
                          sf.ui.proTools.floatingWindows.whoseTitle.startsWith('Plug-in:').first.windowClose()

                          Reply1 LikeSolution
                          1. Yujiro Yonetsu @Yujiro_Yonetsu
                              2021-09-11 23:49:00.836Z

                              Thank you!

                              But, This will close all the plugin windows.
                              What I want to do is to close only the focused plugin window.

                              In this case, I have a meter plug-in that is always visible on the edge of the screen with the target button off.
                              Then when I do an insert or something while working, a new plugin window opens.
                              I only want to close that window, and leave the metering system visible.

                              Would I be able to do that?

                              1. samuel henriques @samuel_henriques
                                  2021-09-11 23:55:45.661Z

                                  On mine, this last script is closing only the foremost one.

                                  But if you want to close all except that meter one, I guess we could do something to close all except the one with that name.
                                  Witch one is it?

                                  1. samuel henriques @samuel_henriques
                                      2021-09-12 00:01:25.978Z

                                      here, try this,

                                      with this one, it doesn't matter whats selected/focused
                                      just change the plug-in name with the one you want open

                                      
                                      sf.ui.proTools.appActivateMainWindow()
                                      
                                      const openedPlugins = sf.ui.proTools.floatingWindows.whoseTitle.startsWith('Plug-in:').map(x => x)
                                      
                                      
                                      openedPlugins.forEach(function (win) {
                                          try {
                                      if (win.title.invalidate().value != "Plug-in: FabFilter Pro-Q 2")
                                              win.windowClose();
                                          } catch (err) { }
                                      });
                                      
                                      1. Yujiro Yonetsu @Yujiro_Yonetsu
                                          2021-09-12 14:59:49.333Z

                                          Thank you again and again.

                                          How do I describe this so that I don't close multiple plugins?

                                          I tried this

                                          const openedPlugins = sf.ui.proTools.floatingWindows.whoseTitle.startsWith('Plug-in:').map(x => x)
                                          
                                          
                                              openedPlugins.forEach(function (win) {
                                                  try {
                                                      if (win.title.invalidate().value != "Plug-in: FabFilter Pro-Q 3" || "Plug-in: NUGEN MasterCheck")
                                                          win.windowClose();
                                                  } catch (err) { }
                                              });
                                          

                                          However, this did not work.

                                          And seems like it would work this way, though.
                                          You said...

                                          sf.ui.proTools.floatingWindows.whoseTitle.startsWith('Plug-in:').first.windowClose()
                                          

                                          I'm wondering why this script doesn't cause only the foremost one to close in my environment...

                                          1. samuel henriques @samuel_henriques
                                              2021-09-12 15:41:27.185Z2021-09-12 17:50:28.419Z

                                              Not sure why we are getting different behaviour.

                                              I'm away from my computer, I hope this makes sense, to chose more than one to keep open

                                              if (win.title.invalidate().value != "Plug-in: FabFilter Pro-Q 3" || win.title.invalidate().value !=  "Plug-in: NUGEN MasterCheck")
                                              
                                              1. Yujiro Yonetsu @Yujiro_Yonetsu
                                                  2021-09-25 02:03:02.824Z

                                                  Sorry for the delay.

                                                  I was using the script you taught me to verify the results.

                                                  In the middle of it all, one mystery was solved.

                                                  If I use the following script

                                                  sf.ui.proTools.floatingWindows.whoseTitle.startsWith('Plug-in:').first.windowClose()
                                                  

                                                  For some reason, all the windows were closed in my environment.
                                                  The reason for this was that I was using the keyboard shortcut "Control + Option + Command + any key" when I tested this script.
                                                  It seems that modifier keys such as "Option" were acting on the script.
                                                  I apologize for the inconvenience.

                                                  So the above script solves the problem.
                                                  Thanks:)