Skype4COM: Command.vbs

Skype4COM

Command.vbs

This script sends blocking and non-blocking commands to the Skype API.

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

'// Skype4COM can send two types of command; blocking commands and non-blocking commands. Blocking is defined as a Boolean variant of the command object and the default value is False, non-blocking. A blocking command awaits a reply before continuing. A non-blocking command does not require a reply. 

'// Send the following non-blocking commands:
oSkype.SendCommand(oSkype.Command(0, "FOCUS"))
oSkype.SendCommand(oSkype.Command(1, "GET AUDIO_IN", "AUDIO_IN"))
oSkype.SendCommand(oSkype.Command(2, "GET AUDIO_OUT", "AUDIO_OUT"))
WScript.Sleep(1000)

'// Send the following blocking commands (note the True (blocking) variant for each command):
oSkype.SendCommand(oSkype.Command(3, "GET CURRENTUSERHANDLE", "CURRENTUSERHANDLE", True))
oSkype.SendCommand(oSkype.Command(4, "GET USER echo123 FULLNAME", "USER echo123 FULLNAME", True))
oSkype.SendCommand(oSkype.Command(5, "GET USER echo123 DISPLAYNAME", "USER echo123 DISPLAYNAME", True))
oSkype.SendCommand(oSkype.Command(6, "GET USER echo123 COUNTRY", "USER echo123 COUNTRY", True))
WScript.Sleep(1000)

'//As with command objects, search commands can be defined as blocking or non-blocking, and the default value is False, non-blocking. A blocking search requires a response before activities continue. Following is a blocking search (note the True (blocking) variant:
Set oBlockingSearch = oSkype.Command(8888, "SEARCH USERS echo123", "USERS ", True)
oSkype.SendCommand(oBlockingSearch)
WScript.Echo "Search Result:" & oBlockingSearch.Reply

'//A non-blocking search does not require a response:
Set oSearchCommand = oSkype.Command(9999, "SEARCH USERS john doe", "USERS ")
oSkype.SendCommand(oSearchCommand)

WScript.Echo "Sleeping ..."
WScript.Sleep(30000)

'// 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 reply event handler monitors the non-blocking search results:
Public Sub Skype_Reply(ByRef aCmd)  
  If IsObject(oSearchCommand) Then 
    If oSearchCommand.Id = aCmd.Id Then WScript.Echo "Search Finished!" End If
  End If
End Sub

Copyright � 2006 Skype Limited. All rights reserved.