Skype4COM 1.0.36.0
|
Call.vbs
This script places a call through the Skype API, and monitors status while the call is in progress.
Copyright � 2004-2006 Skype Limited. Licensed under BSD license.
'// Create a Skype4COM object: Set oSkype = WScript.CreateObject("Skype4COM.Skype", "Skype_") '// Start the Skype client: If Not oSkype.Client.IsRunning Then oSkype.Client.Start() End If '// Declare the following Skype constants: cUserStatus_Offline = oSkype.Convert.TextToUserStatus("OFFLINE") cUserStatus_Online = oSkype.Convert.TextToUserStatus("ONLINE") cCallStatus_Ringing = oSkype.Convert.TextToCallStatus("RINGING") cCallStatus_Inprogress = oSkype.Convert.TextToCallStatus("INPROGRESS") cCallStatus_Failed = oSkype.Convert.TextToCallStatus("FAILED") cCallStatus_Refused = oSkype.Convert.TextToCallStatus("REFUSED") cCallStatus_Cancelled = oSkype.Convert.TextToCallStatus("CANCELLED") cCallStatus_Finished = oSkype.Convert.TextToCallStatus("FINISHED") cCallStatus_Busy = oSkype.Convert.TextToCallStatus("BUSY") cAttachmentStatus_Available = oSkype.Convert.TextToAttachmentStatus("AVAILABLE") '// The PlaceCall command will fail if the user is offline. To avoid failure, check user status and change to online if necessary: If cUserStatus_Offline = oSkype.CurrentUserStatus Then oSkype.ChangeUserStatus(cUserStatus_Online) End If '// Create a user object: Set oUser = oSkype.User("echo123") WScript.Echo "User " & oUser.Handle & " online status is " & oSkype.Convert.OnlineStatusToText(oUser.OnlineStatus) '// Place a call: Set oCall = oSkype.PlaceCall(oUser.Handle) '// Wait until the call is in progress and return the relevant error if any other status occurs: Do While oCall.Status <> cCallStatus_Inprogress If oCall.Status = cCallStatus_Failed Or _ oCall.Status = cCallStatus_Refused Or _ oCall.Status = cCallStatus_Cancelled Or _ oCall.Status = cCallStatus_Finished Or _ oCall.Status = cCallStatus_Busy Then Err.Raise vbObjectError + 1, "", "Call status: " & oSkype.Convert.CallStatusToText(oCall.Status) End If WScript.Sleep(500) Loop '// Check sending DTMF tones for use with interactive voice response (IVR) applications: WScript.Sleep(10000) If cCallStatus_InProgress = oCall.Status Then oCall.DTMF = "0" End If WScript.Sleep(500) If cCallStatus_InProgress = oCall.Status Then oCall.DTMF = "1" End If WScript.Sleep(500) If cCallStatus_InProgress = oCall.Status Then oCall.DTMF = "2" End If WScript.Sleep(500) If cCallStatus_InProgress = oCall.Status Then oCall.DTMF = "3" End If WScript.Sleep(500) If cCallStatus_InProgress = oCall.Status Then oCall.DTMF = "4" End If WScript.Sleep(500) If cCallStatus_InProgress = oCall.Status Then oCall.DTMF = "5" End If WScript.Sleep(500) If cCallStatus_InProgress = oCall.Status Then oCall.DTMF = "6" End If WScript.Sleep(500) If cCallStatus_InProgress = oCall.Status Then oCall.DTMF = "7" End If WScript.Sleep(500) If cCallStatus_InProgress = oCall.Status Then oCall.DTMF = "8" End If WScript.Sleep(500) If cCallStatus_InProgress = oCall.Status Then oCall.DTMF = "9" End If WScript.Sleep(500) If cCallStatus_InProgress = oCall.Status Then oCall.DTMF = "#" End If WScript.Sleep(500) If cCallStatus_InProgress = oCall.Status Then oCall.DTMF = "*" End If WScript.Sleep(500) '// Finish the call: If oCall.Status <> cCallStatus_Finished Then oCall.Finish() End If '// The AttachmentStatus event handler monitors attachment status and automatically attempts to reattach to the API following loss of connection: Public Sub Skype_AttachmentStatus(ByVal aStatus) WScript.Echo ">Attachment status " & oSkype.Convert.AttachmentStatusToText(aStatus) If aStatus = cAttachmentStatus_Available Then oSkype.Attach() End If End Sub '// If the call status is "failed", the CallStatus event handler returns the relevant failure reason as text: Public Sub Skype_CallStatus(ByRef aCall, ByVal aStatus) WScript.Echo ">Call " & aCall.Id & " status " & aStatus & " " & oSkype.Convert.CallStatusToText(aStatus) If cCallStatus_Failed = aStatus Then WScript.Echo ">Failure reason:" & oSkype.Convert.CallFailureReasonToText(aCall.FailureReason) End If End Sub
Copyright � 2006 Skype Limited. All rights reserved.