Jake.codes

Control Skype, for Alfred

Thursday, February 07, 2013

This workflow lets you set a keyboard command for answering an incoming call and hanging up on a current call. It also gives you a keyword action in Alfred for typing call and then a phone number or Skype username. This is based on Brett Terpstra’s Answer Skype with a Hotkey code.

Download the complete workflow

on alfred_script(q)
  tell application "System Events"
        set onSkype to (count of (every process whose bundle identifier contains "Skype")) > 0
    end tell
    
    if onSkype then
        tell application "Skype"
            set calls to send command "SEARCH ACTIVECALLS" script name "AnsweringScript"
            set callID to last word of calls
            if callID is not "CALLS" then
                set status to send command "GET CALL " & callID & " STATUS" script name "AnsweringScript"
                if last word of status is "RINGING" then
                    send command "ALTER CALL " & callID & " ANSWER" script name "AnsweringScript"
                    return
                else
                    send command "ALTER CALL " & callID & " HANGUP" script name "AnsweringScript"
                end if
            else
                send command "CALL " & (q as text) script name "Alfred"
            end if
        end tell
    else
        tell application "Skype"
            activate
        end tell
    end if
end alfred_script