Skype4COM: Plugins.vbs

Skype4COM

Plugins.vbs

This script demos how to create plugin menu items and events.

Copyright � 2004-2006 Skype Limited. Licensed under BSD license.

const pluginContextChat = 0
const pluginContextCall = 1
const pluginContextContact = 2
const pluginContextMyself = 3
const pluginContextTools = 4

const pluginContactTypeUndefined = -1
const pluginContactTypeAll = 0  
const pluginContactTypeSkype = 1  
const pluginContactTypeSkypeOut= 2 

const pluginIconPath = "c:\temp\icon.png"  

Set oSkype = WScript.CreateObject("Skype4COM.Skype", "Skype_")

Set oMenu1 = oSkype.Client.CreateMenuItem("menu1", pluginContextContact, ""&_
  "Single Contact of Any Type", "Plugin that does cool stuff for single contact of any type", pluginIconPath, True, pluginContactTypeAll)

Set oMenu2 = oSkype.Client.CreateMenuItem("menu2", pluginContextContact, ""&_
  "Single Skype Contact", "Plugin that does cool stuff for single Skype contact", pluginIconPath, True, pluginContactTypeSkype, False)

Set oMenu3 = oSkype.Client.CreateMenuItem("menu3", pluginContextContact, ""&_
  "Multiple Skype Contacts", "Plugin that does cool stuff for multple contacts", pluginIconPath, True, pluginContactTypeSkype, True)

Set oMenu4 = oSkype.Client.CreateMenuItem("menu4", pluginContextContact, ""&_
  "Single SkypeOut Contact", "Plugin that does cool stuff for a single SkypeOut contact", pluginIconPath, True, pluginContactTypeSkypeOut, False)

Set oMenu5 = oSkype.Client.CreateMenuItem("menu5", pluginContextContact, ""&_
  "Multiple SkypeOut Contacts", "Plugin that does cool stuff for a one or more SkypeOut contacts", pluginIconPath, True, pluginContactTypeSkypeOut, True)
  
Set oMenu6 = oSkype.Client.CreateMenuItem("menu6", pluginContextCall, ""&_
  "Single Participant Call", "Plugin that does cool stuff in a call", pluginIconPath, True, pluginContactTypeUndefined, False)

Set oMenu7 = oSkype.Client.CreateMenuItem("menu7", pluginContextCall, ""&_
  "Multiple Participants Call", "Plugin that does cool stuff in a conference call", pluginIconPath, True, pluginContactTypeUndefined, True)
  
Set oMenu8 = oSkype.Client.CreateMenuItem("menu8", pluginContextChat, ""&_
  "Single Chat Member", "Plugin that does cool stuff for one-to-one chat", pluginIconPath, True, pluginContactTypeUndefined, False)

Set oMenu9 = oSkype.Client.CreateMenuItem("menu9", pluginContextChat, ""&_
  "Multiple Chat Members", "Plugin that does cool stuff in group chat", pluginIconPath, True, pluginContactTypeUndefined, True)
  
Set oMenu10 = oSkype.Client.CreateMenuItem("menu10", pluginContextTools, ""&_
  "Tools plugin", "Plugin that does cool stuff in tools menu", pluginIconPath, True, pluginContactTypeUndefined, False)

Set oEvent = oSkype.Client.CreateEvent("event1","Plugin example is running","Click here to stop the example")
Do While Not bEventClicked
  WScript.Sleep(1000)
Loop
oEvent.Delete
oMenu1.Delete
oMenu2.Delete
oMenu3.Delete
oMenu4.Delete
oMenu5.Delete
oMenu6.Delete
oMenu7.Delete
oMenu8.Delete
oMenu9.Delete
oMenu10.Delete

Public Sub Skype_PluginEventClicked(ByVal aEvent)
  WScript.Echo ">Event "& aEvent.Id &" clicked."
  bEventClicked = True  
End Sub

Public Sub Skype_PluginMenuItemClicked(ByRef aMenuItem, ByRef aUsers, ByVal aPluginContext, ByVal aContextId)
  WScript.Echo ">Menu item ["& aMenuItem.Id &"] context [" & pluginContextToText(aPluginContext) & "] id ["& aContextId &"] clicked."
  For Each oUser In aUsers
    WScript.Echo " User: "& oUser.FullName &" (" & oUser.Handle &")"
  Next
End Sub

Function pluginContextToText (context)
   Select Case context
   Case pluginContextChat
      pluginContextToText = "Chat"
   Case pluginContextCall
      pluginContextToText = "Call"
   Case pluginContextContact
      pluginContextToText = "Contact"
   Case pluginContextMyself
      pluginContextToText = "Myself"
   Case pluginContextTools
      pluginContextToText = "Tools"      
   End Select
End Function

Copyright � 2006 Skype Limited. All rights reserved.