Last active
July 2, 2020 16:15
-
-
Save lazd/9a267fbba38dd27825f483389adc06e9 to your computer and use it in GitHub Desktop.
Automatically answer FaceTime calls from a given set of contacts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
FaceTime Auto-answer | |
Automatically answer FaceTime calls from a given set of contacts | |
Sources: | |
https://blakeembrey.com/posts/2015-06-facetime-auto-answer | |
https://github.com/PaperCutSoftware/teleportme/issues/17#issuecomment-517218493 | |
*) | |
set contacts to {"Manali Davis", "Leah Davis", "Larry Davis", "Eileen Keveny", "Pam Roberts", "Allison Lutge", "Michelle Miller"} | |
log "Will auto-answer FaceTime calls from:" | |
repeat with i from 1 to length of contacts | |
set contact to item i of contacts | |
log " • " & contact | |
end repeat | |
repeat | |
repeat while application "NotificationCenter" is running | |
tell application "System Events" | |
tell process "NotificationCenter" | |
set acceptButton to a reference to (button "Accept" of window 1 of application process "NotificationCenter" of application "System Events") | |
if acceptButton exists then | |
set callerId to value of static text 2 of window 1 of application process "NotificationCenter" of application "System Events" | |
set dateObj to (current date) | |
set timeStr to (time string of dateObj) | |
set monthStr to month of dateObj as string | |
set dayStr to day of dateObj | |
set yearStr to year of dateObj | |
set dateStr to monthStr & " " & dayStr & ", " & yearStr | |
if contacts contains callerId then | |
log dateStr & " " & timeStr & ": Answering FaceTime call from " & callerId | |
click acceptButton | |
else | |
log dateStr & " " & timeStr & ": Ignoring FaceTime call from " & callerId | |
end if | |
end if | |
end tell | |
end tell | |
delay 2 | |
end repeat | |
delay 5 | |
end repeat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I know the
tell
aspect of this makes no sense, but it works.