-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAirDrop.applescript
40 lines (30 loc) · 1.16 KB
/
AirDrop.applescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
-- This script brings up the AirDrop dialog for the selected file(s) in Finder (window or desktop)
-- Isaac Nelson 17 Jan 2018
-- Vastly improved by implementing Aviral Bansal's fix for UI scripting slowness: https://stackoverflow.com/a/36370637/9278116
-- Updated 28 Mar 2018 to make it work in an Automator workflow
-- Updated 17 Dec 2019 to fix issue with comparison between parentPath and desktopPath
tell application "Finder"
set sel to get the selection
if (sel is {}) then
log "Nothing selected! Can't proceed"
return
end if
set parentPath to (container of item 1 of sel) as alias
set desktopPath to (path to desktop folder)
if desktopPath is equal to parentPath then reveal sel
end tell
tell application "System Events"
tell process "Finder"
set shareButton to (first button whose description is "Share") of toolbar 1 of window 1
ignoring application responses
click shareButton
delay 0.1
end ignoring
end tell
end tell
do shell script "killall System\\ Events"
tell application "System Events"
click (menu item "AirDrop") of menu 1 of shareButton
end tell