How can I make a macro to share items with AirDrop?
I use AirDrop a lot. I just want to be able to share a file using a command. Thanks!
- Nathan Salefski @nathansalefski
It should be pretty easy with just the following code:
//Activate Finder sf.ui.finder.appActivate(); //File, Import, Audio sf.ui.finder.menuClick({ menuPath: ["File", "Share", "AirDrop"], });
However that doesn't seem to be working. I fetched the menu items of the "File" menu in Finder just to make sure there wasn't any weird spelling or references and it seems to be correct.
I used:
const fileMenu = sf.ui.finder.getElement("AXMenuBar").children.whoseRole.is("AXMenuBarItem").whoseTitle.is("File").first.popupMenuFetchAllItems(); log(fileMenu);
to verify and the Path for Share > AirDrop seems to be correct. Any thoughts?
{ "Path": [ "Share", "AirDrop" ], "Names": [ "Share", "AirDrop" ], "Delimiter": " -> ", "Element": "{\"title\":\"AirDrop\",\"role\":\"AXMenuItem\",\"fullRole\":\"AXMenuItem\"}" }
- In reply toPaulo_Uribe⬆:Chad Wahlbrink @Chad2023-07-20 01:12:35.831Z
Hey, @Paulo_Uribe!
The "File" > "Share" menu in Finder seems a bit funky. It seemed like it was a known issue from a quick Google search. I saw people struggling with AppleScript options as well.
So this is a bit of a hack, but it works great.
You can use the "Shortcuts" app on your Mac and hook it up to SoundFlow. Download the Shortcut action here:https://www.icloud.com/shortcuts/e44435c876eb49438f0f68e07510e908
Next, go to the SoundFlow Store, and search for "Apple Shortcuts." I made a package on there that allows you to run any Apple Shortcut from SoundFlow.
To add a preset, either select the main action, "Run Apple Shortcut," and click "Add New Preset," OR you can just option drag the "Default Preset" down to the "My Presets" folder.
From there, type "AirDrop" into the Macro Template, and set the trigger to whatever you'd like.
I hope this helps!
Best,
Chad- PPaulo Uribe @Paulo_Uribe
Hi Chad! Thank you for your help. I've tried it but I can't get it to work. I've done everything as you said. I've doubled checked the spelling and it still doesn't work. The only way it works is by clicking the run button on the shortcuts. Are there any settings on the shortcuts app I should have checked?
Chad Wahlbrink @Chad2023-07-21 20:17:01.831Z
@Paulo_Uribe, Hey!
Thanks for trying it out. Can you check this setting in System Settings:
If this doesn't show the ability to automate 'Shortcut Events' from SoundFlow, it likely won't run! But if it's running from he Shortcuts app, that should be a good sign overall.Chad Wahlbrink @Chad2023-07-21 20:19:01.137Z
You could also try running this from a new script:
sf.system.execAppleScript({ script: ` tell application "Shortcuts Events" run shortcut "AirDrop" end tell ` });
OR try running this from the Mac App, Script Editor:tell application "Shortcuts Events" run shortcut "${shortCutName}" end tell
Doing that may jog the system to prompt you to allow these kind of actions.
- In reply toChad⬆:
Chad Wahlbrink @Chad2023-10-19 16:30:21.923Z
A follow up on this for future readers. You can also set up an Apple Shortcut as a "service" like this:
This allows you to do something like this via SoundFlow:
sf.ui.finder.menuClick({menuPath:['Finder','Services', 'AirDrop']});
- PIn reply toPaulo_Uribe⬆:Paulo Uribe @Paulo_Uribe
So, I checked the settings you mention and they don't even show.
Chad Wahlbrink @Chad2023-07-21 21:12:54.593Z
Understood. The system should prompt you the first time you run a script like this to allow it.
Can you try running from a fresh Soundflow Script or the apple script editor with the scripts from this post How can I make a macro to share items with AirDrop? #post-7
- PPaulo Uribe @Paulo_Uribe
I tried it and it worked! If you can find a way to make it work bypassing the shortcuts app let me know. I'm trying to use that macro on a computer that has an older OS that doesn't have shortcuts. Thank you!
- In reply toChad⬆:DDave Weingarten @Dave_Weingarten
Hey Chad,
I'm getting an error "NSAppleScriptErrorAppName = "Shortcuts Events";
I'm on Ventura. Trying to make a button to turn off my noisy fridge for 30 mins at a time while recording vocals :)
Chad Wahlbrink @Chad2024-10-03 21:04:33.984Z
Hey @Dave_Weingarten,
I just pushed an update to my Shortcuts package on the store to use the latest implementation of Shortcuts support for SoundFlow.
In SF 5.8, we added native support for calling Shortcuts from any macro:
You can also use the script version like this:
sf.system.execShortcut({shortcutName:'AirDrop'})
- DDave Weingarten @Dave_Weingarten
Thank you so much Chad. I discovered this just after posting and got my noisy minifridge to turn off for 30 minutes at a time with the push of a button on my Stream Deck (via Apple Home)! New soundflow user here and it's amazing. Thank you.
Chad Wahlbrink @Chad2024-10-03 21:21:16.678Z
I love to hear that you are getting things working for you, @Dave_Weingarten!
Feel free to ask more questions in the "How To" section of the forum as you have them. Happy Soundflowing 🏄♂️🏄♂️