No internet connection
  1. Home
  2. Macro and Script Help

Fetching path from popup menu

By Alex Oldroyd @Alex_Oldroyd8
    2022-08-02 17:20:49.494Z

    Title

    Fetching path from popup menu

    What do you expect to happen when you run the script/macro?

    Hi there

    I got this working but now it is not. It's part of a larger script but this seems to be where it's failing at the moment.

    This should work out the currently selected output, select no output and then return back to the original output

    Are you seeing an error?

    02.08.2022 18:19:33.66 [Backend]: !! Command Error: ! insert plugin next available slot [user:cl16mc9zf000c6k10yb2ekw9m:cl5vnr3jk0013db10j2c9pju0]: Element is required (! insert plugin next available slot: Line 57)

    << Command: ! insert plugin next available slot [user:cl16mc9zf000c6k10yb2ekw9m:cl5vnr3jk0013db10j2c9pju0]

    What happens when you run this script?

    It seems to not be able to find the selected path in the popup menu

    How were you running this script?

    I used a keyboard shortcut within the target app

    How important is this issue to you?

    5

    Details

    {
        "inputExpected": "Hi there\n\nI got this working but now it is not. It's part of a larger script but this seems to be where it's failing at the moment.\n\nThis should work out the currently selected output, select no output and then return back to the original output",
        "inputIsError": true,
        "inputError": "02.08.2022 18:19:33.66  [Backend]: !! Command Error: ! insert plugin next available slot [user:cl16mc9zf000c6k10yb2ekw9m:cl5vnr3jk0013db10j2c9pju0]:\nElement is required (! insert plugin next available slot: Line 57)\n\n<< Command: ! insert plugin next available slot [user:cl16mc9zf000c6k10yb2ekw9m:cl5vnr3jk0013db10j2c9pju0]\n",
        "inputWhatHappens": "It seems to not be able to find the selected path in the popup menu",
        "inputHowRun": {
            "key": "-Mpfwh4RkPLb2LPwjePT",
            "title": "I used a keyboard shortcut within the target app"
        },
        "inputImportance": 5,
        "inputTitle": "Fetching path from popup menu"
    }

    Source

    
    changeOutputThenRevert();
    
    function changeOutputThenRevert() {
        const logic = sf.ui.app("com.apple.logic10")
        logic.appActivateMainWindow();
        logic.mainWindow.invalidate();
        openInspector();
        const originalDestination = returnOriginalMenuPath();
        selectTrackOutput("No Output")
        //log(originalDestination)
        selectTrackOutput(originalDestination)
    }
    
    function returnOriginalMenuPath() {
        const logic = sf.ui.app("com.apple.logic10")
        const outputPopup = logic.mainWindow.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.allItems[whatTypeOfTrack()]
        const outputMenuPath = outputPopup.popupMenuFetchAllItems().menuItems.filter(x => x.element.isMenuChecked)[0].path;
        const outputDestination = outputMenuPath.slice(-1).join().split(' → ')[0]
        return outputDestination
    }
    
    function selectTrackOutput(outputMenuPath) {
        const logic = sf.ui.app('com.apple.logic10');
        const inspector = logic.mainWindow.groups.whoseDescription.is('Inspector').first;
        logic.appActivateMainWindow();
    
        //Set the Output Path
        let mixer = inspector.children.whoseRole.is("AXList").first.groups
            .filter(g => g.children.whoseRole.is("AXLayoutArea").whoseDescription.is('Mixer').first.exists)
            .map(g => g.children.whoseRole.is("AXLayoutArea").whoseDescription.is('Mixer').first)[0];
    
        mixer.children.whoseRole.is("AXLayoutItem").first.buttons.allItems[whatTypeOfTrack()].popupMenuSelect({
            menuSelector: item => item.filter(i => i.path.slice(-1).join().split(' → ')[0] === outputMenuPath)[0],
        });
    }
    
    function openInspector() {
        const logic = sf.ui.app('com.apple.logic10');
        const inspectorBtn = logic.mainWindow.groups.whoseDescription.is('Control Bar').first.checkBoxes.whoseTitle.is('Inspector').first;
    
        if (!inspectorBtn.isCheckBoxChecked) {
            inspectorBtn.elementClick();
        }
    }
    
    function whatTypeOfTrack() {
        const logic = sf.ui.app("com.apple.logic10");
        const channel = logic.mainWindow.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")
        const inputMonitoring = logic.mainWindow.groups.whoseDescription.is("Inspector").first.children.whoseRole.is("AXList").first.groups.allItems[2].children.whoseRole.is("AXLayoutArea").whoseDescription.is("Mixer").first.children.whoseRole.is("AXLayoutItem").first.buttons.whoseDescription.is("monitoring").first;
        const inputMonitoringOther = logic.mainWindow.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("monitoring").first;
        const monoStereo = logic.mainWindow.groups.whoseDescription.is("Inspector").first.children.whoseRole.is("AXList").first.groups.allItems[2].children.whoseRole.is("AXLayoutArea").whoseDescription.is("Mixer").first.children.whoseRole.is("AXLayoutItem").first.buttons.whoseDescription.is("channel mode").first;
        const monoStereoOther = logic.mainWindow.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("channel mode").first;
    
        //audio
        if ((inputMonitoring.exists) || (inputMonitoringOther.exists)) {
            return (7)
        }
    
        //aux
        if (((monoStereo.exists) || (monoStereoOther.exists) && (!inputMonitoring.exists))) {
            return (5)
        }
    
        //instrument
        if (!monoStereo.exists) {
            return (5)
        }
    
    }
    

    Links

    User UID: Kf7km0JU15Q6NnRTk6HrX1PmHaw1

    Feedback Key: sffeedback:Kf7km0JU15Q6NnRTk6HrX1PmHaw1:-N8UZkwefrhN1CZ78L60

    Feedback ZIP

    • 5 replies
    1. Kitch Membery @Kitch2022-08-05 19:45:01.854Z

      Hi @Alex_Oldroyd,

      Try this out;

      function showInspector() {
          const logic = sf.ui.app('com.apple.logic10');
          const controlBar = logic.mainWindow.groups.whoseDescription.is('Control Bar').first;
          const inspectorBtn = controlBar.checkBoxes.whoseTitle.is('Inspector').first;
      
          if (!inspectorBtn.isCheckBoxChecked) {
              inspectorBtn.elementClick();
          }
      }
      
      function getOutputPath() {
          const logic = sf.ui.app('com.apple.logic10');
          const inspector = logic.mainWindow.groups.whoseDescription.is('Inspector').first;
          const inspectorList = inspector.childrenByRole("AXList").first;
          const mixer = inspectorList.groups.find(group => group.childrenByRole("AXLayoutArea").first.getString("AXDescription") === "Mixer")
              .childrenByRole("AXLayoutArea").whoseDescription.is("Mixer").first;
          const mixerButtons = mixer.children.whoseRole.is("AXLayoutItem").first.buttons;
          const outputPopup = mixerButtons.find(btn => btn.frame.w === 69.00 && btn.frame.h === 18);
      
          const selectedOuputPath = outputPopup.popupMenuFetchAllItems().menuItems.filter(mi =>
              mi.path[0] === "No Output" || mi.path[0] === "Output" || mi.path[0] === "Bus").filter(mi => mi.element.isMenuChecked)[0].path;
      
          //Close Output Popup
          logic.appActivateMainWindow();
      
          return selectedOuputPath
      }
      
      function setOutputPath({ menuPath }) {
          const logic = sf.ui.app('com.apple.logic10');
          const inspector = logic.mainWindow.groups.whoseDescription.is('Inspector').first;
          const inspectorList = inspector.childrenByRole("AXList").first;
          const mixer = inspectorList.groups.find(group => group.childrenByRole("AXLayoutArea").first.getString("AXDescription") === "Mixer")
              .childrenByRole("AXLayoutArea").whoseDescription.is("Mixer").first;
          const mixerButtons = mixer.children.whoseRole.is("AXLayoutItem").first.buttons;
          const outputPopup = mixerButtons.find(btn => btn.frame.w === 69.00 && btn.frame.h === 18);
      
          outputPopup.popupMenuSelect({ menuPath });
      }
      
      function changeOutputThenRevert() {
          const logic = sf.ui.app("com.apple.logic10")
      
          logic.appActivateMainWindow();
          logic.mainWindow.invalidate();
      
          showInspector();
      
          const originalOutputPath = getOutputPath();
      
          setOutputPath({
              menuPath: ["No Output"]
          });
      
          sf.wait(); //This wait is for demonstration purposes only
      
          setOutputPath({
              menuPath: originalOutputPath
          });
      }
      
      changeOutputThenRevert();
      

      Note: I have only tried this on version 10.6.2 If it does not work on newer versions of logic let me know and I'll check it on my laptop rig.

      1. AAlex Oldroyd @Alex_Oldroyd8
          2022-08-06 11:46:40.754Z

          Ah mate thanks so much. It works seamlessly on audio, aux and software instruments.... however it's having the same issue that i experienced with my code.

          If you put an audio track in a summing stack, then run this script on that audio track, it will fail. I get the following error:

          06.08.2022 12:42:11.34 <info> [Backend]: !! Command Error: change output then revert to original kitch [user:cl3c6los2000cd11016x299k9:cl6htqqjm00000h10g7no224y]:
          Could not click popup menu item (change output then revert to original kitch: Line 39)
              Could not find menu item with name: Bus -> 97 - 128 -> Aux 2 -> Bus 100  (LV Dolby) → Aux 2
          
          1. Kitch Membery @Kitch2022-08-06 18:26:54.931Z

            Ahh Interesting...

            I'll see if I can recreate it :-)

            1. AAlex Oldroyd @Alex_Oldroyd8
                2022-08-07 11:12:18.869Z

                Thanks mate

              • In reply toAlex_Oldroyd8:
                Kitch Membery @Kitch2022-08-08 03:29:52.621Z

                Hi @Alex_Oldroyd8,

                So it looks like this may be a bug, or a yet-to-be-supported feature for SoundFlow to control Logic, I am however going to log a report on it to see if Christian can address the issue.

                See the report here;