applescript让Skype打电话和播放歌曲

时间:2015-02-16 21:13:31

标签: macos applescript skype

嗨,我正在尝试使用这个脚本用AppleScript制作一部手机,并在iTunes中播放一首歌。

脚本的所有部分都可以工作但是放在一起它不起作用。

我总是得到同样的错误,一次有效,但无法复制。

脚本是:

set audioFilename to "Silly_Farts-Joe-1473367952"

-- Mostly from  http://forum.skype.com/viewtopic.php?t=29120
tell application "Skype"
    send command "CALL +0112345678" script name "phoneOut"
    set calls to send command "SEARCH ACTIVECALLS" script name "phoneOut"
    set callID to last word of calls
    repeat
        set status to send command "GET CALL " & callID & " STATUS" script name "phoneOut"
        if last word of status is not "ROUTING" then exit repeat
    end repeat
    repeat
        set status to send command "GET CALL " & callID & " STATUS" script name "phoneOut"
        if last word of status is "INPROGRESS" then exit repeat
    end repeat
end tell

-- From various apple scripts
tell application "iTunes"
    activate
    tell source "Library"
        tell playlist "Library"
            set toPlay to track audioFilename
            play toPlay
        end tell
    end tell
    set trackTime to duration of toPlay
    delay trackTime
    stop
end tell

-- From those forum blokes again
tell application "Skype"
    send command "SET CALL " & callID & " STATUS FINISHED" script name "phoneOut"
end tell

事件日志看起来像这样。

tell application "Skype"
    send command "CALL +0123456789" script name "phoneOut"
        --> "CALL 5357 STATUS UNPLACED"
    send command "SEARCH ACTIVECALLS" script name "phoneOut"
        --> "CALLS "
    send command "GET CALL CALLS STATUS" script name "phoneOut"
        --> "ERROR 11 Invalid call id"
    send command "GET CALL CALLS STATUS" script name "phoneOut"
        --> "ERROR 11 Invalid call id"
    send command "GET CALL CALLS STATUS" script name "phoneOut"
        --> "ERROR 11 Invalid call id"
    send command "GET CALL CALLS STATUS" script name "phoneOut"
        --> "ERROR 11 Invalid call id"

1 个答案:

答案 0 :(得分:0)

好的发现了问题,我认为SEARCH ACTIVECALLS已从api中移除。

我找到了命令搜索呼叫,它给你所有的呼叫,但最新的呼叫始终是第一个。所以这将有效

set calls to send command "SEARCH CALLS" script name "phoneOut"
set callID to second word of calls