How to start a Hangouts phone call with Applescript/Terminal

applescriptautomationgoogle

I want to initiate a Google Hangouts phone call with Applescript.

Hangouts has an AS dictionary, but with only the default suites.

I want to emulate opening the Hangouts popup, typing in a phone number, and starting the call.

I looked at Hangouts API, but it is beyond me. But I think it could be done by calling python or ruby scripts from Terminal.

(I would like to integrate this into Butler's action-on-phone-number feature.)

Best Answer

This script I wrote works for me. You may need to adjust a few of the delay values, depending on the speed in which your computer launches your browser etc.

I actually wrote this script and saved it as an application and then I enabled it as a dictation command

tell application "Safari"
    activate
    set URL of document 1 to "https://hangouts.google.com/"
    delay 8 --adjust this value if needed
    set the clipboard to "1-234-567-8910" -- enter the real phone number
    tell application "System Events"
        click button 5 of UI element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window "Google Hangouts" of application process "Safari"
        delay 1
        click button "New conversation" of UI element 1 of scroll area 1 of group 11 of UI element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window "Google Hangouts" of application process "Safari"
        keystroke (the clipboard)
        delay 2
        key code 36
    end tell
end tell