WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples from Users

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

SkyPe Enumerate Contacts

 Keywords: SkyPe Enumerate List Contacts Skype4COM.Skype 

;Winbatch 2010C - Playing with the Skype API
;
;Simple Script - just intends to enumerate contact list
;The secret is to allow Access to Skype API from Winbatch
;The first time you run the script, make sure Skype is open
;and visible. You should see a message or pop-up asking
;permission - click allow. After that, under Tools|Options|Advanced| Manage Other Program Access
;you should see Winbatch on the list
;
;Stan Littlefield, December 4 2010
;//////////////////////////////////////////////////////////////////////////////////////////////////////
IntControl(73,1,0,0,0)
GoSub udfs
aStatus=1
oSkype = CreateObject("Skype4COM.Skype", "Skype_")
ObjectEventAdd(oSkype, "AttachmentStatus", "AttachmentStatus")
oSkype.TimeOut=20000
If !oSkype.Client.IsRunning Then oSkype.Client.Start(@TRUE)
;Create a short delay to ensure program loads
Display(10,"Please Wait","Opening Skype API")
While 1
  If oSkype.AttachmentStatus == oSkype.Convert.TextToAttachmentStatus("AVAILABLE") Then oSkype.Attach(5,@FALSE)
  If oSkype.AttachmentStatus == oSkype.Convert.TextToAttachmentStatus("SUCCESS") Then Break
  If oSkype.CurrentUserStatus == 0 Then oSkype.ChangeUserStatus(1)
EndWhile

contacts=oSkype.CurrentUserHandle:" Contacts:":@CRLF
For i=1 To oSkype.Friends.Count
   contacts=contacts:oSkype.Friends(i).Handle:@CRLF
Next

Message("Contacts",contacts)

:End
ObjectEventRemove(oSkype,"AttachmentStatus")
oSkype=0
Exit
;//////////////////////////////////////////////////////////////////////////////////////////////////////

:WBERRORHANDLER
IntControl(73,1,0,0,0)
ErrorProcessing(1,1,0,0)
Exit

;//////////////////////////////////////////////////////////////////////////////////////////////////////
:udfs
#DefineSubRoutine ErrorProcessing(deleteIni,showerr,logfile,Err_Array)
If VarType(Err_Array) ==256
   WbError = Err_Array[0]
   wberrorhandlerline = Err_Array[1]
   wberrorhandleroffset = Err_Array[2]
   wberrorhandlerassignment = Err_Array[3]
   wberrorhandlerfile = Err_Array[4]
   wberrortextstring = Err_Array[5]
   wberroradditionalinfo = Err_Array[6]
   wberrorinsegment = Err_Array[7]
Else
   WbError = LastError()
EndIf
WbTextcode = WbError
If WbError==1668||WbError==2669||WbError==3670
   WbError = ItemExtract(1,IntControl(34,-1,0,0,0),":")
   WbTextcode = -1
EndIf
WbErrorString = IntControl(34,WbTextcode,0,0,0)
WbErrorDateTime = TimeYmdHms()
If deleteIni
   WbErrorFile = StrCat(ShortCutDir( 'AppData', 0, 0 ),'\WinBatch\Settings\')
   If ! DirExist(WbErrorFile) Then WbErrorFile = DirWindows(0)
   WbErrorFile = StrCat(WbErrorFile,"WWWBATCH.INI")
   FileDelete(WbErrorFile)
   IniWritePvt(WbErrorDateTime,"CurrentScript",WbErrorHandlerFile      ,WbErrorFile)
   IniWritePvt(WbErrorDateTime,"ErrorValue"   ,WbError                 ,WbErrorFile)
   IniWritePvt(WbErrorDateTime,"ErrorString"  ,WbErrorString           ,WbErrorFile)
   IniWritePvt(WbErrorDateTime,"ScriptLine"   ,WbErrorHandlerLine      ,WbErrorFile)
   IniWritePvt(WbErrorDateTime,"ScriptOffset" ,WbErrorHandlerOffset    ,WbErrorFile)
   IniWritePvt(WbErrorDateTime,"VarAssignment",WbErrorHandlerAssignment,WbErrorFile)
   IniWritePvt(WbErrorDateTime,"VarInSegment" ,WbErrorInSegment,WbErrorFile)
   IniWritePvt("","","",WbErrorFile)
EndIf
WbErrorMsgText = StrCat(WbErrorDateTime,@CRLF)
WbErrorMsgText = StrCat(WbErrorMsgText,"Current Script: ",WbErrorHandlerFile,@CRLF)
WbErrorMsgText = StrCat(WbErrorMsgText,"Error# [",WbError,"]",@CRLF)
WbErrorMsgText = StrCat(WbErrorMsgText,"Error Text: ",wberrortextstring,@CRLF)
WbErrorMsgText = StrCat(WbErrorMsgText,"[Extended Information] ",wberroradditionalinfo,@CRLF,@CRLF)
WbErrorMsgText = StrCat(WbErrorMsgText,"On Line:",@CRLF,WbErrorHandlerLine,@CRLF)
;WbErrorMsgText = StrCat(WbErrorMsgText,"Offset: ",WbErrorHandlerOffset,@CRLF)
If (WbErrorHandlerAssignment>"") Then %WbErrorHandlerAssignment% = "UNKNOWN"
WbErrorMsgText = StrCat(WbErrorMsgText,"Assignment/Variable: ",WbErrorHandlerAssignment,@CRLF)
If (WbErrorInSegment>"") Then WbErrorMsgText = StrCat(WbErrorMsgText,"In UDF/UDS: ",WbErrorInSegment,@CRLF)
If logfile
   cSep = StrCat(StrFill("=",50),@CRLF)
   cLogFile = StrCat(DirScript(),"log.err")
   If ! FileExist(cLogFile) Then FilePut(cLogFile,StrCat("Error Log",@CRLF,cSep))
   FilePut(cLogFile,StrCat(FileGet(cLogFile),WbErrorMsgText,cSep))
   Display(2,"An Error Occured",StrCat("written to ",cLogFile))
Else
   If showerr
      WbErrorMsgText = StrCat(WbErrorMsgText,"[THIS ERROR NOT WRITTEN TO LOG FILE]",@CRLF)
      Message("An Error Was Encountered",WbErrorMsgText)
   EndIf
EndIf
Return(1)
#EndSubRoutine

#DefineSubRoutine AttachmentStatus(aStatus)
If aStatus == oSkype.Convert.TextToAttachmentStatus("SUCCESS")
   Display(2,"Status","Current user is ":oSkype.CurrentUserHandle)
Else
   Display(2,"Please Wait","Attaching To Skype Client ":oSkype.Convert.TextToAttachmentStatus(aStatus))
EndIf
Return(oSkype.AttachmentStatus)
#EndSubRoutine

Return
;//////////////////////////////////////////////////////////////////////////////////////////////////////

Article ID:   W18177
Filename:   SkyPe Enumerate Contacts.txt
File Created: 2010:12:06:09:22:18
Last Updated: 2010:12:06:09:22:18