Skype4COM: Answer.vbs

Skype4COM

Answer.vbs

This script sets up automatic answering of incoming calls.

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

'// Connect to the Skype API:
oSkype.Attach

'// Run an infinite loop to ensure the connection remains active: 
Do While True 
  WScript.Sleep(60000) 
Loop

'// 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 if the status is "ringing" and it is an incoming call, it attempts to answer the call: 
Public Sub Skype_CallStatus(ByRef aCall, ByVal aStatus)
  WScript.Echo  ">Call " & aCall.Id & " status " & aStatus & " " & oSkype.Convert.CallStatusToText(aStatus)
  If oSkype.Convert.TextToCallStatus("RINGING") = aStatus And _
    (oSkype.Convert.TextToCallType("INCOMING_P2P") = aCall.Type Or _
     oSkype.Convert.TextToCallType("INCOMING_PSTN") = aCall.Type) Then 
     WScript.Echo "Answering call from " & aCall.PartnerHandle
     If aCall.TargetIdentity <> "" Then
       WScript.Echo "Call target identity: " & aCall.TargetIdentity
     End If
     aCall.Answer() 
  End If
End Sub


Copyright � 2006 Skype Limited. All rights reserved.