1

Here's the AppleScript code:
set phone_num to "1111111111"-- (put your own number here)

tell me to activate
display dialog "" buttons {"FaceTime", "Call", "Cancel"} default button 2 with icon path to resource "AppIcon.icns" in bundle (path to application "FaceTime")

-- FaceTime
if result = {button returned:"Yes"} then
do shell script "open facetime://" & quoted form of phone_num
tell application "System Events"
repeat while not (button "Call" of window 1 of application process "FaceTime" exists)
delay 1
end repeat
click button "Call" of window 1 of application process "FaceTime"
end tell

-- Call
else if result = {button returned:"Call"} then
tell application "FaceTime"
activate -- bring FaceTime to front
end tell
tell application "System Events"
tell process "FaceTime"
tell toolbar of window 1
-- click "Audio" window
click (first button where its accessibility description = "Audio")
-- put phone number in textbox
keystroke phone_num

-- CLICK "Call Using iPhone" button

end tell
end tell
end tell

-- Quit
else
tell application "FaceTime" to activate
delay 1
tell application "System Events" to keystroke "q" using {command down} -- quit FaceTime
end if

"Accessibility Inspector's" Hierarchy

0

Here is a little something that may shave a few lines from your code...

This works for me on the latest version of Sierra

set input to the (123 - 456 - 7890) --  Insert Telephone Number
open location "tel://" & input & "?audio=yes"
delay 1 --  You May Need To Adjust This Delay Value
tell application "System Events"
    key code 36
end tell
0

I have similar thing setup in Alfred. I use this to click on Call.

tell application "System Events" to click button "Call" of front window of application process "FaceTime"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.