No internet connection
  1. Home
  2. Script Sharing

Reset Menus in Logic Pro

By Nicolas Aparicio @Nicolas_Aparicio
    2024-07-17 20:00:37.827Z

    Hi team,
    Here is a code that can reset Logic's menu, as sometimes the values in it won't refresh properly.
    Because of the way Logic works and my coding skills 😂, this code works 95% of the time so, not perfect but hope it's useful.

    This is the function: 👇

    function resetMenu(menuItem) {
        sf.ui.logic.invalidate();
        sf.ui.logic.appActivate();
    
        sf.ui.logic.getMenuItem(menuItem).elementClick();
        sf.keyboard.press({ keys: 'escape' })
    };
    

    And you can call it like this 👇:
    e.g.

    resetMenu('View') 
    

    or

    resetMenu('File') 
    
    • 3 replies
    1. Kitch Membery @Kitch2024-07-17 21:19:01.966Z

      This is Cool @Nicolas_Aparicio!

      Untested... but for scenarios where you want to select a menu item and ensure it refreshes, you could use something like this.

      /**
       * Clicks through a sequence of menu items in Logic Pro.
       *
       * @param {Object} params - The parameters object.
       * @param {string[]} params.menuPath - An array representing the hierarchy of menu items to be clicked.
       */
      function clickLogicProMenuItem({ menuPath }) {
          menuPath.forEach((_, index) => {
              const pathAtIndex = menuPath.slice(0, index + 1);
              sf.ui.logic.menuClick({
                  menuPath: pathAtIndex,
              });
          });
      }
      
      function main() {
          sf.ui.logic.appActivate();
          sf.ui.logic.invalidate();
      
          clickLogicProMenuItem({
              menuPath: ["File", "Movie", "Open Movie…"],
          });
      }
      
      main();
      

      And the clickLogicProMenuItem function can be reused, no matter the length of the menu path. :-)

      1. NNicolas Aparicio @Nicolas_Aparicio
          2024-07-17 21:32:46.457Z

          Nice, well, that's how you top it up.

          Thanks Kitch.

          1. Kitch Membery @Kitch2024-07-17 21:49:42.798Z

            Rock on!!