Skip to content

Instantly share code, notes, and snippets.

@willwade
Last active May 10, 2023 00:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save willwade/b38de2f1e1b22c510c4deba981fbaf16 to your computer and use it in GitHub Desktop.
Save willwade/b38de2f1e1b22c510c4deba981fbaf16 to your computer and use it in GitHub Desktop.
property delayInterval : 15 -- seconds
on run
activate
tell application "System Events" to set UIAccessStatus to UI elements enabled
end run
on idle
try
tell application "System Events"
tell process "NotificationCenter"
set theseAlerts to (every window whose subrole is "AXNotificationCenterAlert")
repeat with i from 1 to the count of theseAlerts
set thisWindow to item i of theseAlerts
set theseTextStrings to the value of static text of thisWindow
-- added second check for notification changes in El Capitan
if theseTextStrings contains "AirDrop" then
if exists button "Accept" of thisWindow then
click button "Accept" of thisWindow
else if exists menu button "Save to Downloads" of thisWindow then
click menu button "Save to Downloads" of thisWindow
else if exists menu button "Accept" of thisWindow then
click menu button "Accept" of thisWindow
end if
end if
end repeat
end tell
end tell
return delayInterval -- run the idle handler again after the indicated time delay
on error errorMessage number errorNumber
activate
display alert (errorNumber as string) message errorMessage
tell me to quit
end try
end idle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment