No internet connection
  1. Home
  2. How to

How to create a macro that executes an extension from the Finder Share menu

By @pepsin
    2024-05-21 17:10:18.389Z

    I'm trying to set up a macro that performs a share menu action on the selected file in Finder.

    The action is an extension called "Add to Under My Roof Inbox." It's from an app called Under My Roof with the purpose of importing files directly to its "Inbox" through iCloud.

    This extension is visible when I click the share menu button in the Finder window, but I'm having trouble automating this action in SoundFlow. The Open & Select Item in Popup Menu will activate the share menu, but won't click the extension. If I wait a moment, then run the macro again (with a Streamdeck button while Finder is focused), the action will SOMETIMES complete as expected, but not consistently. I tried duplicating the action with a "Wait" command in between, but this doesn't work at all.

    I tried to recreate the functionality in Shortcuts, but the extension doesn't seem to be available as an action.

    What else can I try?

    Thanks for your time!

    Solved in post #2, click to view
    • 2 replies
    1. Chris Shaw @Chris_Shaw2024-05-21 22:13:59.742Z2024-05-22 01:32:54.181Z

      this should do it.
      This will automatically click the "Add" button when the Under My Roof popup window appears by pressing enter on the keyboard. If you don't want to do this, comment or delete the last two lines of this script.

      const shareType = "Add to Under My Roof Inbox";
      
      sf.ui.finder.appActivateMainWindow()
      sf.ui.finder.focusedWindow.invalidate()
      
      // Define  window elements
      const finder = sf.ui.finder
      const finderWindowToolbar = finder.mainWindow.children.whoseRole.is("AXToolbar").first;
      const shareButton = finderWindowToolbar.buttons.whoseDescription.is("Share").first;
      
      // Click "Share" button
      shareButton.elementClick()
      
      // Wait for Share popover menu
      const popover = shareButton.children.whoseFullRole.is("AXPopover").first;
      popover.elementWaitFor();
      sf.wait({intervalMs:100})
      
      // Define popover menu elements
      const hostingView = popover.children.whoseFullRole.is("AXGroup:AXHostingView").first;
      const shareButtonToClick = hostingView.children.whoseDescription.is(shareType).first;
      
      // Click desired share button
      shareButtonToClick.elementClick()
      
      //Optional return keypress to Add
      sf.wait({ intervalMs: 500 })
      sf.keyboard.press({ keys: "enter" })
      

      FYI - You can use this script to click anything in the share popup window by changing the shareType value in the first line of the script

      Reply2 LikesSolution
      1. P@pepsin
          2024-05-22 18:44:24.804Z

          This is exactly what I was looking for, thank you so much!