No internet connection
  1. Home
  2. How to

Search Audiosuite Plugin Preset

By Martin Pavey @Martin_Pavey
    2019-09-13 13:16:51.417Z

    Hi Christian,
    I found the above script in a post from December 2018.
    Is it possible to get this to work for open Audiosuite plugins also?

    I found the Audiosuite first 15 presets script, but that didn't work.

    Thanks

    Martin

    Solved in post #3, click to view
    • 13 replies

    There are 13 replies. Estimated reading time: 12 minutes

    1. M
      Martin Pavey @Martin_Pavey
        2019-09-13 13:18:09.753Z2019-09-13 20:48:15.513Z

        Here's the script you wrote for Plugin Inserts:

        sf.ui.proTools.appActivate();
        
        //Find the top most floating window containing 'Plug-in:' and locate its preset selector
        var win = sf.ui.proTools.floatingWindows.whoseTitle.contains('Plug-in:').first;
        var btn = win.popupButtons.whoseTitle.contains('Librarian menu').first;
        
        //Get the presets
        var items = btn.popupMenuFetchAllItems().menuItems.map(function(item){
            return {
                name: item.names.join(' -> '),
                path: item.names
            };
        });
        
        //Choose a preset
        var chosenPath = sf.interaction.popupSearch({
            items: items,
            title: 'Select preset'
        }).item.path;
        
        //Get focus back
        sf.wait({ intervalMs: 100 });
        sf.ui.proTools.appActivate();
        sf.wait({ intervalMs: 50 });
        win.elementRaise();
        sf.wait({ intervalMs: 50 });
        
        //Select the preset from the menu
        btn.popupMenuSelect({
            menuPath: chosenPath,    
        });
        
        1. Hi @Martin_Pavey.

          This updated script should work on both AudioSuite plugins and inserts:

          sf.ui.proTools.appActivate();
          
          //Find the top most floating window containing 'Plug-in:' and locate its preset selector
          var win, btn;
          {
              win = sf.ui.proTools.floatingWindows.whoseTitle.matches(/(^Plug-in|^Audio Suite)/g).first;
              if (!win) throw 'Could not find a window';
              btn = win.popupButtons.whoseTitle.contains('Librarian menu').first;
              if (!btn.exists) btn = win.popupButtons.whoseTitle.contains('Preset').first;
          }
          
          //Get the presets
          var items = btn.popupMenuFetchAllItems().menuItems.map(function (item) {
              return {
                  name: item.names.join(' -> '),
                  path: item.names
              };
          });
          
          //Choose a preset
          var chosenPath = sf.interaction.popupSearch({
              items: items,
              title: 'Select preset'
          }).item.path;
          
          //Get focus back
          sf.wait({ intervalMs: 100 });
          sf.ui.proTools.appActivate();
          sf.wait({ intervalMs: 50 });
          win.elementRaise();
          sf.wait({ intervalMs: 50 });
          
          //Select the preset from the menu
          btn.popupMenuSelect({
              menuPath: chosenPath,
          });
          
          ReplySolution
          1. MMartin Pavey @Martin_Pavey
              2019-09-14 00:01:28.639Z

              Oh wow, this is wonderful, its going to save me loads of time and clicking.
              I'm really loving what can be achieved with Soundflow.
              Thanks Christian!

          2. In reply toMartin_Pavey:
            Danny @Danny_van_Spreuwel
              2020-09-17 16:38:06.848Z

              At some point the popupSearch window disapears right after the search items function. A small wait of 100 ms right after the "Get the preset" function solved this problem.

              sf.ui.proTools.appActivate();
              
              //Find the top most floating window containing 'Plug-in:' and locate its preset selector
              var win, btn;
              {
                  win = sf.ui.proTools.floatingWindows.whoseTitle.matches(/(^Plug-in|^Audio Suite)/g).first;
                  if (!win) throw 'Could not find a window';
                  btn = win.popupButtons.whoseTitle.contains('Librarian menu').first;
                  if (!btn.exists) btn = win.popupButtons.whoseTitle.contains('Preset').first;
              }
              
              //Get the presets
              var items = btn.popupMenuFetchAllItems().menuItems.map(function (item) {
                  return {
                      name: item.names.join(' -> '),
                      path: item.names
                  };
              });
              
              sf.wait({ intervalMs: 100 });
              
              //Choose a preset
              var chosenPath = sf.interaction.popupSearch({
                  items: items,
                  title: 'Select preset'
              }).item.path;
              
              //Get focus back
              sf.wait({ intervalMs: 100 });
              sf.ui.proTools.appActivate();
              sf.wait({ intervalMs: 50 });
              win.elementRaise();
              sf.wait({ intervalMs: 50 });
              
              //Select the preset from the menu
              btn.popupMenuSelect({
                  menuPath: chosenPath,
              });
              1. Miguel Carrascal @Miguel_Carrascal
                  2020-10-01 23:19:44.406Z

                  Hi Danny –
                  I'm setting up a Deck and wanted to include your version of the "Search Presets" script since I was having a bit of trouble getting the SF System script to work. I successfully run your script once, but every subsequent time I try, I get the following error (below):

                  I am a bit confused as to why this keeps happening. I've restarted SF, made sure I am on the most up-to-date version; restarted Pro Tools, computer, streamdeck...the works, but the script won't work after the first time.

                  I worked out a poor substitute as a workaround to have the preset menu of the foremost plugin pop up, which then allows me to use my keyboard to search throught the presets (script below):

                  
                  sf.ui.proTools.appActivateMainWindow();
                  
                  sf.ui.proTools.firstAudioSuiteWindow.popupButtons.whoseTitle.is('Preset').first.popupMenuFetchAllItems();
                  
                  

                  However, I really love the searchable floating window that appears with your script.
                  Any ideas/suggestions?

                  @chrscheuer might this be a bug of some sort? I'm running macOS Mojave 10.14.6 (not sure if that info is helpful).

                  Thank you very much in advance for all your help.
                  Best,
                  -MCR

                  1. Hi Miguel,

                    This is on SF 4.1.2 right?
                    Can you do a screen recording of the issue occurring (using the Search Presets script from my Pro Tools utilities package, with no modifications)? Often a screen recording is the quickest way for us to understand what may be different in your setup that could cause it to behave differently from where we designed it.

                    1. Miguel Carrascal @Miguel_Carrascal
                        2020-10-02 15:17:08.903Z

                        Hi Christian –

                        Yes, I'm using SF 4.1.2.
                        File is too big, so I've uploaded it to my Dropbox instead. Link below:

                        Let me know if anything. Thank you very much in advance.
                        Best,
                        -MCR

                        1. Thanks Miguel

                          If you add a keyboard trigger to it and run it when Pro Tools is focused, does that make a difference?

                          1. Miguel Carrascal @Miguel_Carrascal
                              2020-10-02 15:59:06.695Z

                              Yes, if I assign a Keyboard Trigger it works without any issues.
                              Any thoughts on why the streamdeck trigger isn't working properly?
                              Thanks so mch for the suggestion!

                              1. In reply tochrscheuer:
                                Miguel Carrascal @Miguel_Carrascal
                                  2020-10-02 16:33:31.942Z2020-10-02 16:59:03.769Z

                                  Also, same-same-but-different issue.
                                  I have the same thing happen with "Search Markers" command. No issues when using Keyboard Trigger, but not working when clicking Run Macro on SF or when I assign to streamdeck trigger.
                                  SF Log capture below:

                                  1. Are you using macOS spaces?

                                    Note, when clicking some of these actions from "Run Macro" or "Run Command" within SoundFlow, you may be running into a limitation/feature in macOS in which a mouse click on an application which isn't focused, won't result in that application receiving the mouse click, but rather in just focusing the app. A 2nd mouse click will need to be sent in order for the app to receive it. You can "test" this feature yourself by focusing another app, then clicking on a button in Pro Tools that should have resulted in a popup menu being shown (without first focusing Pro Tools). Most likely, that click will only focus Pro Tools, and you'll need a 2nd click to actually get the popup menu shown.

                                    In the cases of popup menus, SoundFlow actions are for this reason extra sensitive towards the user having the correct app focused before you run them.
                                    This is most likely why you're seeing these errors.

                                    When you were testing the Stream Deck triggers, did you have Pro Tools focused?

                                    Note, that when writing your own scripts, we typically recommend adding this line to the start of your script (if it's for Pro Tools):

                                    sf.ui.proTools.appActivateMainWindow();
                                    

                                    As it says from its name, that line will ensure that Pro Tools is properly activated/focused, so that any subsequent mouse clicks will correctly be handled by Pro Tools, and as a result, any popup menu automation will work.

                                    1. Miguel Carrascal @Miguel_Carrascal
                                        2020-10-02 22:56:06.283Z

                                        Bingo!
                                        I was unawarely making use of macOS spaces since I have (2) displays.
                                        I made sure to look at the offending scripts, and it turned out that the code written was not entirely correct:

                                        sf.ui.proTools.appActivate();
                                        

                                        As you can see, it is missing the MainWindow portion.
                                        Made the switch, and it all works out swimmingly now.
                                        Thanks so much, Christian!
                                        -MCR

                                        1. Awesome, great you got it working :)