No internet connection
  1. Home
  2. How to

Reopen last closed plug in window?

Just about the only thing I miss about the Slate Batch Commander was a button I could press to reopen my last-adjusted plugin window. Seems like I always change my mind and want to tweak settings again after closing a plugin window, and that button simplified the process. Is it possible to do this in Soundflow? I'm guessing it is. Thanks!

Solved in post #7, click to view
  • 8 replies
  1. Brenden @nednednerb
      2022-11-10 18:04:11.634Z

      One way might be to create a custom shortcut that takes the last active window and stores it in some way (that part is beyond my knowledge, maybe by saving the plug-in settings as a preset named _lastSetting or something), and then the same shortcut can close the window in a subsequent action. Then another shortcut could quickly recall that stored info and open that window and load that preset to get back to where you just were.

      1. samuel henriques @samuel_henriques
          2022-11-10 21:16:24.927Z2022-11-10 23:07:50.963Z

          Hello Matthew,
          For this lets use two scripts, one to save the open plug-in and the other will access the first info and open the plug.
          1:

          
          function saveOpenPlug() {
              try {
          
                  const plugWin = sf.ui.proTools.windows.whoseTitle.startsWith("Plug-in: ").first
                  let openedPlug = {
                      trackName: plugWin.popupButtons.whoseTitle.is("Track Selector").first.value.invalidate().value,
                      insertNumber: plugWin.popupButtons.whoseTitle.is("Insert Position selector").first.value.invalidate().value.charCodeAt(0) - 96
                  };
          
                  let global = globalState.lastOpenedPlugWin
          
                  if (!global) { global = [] }
          
                  if (global.length < 2) {
                      global.unshift(openedPlug);
          
                  } else if (global.length === 2) {
                      global.pop();
                      global.unshift(openedPlug);
                  };
          
                  globalState.lastOpenedPlugWin = global
          
              } catch (err) { }
          };
          
          saveOpenPlug();
          
          

          Then you need to set a window trigger to run this script every time you open a plug:

          Then a second script:

          try {
              const { trackName, insertNumber } = globalState.lastOpenedPlugWin[0]////0 for last, 1 for before last, so you can toggle the last two
          
              sf.ui.proTools.trackGetByName({ name: trackName }).track.trackInsertToggleShow({
                  insertNumber: insertNumber,
                  targetValue: "Enable"
              });
          } catch (err) {
              alert("No plug-in saved.");
          
          };
          

          notice the note I left ///0 for last, 1 for before last, so you can toggle the last two , the script is actually saving the last two opened plugs so you could use this to toggle two plugin windows.

          1. Brenden @nednednerb
              2022-11-11 06:08:49.208Z

              Samuel,

              That's great! Definitely a keeper for when I'm busy mixing something fun.

              Is there an easy or straightforward switch to adapt this script to recall the last AudioSuite plug-in and setting that was opened?

            • M

              Fantastic. The second script would be assigned to a "button" of some sort, correct?

              1. samuel henriques @samuel_henriques
                  2022-11-11 14:38:02.513Z

                  correct

                • samuel henriques @samuel_henriques
                    2022-11-11 14:44:00.250Z

                    And here's a version for audioSuite
                    Script 1, save settings:

                    let currentWin
                    function buttonCheckHoover(callback) {
                    
                        // example of list ["RX 8 Voice De-noise", "RX 8 De-plosive", "RX 8 De-click"]
                        const ignoreWinList = []
                        const audioSuiteWin = sf.ui.proTools.invalidate().firstAudioSuiteWindow
                        const audioSuiteWinName = audioSuiteWin.title.value
                        const btn = audioSuiteWin.buttons.whoseTitle.is("Render").first
                        currentWin = audioSuiteWinName
                    
                        sf.engine.runInBackground(function () {
                            try {
                                while (true) {
                                    let newWin = audioSuiteWin.title.invalidate().value;
                    
                                    if (btn.exists && (currentWin === newWin) && !ignoreWinList.includes(newWin.split(": ")[1])) {
                    
                                        if (sf.ui.proTools.isActive) {
                                            // Get mouse position
                                            const mousePosition = sf.mouse.getPosition().position
                                            // Get cancel button position
                                            const buttonPos = btn.position
                    
                                            //  Btn position must have a value
                                            if (buttonPos &&
                    
                                                /// If mouse stops in btn , presume button was pressed
                                                mousePosition.x > buttonPos.x && mousePosition.x < buttonPos.x + 77 &&
                                                mousePosition.y > buttonPos.y && mousePosition.y < buttonPos.y + 15) {
                    
                                                callback()
                                            };
                                        };
                                    } else {
                                        break;
                                    };
                                    sf.wait({ intervalMs: 500 })
                                };
                            } catch (err) { throw err }
                        });
                    };
                    
                    
                    
                    function saveOpenPlug() {
                    
                    
                        const audioSuiteWin = sf.ui.proTools.firstAudioSuiteWindow
                        const audioSuiteName = audioSuiteWin.title.invalidate().value.split(": ")[1]
                    
                        globalState.lastOpenedAudioSuiteWin = audioSuiteName
                    
                        //audioSuiteWin.popupButtons.whoseTitle.is("Settings Menu").first.popupMenuSelect({ menuPath: ["Copy Settings"] })
                    
                        //Copy Settings
                        sf.keyboard.press({ keys: "cmd+shift+c" });
                    
                    };
                    
                    
                    buttonCheckHoover(saveOpenPlug)
                    

                    Set the window trigger like so:

                    This will save the settings when you hover the mouse over the render button. But you probably use SF to press the button, so add the saveOpenPlug() function to the script you use to press render, just after or before the render line so i'll save the settings to a global variable.
                    If you are like me, and always have a few audioSuite already open that don't matter for this, you can set an ignoreWinList. Jus add the plugin names as the example.

                    Then to recall use:

                    function getMenuPaths(menuName) {
                        let arr = []
                        sf.ui.proTools.getMenuItem(menuName).children.first.children.map(menuItem => {
                            sf.ui.proTools.getMenuItem(menuName, menuItem.title.value).children.first.children.map(subMenuItem =>
                                arr.push([menuName, menuItem.title.value, subMenuItem.title.value]))
                        });
                        return arr
                    };
                    
                    function main() {
                    
                    
                        let audioSuiteName = globalState.lastOpenedAudioSuiteWin
                    
                        let asList = getMenuPaths("AudioSuite")
                    
                        let asPath = asList.filter(p => p.includes(audioSuiteName))[0]
                    
                        const aWin = sf.ui.proTools.audioSuiteOpenPlugin({
                            category: asPath[1],
                            name: asPath[2],
                        }).window
                    
                        //aWin.popupButtons.whoseTitle.is("Settings Menu").first.popupMenuSelect({ menuPath: ["Paste Settings"] })
                        
                        //Paste Settings
                        sf.keyboard.press({ keys: "cmd+shift+v" });
                    
                    };
                    
                    
                    main();
                    
                    Reply1 LikeSolution
                    1. M

                      This works! I know it's not magic but when you smart folks come up with this stuff it feels that way. Thanks so much!

                      1. samuel henriques @samuel_henriques
                          2022-11-11 16:12:30.504Z2022-11-11 16:27:35.527Z

                          It's magic for me as well 😂😂