No internet connection
  1. Home
  2. How to

Select Window Configuration by name

By samuel henriques @samuel_henriques
    2020-09-05 14:48:00.245Z

    Hello
    I'm trying to click on a window configuration by its name, since I found by number its not consistent for me.
    I'm using,

    sf.ui.proTools.menuClick({
    looseMatch: true,
    menuPath: ["Window", "Configurations","CONFIG NAME HERE"]
    

    But for some reason, it looks like the configurations from the menu are not available.

    Any Help?

    Thank you

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

    There are 17 replies. Estimated reading time: 12 minutes

    1. Hmm, not sure. It seems that Loose Match only works if the name starts with the same characters that you're looking for rather than a set of characters within the name. Like shown below, I can do a loose match with "99" but not "Window Reset".

      Perhaps @chrscheuer can chime in?

      1. Kitch Membery @Kitch2020-09-06 03:07:37.634Z

        Hi @samuel_henriques & @Chris_Shaw,

        Somthing like this should do it... There is probably an easier way :-)

        function selectWindowConfigByName(configName) {
            let windowConfigurationsMenu = sf.ui.proTools.getMenuItem('Window').children.first.children.first.children.first.children;
        
            let configMenuItems = windowConfigurationsMenu.map(c => c.title.invalidate().value).join(', ').split(', ');
        
            let menuItemToSelect = configMenuItems.filter(m => m.includes(configName))[0];
        
            sf.ui.proTools.menuClick({
                looseMatch:true,
                menuPath: ["Window", "Configurations", menuItemToSelect],
            });
        }
        
        selectWindowConfigByName('Window Reset');
        

        Rock on!!!

        ReplySolution
        1. Kitch Membery @Kitch2020-09-06 03:10:48.494Z

          BTW to select the window configuration you want simply update the following line;

          selectWindowConfigByName('ENTER WINDOW CONFIGURATION NAME HERE');

          1. This is great... I'd do it just ever so slightly differently, but Kitch's method is perfectly valid too :)

            function selectWindowConfigByName(windowConfigName) {
            
                var allConfigurationItems = sf.ui.proTools.getMenuItem('Window', 'Configurations').children.first.children.map(c => {
                    var m = c.title.value.match(/^(\d+):\s+(.+)$/);
                    return {
                        num: m && Number(m[1]),
                        title: m && m[2],
                        element: c,
                    };
                }).filter(i => i.num);
            
                var item = allConfigurationItems.filter(i => i.title === windowConfigName)[0];
                if (!item) throw `Could not find window configuration with name: "${windowConfigName}"`;
            
                item.element.elementClick();
            }   
            
            selectWindowConfigByName('Window Reset');
            
            1. samuel henriques @samuel_henriques
                2020-09-06 12:51:18.827Z

                Hello Kitch and Christian,

                Thank you so much, both codes work great,
                now,
                how to I had a function when he doesn't find the window configuration?

                Thank you both

                1. I'm not sure I follow your question. Can you clarify?

                  1. samuel henriques @samuel_henriques
                      2020-09-06 13:17:35.498Z

                      I use a session on the desktop named "T" with the configuration I need.
                      Every time I make adjustment on any session I'm working, I copy the session to the desktop and name it "T"

                      this is the function I made to import session data from it

                      function importt() {
                      
                      
                               sf.keyboard.press({
                                   keys: "alt+shift+i",
                               });
                      
                               var folder = "/Users/PPA_01/Desktop/T.ptx";
                               sf.keyboard.type({ text: folder });
                               sf.keyboard.press({ keys: 'enter' });
                               sf.ui.proTools.windows.first.buttons.whoseTitle.is('Open').first.elementClick();
                               sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Session Data').first.checkBoxes.whoseTitle.is('Tempo / Meter Map').first.checkboxSet({
                                   targetValue: "Disable",
                               });
                               sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Session Data').first.checkBoxes.whoseTitle.is('Key Signature / Chord Map').first.checkboxSet({
                                   targetValue: "Disable",
                               });
                               sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Session Data').first.checkBoxes.whoseTitle.is('Markers / Memory Locations').first.checkboxSet({
                                   targetValue: "Disable",
                               });
                               sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Session Data').first.checkBoxes.whoseTitle.is('Window Configurations').first.checkboxSet({
                                   targetValue: "Enable",
                               });
                               sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Session Data').first.checkBoxes.whoseTitle.is('Mic PRE Settings').first.checkboxSet({
                                   targetValue: "Disable",
                               });
                               sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Session Data').first.radioButtons.whoseTitle.is('Do Not Import').first.checkboxSet({
                                   targetValue: "Enable",
                               });
                               sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.buttons.whoseTitle.is('OK').first.elementClick();
                           
                      }   
                      
                      
                      
                      

                      this script works fine is the number and name of the window configuration is constant,

                        sf.ui.proTools.appActivateMainWindow();
                      
                      
                      
                      
                      
                      if (sf.ui.proTools.getMenuItem("Window", "Configurations", "99: PPA_01_WIN CONFIG").exists){
                       
                         sf.ui.proTools.menuClick({
                          looseMatch: true,
                          menuPath: ["Window", "Configurations", "99: PPA_01_WIN CONFIG"]
                        });
                          
                      
                          }else {
                      
                      importt()
                      
                      
                      
                      
                      function importt() {
                              sf.keyboard.press({
                                  keys: "alt+shift+i",
                              });
                      
                              var folder = "/Users/PPA_01/Desktop/T.ptx";
                              sf.keyboard.type({ text: folder });
                              sf.keyboard.press({ keys: 'enter' });
                              sf.ui.proTools.windows.first.buttons.whoseTitle.is('Open').first.elementClick();
                              sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Session Data').first.checkBoxes.whoseTitle.is('Tempo / Meter Map').first.checkboxSet({
                                  targetValue: "Disable",
                              });
                              sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Session Data').first.checkBoxes.whoseTitle.is('Key Signature / Chord Map').first.checkboxSet({
                                  targetValue: "Disable",
                              });
                              sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Session Data').first.checkBoxes.whoseTitle.is('Markers / Memory Locations').first.checkboxSet({
                                  targetValue: "Disable",
                              });
                              sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Session Data').first.checkBoxes.whoseTitle.is('Window Configurations').first.checkboxSet({
                                  targetValue: "Enable",
                              });
                              sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Session Data').first.checkBoxes.whoseTitle.is('Mic PRE Settings').first.checkboxSet({
                                  targetValue: "Disable",
                              });
                              sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Session Data').first.radioButtons.whoseTitle.is('Do Not Import').first.checkboxSet({
                                  targetValue: "Enable",
                              });
                              sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.buttons.whoseTitle.is('OK').first.elementClick();
                      
                       sf.ui.proTools.menuClick({
                      looseMatch: true,
                      menuPath: ["Window", "Configurations", "99: PPA_01_WIN CONFIG"]
                      });
                               
                      
                      
                      
                      }
                      
                      }
                      

                      Thank you all

                      1. samuel henriques @samuel_henriques
                          2020-09-06 13:29:54.534Z2020-09-06 14:19:57.680Z

                          I might just be over complicating this whole thing..

                          If I just keep the name and number it should work regardless...
                          Thank you guys so much...It's been a great leaning experience

                          1. MMicah Loken @Micah_Loken
                              2022-03-06 16:20:37.887Z

                              Hey @samuel_henriques,

                              I'm curious if you have figured out a newer/updated method for your import? I am also doing a similar method of saving out the window config to the desktop to import into other sessions. Thanks!

                        • In reply tochrscheuer:
                          Kitch Membery @Kitch2020-09-06 22:12:27.121Z

                          So good!!! I have to get my head around regex. :-)

                    • You can use the built in SoundFlow command for this:

                      sf.ui.proTools.windowConfigurationSelect({
                          number: 1,
                      });
                      
                      1. AlexanderW @AlexanderW
                          2020-09-17 18:49:35.981Z

                          Is there a way that SF reads out all stored window configurations from the currently opened session and put their names on buttons on the deck so that I can see them and choose one by just pressing the button?

                          Same thing would be awesome for previously stored Eucon Layouts.

                          1. It is somewhat possible but requires some pretty complicated programming. Check out Andrew Scheps' Toggle Decks to see how something like this works.

                            1. AlexanderW @AlexanderW
                                2020-09-17 21:09:23.524Z

                                Ok, I think it could be worth the effort. I'm going to take a look at it. Thank you

                                1. In reply toChris_Shaw:
                                  AlexanderW @AlexanderW
                                    2020-09-17 21:22:09.996Z

                                    I found a script from Andrew that saves and recalls Configs, which may be very useful but not really does the trick I am looking for. Or am I overseeing something?

                                  • In reply toAlexanderW:

                                    FYI - There already is a Eucon Layouts package that Christian put up on the store

                                    1. AlexanderW @AlexanderW
                                        2020-09-17 21:20:17.955Z

                                        I saw that, but the layouts are there just by number. You can't see the actual name of it. So it's mostly usable if you have always the same configs at the same number, which may not necessarily be the case