Skype4COM: Join.vbs

Skype4COM

Join.vbs

This script joins callers to form a conference call.

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")
cCallStatus_LocalHold = oSkype.Convert.TextToCallStatus("LOCALHOLD")

'// 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  

'// Place a call (the first of more than one):
Set oCall1 = oSkype.PlaceCall("skypeuser1")
WaitForCallStatus oCall1, cCallStatus_Inprogress

'// Put the first call on hold:
oCall1.Hold
WaitForCallStatus oCall1, cCallStatus_LocalHold

'// Place the second call:
Set oCall2 = oSkype.PlaceCall("skypeuser2")
WaitForCallStatus oCall2, cCallStatus_Inprogress

'// Join these two calls to a conference:
WScript.Echo "Join call " & oCall2.Id & " to call " & oCall1.Id
oCall2.Join oCall1.Id

WScript.Sleep(60000)

'// 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 = oSkype.Convert.TextToAttachmentStatus("AVAILABLE") Then oSkype.Attach() End If
End Sub

'// The CallStatus event handler monitors call status and returns status changes as text:
Public Sub Skype_CallStatus(ByRef oCall, ByVal Status)
  WScript.Echo ">Call " & oCall.Id & " status " & Status & " " & oSkype.Convert.CallStatusToText(Status)
End Sub

'// Waits for call status to change:
Public Sub WaitForCallStatus(ByRef aCall, ByVal aStatus)
  Do While aCall.Status <> aStatus
    If aCall.Status = cCallStatus_Failed Or _
      aCall.Status = cCallStatus_Refused Or _
      aCall.Status = cCallStatus_Cancelled Or _
      aCall.Status = cCallStatus_Finished Or _
      aCall.Status = cCallStatus_Busy Then
      Err.Raise vbObjectError + 1, "", "Call " & _
        aCall.Id & " " & oSkype.Convert.CallStatusToText(aCall.Status)
    End If    
    WScript.Sleep(500)
  Loop  
End Sub


Copyright � 2006 Skype Limited. All rights reserved.