使用Mac上的Skype API自动将来电添加到会议

时间:2013-01-31 01:24:04

标签: macos api automation applescript skype

我正在尝试编写一个AppleScript,它将启动Skype并呼叫谁在线并在会议开始后自动添加来电。我被困在这个实现的最后部分(在下面的代码中加注)。重复循环中的代码。

是否可以帮我实现一种方法,将来电添加到现有的电话会议中,而不会将电话置于保持状态?

提前致谢!

我的系统是Mac OS X Lion(10.7.5)

PS。到目前为止,我从其他人的作品中得到了很多帮助。我就是这样做的。

tell application "System Events"
    set powerCheck to ((application processes whose (name is equal to "Skype")) count)
    if powerCheck = 0 then
        my launch_skype()
    else if powerCheck = 1 then
        return
    end if
end tell

## FUNCTIONS ##
on dismiss_skype_api_security()
    tell application "System Events" to tell process "Skype"
        set window_name to "Skype API Security"
        set ok_text to "OK"
        set radio_text to "Allow this application to use Skype"
        tell application "System Events" to tell process "Skype"
            if window window_name exists then
                click radio button radio_text of radio group 1 of window window_name
                delay 2
                click button ok_text of window window_name
            end if
        end tell
        delay 1
    end tell
end dismiss_skype_api_security

on launch_skype()
    tell application "Skype"
        set statusList to {"RINGING", "ROUTING", "UNPLACED"}
        delay 2
        try
            set status to "COMMAND_PENDING"
            repeat until status is not equal to "COMMAND_PENDING"
                set status to send command "GET USERSTATUS" script name "auto call"
                if status is equal to "COMMAND_PENDING" then
                    my dismiss_skype_api_security()
                end if
            end repeat

            #### CALL ONLINE CONTACTS + AUTO ACCEPT ####
            activate
            delay 1
            set OnlineContacts to my get_online_contacts()
            delay 1
            send command "CALL " & OnlineContacts script name "auto call"
            delay 2

            -- Set first call ID as master
            set firstCall to send command "SEARCH ACTIVECALLS" script name "auto call"
            set firstCallID to last word of firstCall -- What if the last guy leaves the call ?!?!?
            set firstStatus to send command "GET CALL " & firstCallID & " STATUS" script name "auto call"
            if statusList contains the last word of firstStatus then -- First Call
                set MasterCallID to firstCallID
            end if


          **set callID to ""
            repeat until callID is "CALLS"
                delay 3
                set status to send command "GET CALL " & firstCallID & " STATUS" script name "auto call"
                if the last word of status is "RINGING" then --Someone is calling to join the call
                    set calls to send command "SEARCH ACTIVECALLS" script name "auto call"
                    set callID to last word of calls
                    --send command "ALTER CALL " & callID & " JOIN_CONFERENCE " & mainCallID script name --"auto call"
                end if
            end repeat**

        on error number -2753
            quit
        end try
    end tell
end launch_skype

### GET ONLINE CONTACTS ###
on get_online_contacts()
    global OnlineFriends
    set OnlineFriends to {}
    tell application "Skype"
        set SkypeStatus to send command "GET CONNSTATUS" script name "auto call"
        if SkypeStatus is "CONNSTATUS ONLINE" then
            set AppleScript's text item delimiters to " "
            set Friends to send command "SEARCH FRIENDS" script name "auto call"
            set Friends to my ReplaceString(Friends, " ", ",")
            set Friends to my ReplaceString(Friends, ",,", ",")
            set FriendsList to my SplitList(Friends, ",")
            set NumFriends to number of items in FriendsList
            repeat with i in FriendsList
                if (i begins with "DISABLEDxmpp:") or (i begins with "USERS") or (i begins with "ugur") or (i is "echo123") or (i begins with "esr") or (i begins with "ayt") or (i begins with "Zaf") then
                else
                    set FriendStatus to send command "GET USER " & i & " ONLINESTATUS" script name "auto call"
                    if text item 4 of FriendStatus is "ONLINE" then
                        set aUser to i
                        set aUser to my JoinList(aUser, " ")
                        set end of OnlineFriends to aUser
                    end if
                end if
            end repeat
            if (count OnlineFriends) > 0 then
                set OnlineFriends to my JoinList(OnlineFriends, ", ")
            else
                set beginning of OnlineFriends to "No Skype Friends online at this time."
            end if
        else
            set beginning of OnlineFriends to "Skype is offline."
        end if
    end tell
    return OnlineFriends
end get_online_contacts

on JoinList(l, del)
    set RetVal to ""
    set OldDel to AppleScript's text item delimiters
    set AppleScript's text item delimiters to del
    set RetVal to l as string
    set AppleScript's text item delimiters to OldDel
    return RetVal
end JoinList

on SplitList(t, del)
    set RetVal to {}
    set OldDel to AppleScript's text item delimiters
    set AppleScript's text item delimiters to del
    set RetVal to every text item of t
    set AppleScript's text item delimiters to OldDel
    return RetVal
end SplitList

on ReplaceString(theText, oldString, newString)
    set OldDel to AppleScript's text item delimiters
    set AppleScript's text item delimiters to oldString
    set tempList to every text item of theText
    set AppleScript's text item delimiters to newString
    set theText to the tempList as string
    set AppleScript's text item delimiters to OldDel
    return theText
end ReplaceString

0 个答案:

没有答案