Airdrop Shortcut

I just started using BTT and I was wondering if anybody can show me a step-by-step on how to set up a gesture/keyboard shortcut to bring up the airdrop menu. Thank you for your help in advance!

Hi there,

Not if I fully understand your question.

To open Aidrop you can us Shift+Command+R and it brings up the Airdrop Window.
This short cut you can execute with BTT gesture.
I had it set to open a new finder window and in that open the airdrop feature.

Hope that helps.

I also don't really understand the question, but here is an AppleScript which:

  • Check in the active Finder window if files are selected
  • If nothing selected, then opens a choose file dialog for selection
  • Then AirDrop will open when a selection is made

You can run the script in the Script Editor or as a BTT AppleScript Action.

set selectedItems to missing value

-- CHECK FINDER SELECTION
tell application "Finder"
	if get selection ≠ {} then
		set selectedItems to {}
		repeat with s in (get selection)
			set end of selectedItems to s as alias
		end repeat
	end if
end tell

-- CHOSSE FILE IF SELECTION IS NULL
if selectedItems is missing value then
	set selectedItems to choose file with prompt "Select File(s) to send via AirDrop" with multiple selections allowed
end if

-- START AIRDROP IF SELECTION IS NOT NULL
if selectedItems ≠ missing value then
	StartAirDrop(selectedItems)
end if


on StartAirDrop(inputItems)
	script theScript
		use framework "Foundation"
		use framework "AppKit"
		property NSSharingService : a reference to current application's NSSharingService
		property NSArray : a reference to current application's NSArray
		property NSString : a reference to current application's NSString
		property NSRunLoop : a reference to current application's NSRunLoop
		property NSDate : a reference to current application's NSDate
		property NSURL : a reference to current application's NSURL
		
		on StartAirDrop(inputItems)
			-- CHECK INPUT
			set itemsList to {}
			if the class of inputItems is not list then
				if (inputItems as string) begins with "~" then
					set abbreviatedItemPath to NSString's stringWithString:inputItems
					set posixFilePath to abbreviatedItemPath's stringByExpandingTildeInPath()
				else
					set posixFilePath to the POSIX path of inputItems
				end if
				set itemURL to NSURL's fileURLWithPath:posixFilePath
				set the end of the itemsList to itemURL
			else
				repeat with i from 1 to the count of inputItems
					set thisItem to item i of inputItems
					if (thisItem as string) begins with "~" then
						set abbreviatedItemPath to (NSString's stringWithString:thisItem)
						set posixFilePath to abbreviatedItemPath's stringByExpandingTildeInPath()
					else
						set posixFilePath to the POSIX path of thisItem
					end if
					set thisItemURL to (NSURL's fileURLWithPath:posixFilePath)
					set the end of the itemsList to thisItemURL
				end repeat
			end if
			
			-- CREATE ARRAY AND SHOW AIRDROP
			set the AirDropArrray to NSArray's arrayWithArray:itemsList
			if current application's NSThread's isMainThread() then
				my showAirDrop:(AirDropArrray)
			else
				its performSelectorOnMainThread:"showAirDrop:" withObject:(AirDropArrray) waitUntilDone:true
			end if
			
		end StartAirDrop
		
		on showAirDrop:AirDropArrray
			-- CREATE NEW SHARING SERVICE INSTANCE
			set AirDropSharingService to ¬
				NSSharingService's sharingServiceNamed:(current application's NSSharingServiceNameSendViaAirDrop)
			-- CALL SHARING SERVICE
			tell AirDropSharingService to performWithItems:AirDropArrray
			-- work-around added to trigger Sharing frameworks
			NSRunLoop's currentRunLoop's runUntilDate:(NSDate's |date|)
		end showAirDrop:
	end script
	return theScript's StartAirDrop(inputItems)
end StartAirDrop


Works perfectly, but after the AirDrop is done, the box is still there.
To remove the box, I have to quit the BetterTouchTool.
How can I fix that?

@fortred2 can you help, please?

@sid11 I don't have time to look into this. However, I can share with you this project: GitHub - vldmrkl/airdrop-cli: A macOS CLI for AirDrop written in Swift

It's a CLI that I've used to create AirDrop automations.

so, install this and trigger using it using BTT?

@sid11 Yes. Here's a simple demonstration. Assign a Keyboard Shortcut to trigger a Run Real JavaScript BTT Action containing this script:

async function someJavaScriptFunction() {
  let path_or_url = await get_clipboard_content("public.file-url", false);
  
  let cfg = {
    script: `/opt/homebrew/bin/airdrop ${path_or_url}`,
    launchPath: "/bin/bash",
    parameters: "-c",
  };
  let result = await runShellScript(cfg);
  
  return result;
}

replaced it with your solution still getting the box


also it works with clipboard item not select one in the finder

@Andreas_Hegenberg quitting BTT removes the shadow box.

both applescript and JS version of @fortred2 leaves shadow

but quitting, BTT removes applescript airdrop shadow
the one @fortred2 give remains even after quitting
i had to restart to remove the shadow

@sid11 I intentionally crafted the script to obtain the public.file-url UTI of the clipboard so that it could be more versatile, working for files from Finder as well as URLs from a browser. The script could be modified to work with selection instead.

I don't see the shadow using the JS script that uses the airdrop CLI. What version of macOS are you running? And what's your BTT version?

macOS 15.6
BTT is latest alpha release

@sid11 do you see the shadow if you use the airdrop CLI directly in the terminal?

Also, please post the exact BTT version - not just "the latest one".

using cli also does it

it if i close the terminal the box goes away....

also if I click anywhere else and not device in airdrop, it close the airdrop box instead of sending the item...the box shadow remains.

Can we automate it context menu of selected item? instead of right click share, then airdrop then clicking it?

BTT version is 5.554

@fortred2 do you think this is a bug in OS?

@Andreas_Hegenberg can you please guide?

Sounds like a macOS bug to me, but it seems to work fine here. Unfortunately I haven't heard of this issue before.

You are on macos 15.6?

@sid11 I found this issue on Github. It appears to be the same issue you're experiencing:

The fix suggested in the comments are to uninstall the CLI and then reinstall it using brew install --HEAD airdrop-cli.

i will try

how can we also send selected item from finder?
like if there if i trigger without selecting anyfile, the send the clipboard file else send the selected.

also, why am i getting the box in applescript also?