No internet connection
  1. Home
  2. How to

Open & Select Popup Menu Item not working as expected

By Alex Oldroyd @Alex_Oldroyd8
    2022-01-26 15:08:44.849Z2022-01-26 15:28:06.905Z

    Hi all

    In Logic Pro X, you can add a plugin slot before all occupied by clicking on the thin strip above the plugin slot list.

    You can click on it, navigate to the desired plugin and select and it will load before all others. However Open & Select popup menu doesn't see any of the menu items in this popup menu. If I use the same code that will open up a plugin on the first slot, but instead point it to this popup, it suddenly cant see the options. Any help would be greatly appreciated! :)

    
    sf.ui.app("com.apple.logic10").children.whoseRole.is("AXWindow").allItems[1].groups.whoseDescription.is("Inspector").first.children.whoseRole.is("AXList").first.groups.allItems[3].children.whoseRole.is("AXLayoutArea").whoseDescription.is("Mixer").first.children.whoseRole.is("AXLayoutItem").first.buttons.whoseDescription.is("insert bar").allItems[3].popupMenuSelect({
        menuPath: ["EQ"],
    });
    
    
    
    • 11 replies
    1. A
      Alex Oldroyd @Alex_Oldroyd8
        2022-02-07 08:57:50.130Z

        Hey @Kitch. Is there a way to use get open & select working on this?

        1. Kitch Membery @Kitch2022-02-07 21:15:39.254Z

          I'll take a look :-)

          1. AAlex Oldroyd @Alex_Oldroyd8
              2022-02-07 21:33:55.983Z

              Hero!! :)

              1. Kitch Membery @Kitch2022-02-07 21:34:45.162Z

                Not yet I'm not hahaha :-)

                1. AAlex Oldroyd @Alex_Oldroyd8
                    2022-02-07 22:18:57.702Z

                    Lol . whenever you can will be much appreciated mate :)

            • In reply toAlex_Oldroyd8:
              Kitch Membery @Kitch2022-02-07 22:46:12.257Z

              Hi @Alex_Oldroyd8,

              This should do the trick :-)

              /**
               * @param {object} obj
               * @param {number} obj.insertBarNumber
               * @param {string[]} obj.menuPath
               */
              function addToInsertBar({ insertBarNumber, menuPath }) {
                  const logic = sf.ui.app('com.apple.logic10');
                  logic.appActivateMainWindow();
                  const inspector = logic.mainWindow.groups.whoseDescription.is('Inspector').first;
                  const mixer = inspector.children.whoseRole.is("AXList").first.groups.allItems[2].children.whoseRole.is("AXLayoutArea").whoseDescription.is("Mixer").first
              
                  const insertBar = mixer.children.whoseRole.is("AXLayoutItem").first.buttons.whoseDescription.is("insert bar").map(e => e).reverse()[insertBarNumber - 1];
              
                  const popupMenu = insertBar.popupMenuOpenFromElement({
                      relativePosition: { "x": 60, "y": 3 },
                  }).popupMenu;
              
                  popupMenu.popupMenuSelect({
                      menuPath,
                  });
              }
              
              addToInsertBar({
                  insertBarNumber: 1,
                  menuPath: ["EQ", "Channel EQ", "Dual Mono"],
              });
              
              

              Rock on!

              1. AAlex Oldroyd @Alex_Oldroyd8
                  2022-02-08 00:03:46.707Z

                  Thanks mate. I'm getting the following error and I can't work out the issue...

                  08.02.2022 00:02:25.17 <info> [Backend]: JavaScript error with InnerException: null
                  !! Command Error: 1 Add plugin before list [user:ckytyz33500008210mg0auixy:ckyu2dk4s000n82109qxisgd5]:
                  TypeError: Cannot read property 'popupMenuOpenFromElement' of undefined
                  (1 Add plugin before list line 14) 
                  
                  1. Kitch Membery @Kitch2022-02-08 00:07:02.230Z

                    Heading out for a bit but will check it on my return :-)

                    Try playing around with the relativePosition: { "x": 60, "y": 3 },

                    Maybe change it to relativePosition: { "x": 50, "y": -4 },

                    1. In reply toAlex_Oldroyd8:
                      Kitch Membery @Kitch2022-02-08 00:08:17.204Z

                      If that does not work could you upload a screenshot?

                      1. In reply toAlex_Oldroyd8:
                        Kitch Membery @Kitch2022-02-08 03:39:27.009Z

                        @Alex_Oldroyd8

                        Here is a new and improved version;

                        /**
                         * @param {object} obj
                         * @param {number} obj.insertBarNumber
                         * @param {string[]} obj.menuPath
                         */
                        function addToInsertBar({ insertBarNumber, menuPath }) {
                            const logic = sf.ui.app('com.apple.logic10');
                            logic.appActivateMainWindow();
                            const inspector = logic.mainWindow.groups.whoseDescription.is('Inspector').first;
                        
                            const mixer = inspector.childrenByRole("AXList").first.groups.find(c => {
                                return c.children.whoseRole.is("AXLayoutArea").first.getString("AXDescription") === "Mixer"
                            }).children.whoseRole.is("AXLayoutArea").whoseDescription.is("Mixer").first;
                        
                            const insertBar = mixer.children.whoseRole.is("AXLayoutItem").first.buttons.whoseDescription.is("insert bar")
                                .map(e => e).reverse()[insertBarNumber - 1];
                        
                            const popupMenu = insertBar.popupMenuOpenFromElement({
                                relativePosition: { "x": 60, "y": 3 },
                            }).popupMenu;
                        
                            popupMenu.popupMenuSelect({
                                menuPath,
                            });
                        }
                        
                        addToInsertBar({
                            insertBarNumber: 1,
                            menuPath: ["EQ", "Channel EQ", "Dual Mono"],
                        });
                        

                        I wasn't taking into account the Groups or or Help Inspectors being visible.

                        Give this a run :-)

                        1. AAlex Oldroyd @Alex_Oldroyd8
                            2022-02-08 19:03:44.998Z

                            @Kitch you are a god. This is amazing. As long as there is a plugin in slot 1, it works every time on audio, instruments and auxes! :)

                            I'll make a script that includes an if/else statement to check if there are other plugins on the channel.

                            How would you go about doing this on multiple selected tracks... Do you think it would be better in the mixer window or is there a way to do it in the arrange window?