I am currently working on a solution that allows me to queue Skype calls by getting numbers in an array and do a call for each number. Later on I will be adding controls to call specific numbers but I am willing to work on the "call the whole list" function.
The problem is that, in this presented way, the numbers "for" function loops too many times, the numbers are over and still, I get an error. Also I would like to say that the doCall() function is called upon call failed status else the script will break, I mean it won't continue the calling of the list. I am just beginning to understand the ways with AutoIt and would require some enlightening if anyone will be kind enough.
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include "GUIListViewEx.au3"
#include "GUIListView.au3"
#include "onEventFunc.au3"
;// Create a Skype4COM object:
$oSkype = ObjCreate("Skype4COM.Skype")
$oSkypeEvent = ObjEvent($oSkype,"Skype_")
$oError = ObjEvent("AutoIt.Error","MyErrFunc")
;// 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")
$cAttachmentStatus_Available = $oSkype.Convert.TextToAttachmentStatus("AVAILABLE")
;// Start the Skype client:
If Not $oSkype.Client.IsRunning Then
$oSkype.Client.Start()
EndIf
;// Verify that a user is signed in and online before continuing
While 1
If $oSkype.CurrentUserStatus = $oSkype.Convert.TextToUserStatus("ONLINE") Then
ExitLoop
Else
$oSkype.ChangeUserStatus($oSkype.Convert.TextToUserStatus("ONLINE"))
EndIf
Sleep(1000)
WEnd
;// 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)
EndIf
#Region ### START Koda GUI section ### Form=
Opt("GUIOnEventMode", 1) ; set to On event mode
;Opt("GUICoordMode", 2)
$Form1 = GUICreate("Cpoint - Skype Dialer v1.0", 615, 438, -1, -1, -1, 0x2000000)
;----- Make sure GUI exists BEFORE creating Tables -----
GUISetState()
$Label1 = GUICtrlCreateLabel("Introduceti numerele de telefon", 64, 24, 300, 28)
GUICtrlSetFont(-1, 15, 400, 0, "Trebouchet")
$Edit1 = GUICtrlCreateEdit("", 24, 64, 417, 297)
$Button1 = GUICtrlCreateButton("Call", 472, 160, 129, 81)
SetOnEventA(-1, "doCall", $paramByVal, 1)
$Label2 = GUICtrlCreateLabel("No operation started", 24, 392, 300, 24)
;GUICtrlSetOnEvent($Button1,"doCall") ; run NextClk if button is clicked
GUISetOnEvent($GUI_EVENT_CLOSE, "CloseClk") ; run CloseClk if form is closed
;GUISetState(@SW_LOCK)
#EndRegion ### END Koda GUI section ###
While 1
WEnd
Func CloseClk()
$answer = MsgBox(4, "Close software", "Do you really want to close the program ?")
; Check the user's answer to the prompt (see the help file for MsgBox return values)
; If "No" was clicked (7) then exit the script
If $answer = 6 Then
Exit
EndIf
EndFunc
;// The AttachmentStatus event handler monitors attachment status and automatically attempts to reattach to the API following loss of connection:
Func Skype_AttachmentStatus($aStatus)
;MsgBox(0,"","Attachment status " & $oSkype.Convert.AttachmentStatusToText($aStatus))
If $aStatus = $cAttachmentStatus_Available Then
$oSkype.Attach()
EndIf
EndFunc
;// If the call status is "failed", the CallStatus event handler returns the relevant failure reason as text:
Func MyErrFunc()
;Do Nothing
EndFunc
Func test()
;----- Table Example 4 -----
GUICtrlCreateLabel(" Example 4 ", 64, 24, 300, 28);, 24, 64, 417, 297
GUICtrlSetFont(-1, 15, 400, 0, "Trebouchet")
Global $iCount_Left = 1, $iCount_Right = 1, $vData
;If $hListView_Left > 0 Then
; Create Left ListView
$hListView_Left = GUICtrlCreateListView("Tom|Dick|Harry", 10, 60, 300, 300, $LVS_SHOWSELALWAYS)
_GUICtrlListView_SetExtendedListViewStyle($hListView_Left, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_SetColumnWidth($hListView_Left, 0, 93)
_GUICtrlListView_SetColumnWidth($hListView_Left, 1, 93)
_GUICtrlListView_SetColumnWidth($hListView_Left, 2, 93)
; Create array and fill Left listview
Global $aLV_List_Left[$iCount_Left]
_GUICtrlListView_BeginUpdate($hListView_Left)
For $i = 0 To UBound($aLV_List_Left) - 1
$aLV_List_Left[$i] = "Tom " & $i & "|Dick " & $i & "|Harry " & $i
GUICtrlCreateListViewItem($aLV_List_Left[$i], $hListView_Left)
Next
; Initiate LVEx - no count parameter - default insert mark colour (black)
$iLV_Left_Index = _GUIListViewEx_Init($hListView_Left, $aLV_List_Left)
GUISetState()
; Set neither ListView as active
_GUIListViewEx_SetActive(1)
_GuiCtrlListView_EndUpdate($hListView_Left)
;EndIf
EndFunc
Func doCall($indexNumber)
;If IsDeclared($indexNumber) Then
; Else
; $indexNumber = "1"
; EndIf
MsgBox(0,"Number",$indexNumber)
$numbers = ControlGetText ($Form1,$Button1,$Edit1);
If StringLen($numbers) < 1 Then
;MsgBox(0,"Eroare","Va rugam sa introduceti un numar de telefon")
GUICtrlSetData ($Label2, "Va rugam sa introduceti un numar de telefon")
Else
$numbersArray = StringSplit($numbers, ";");
For $i = $indexNumber to UBound($numbersArray)
;// Create a user object:
$oUser = $oSkype.User($numbersArray[$i])
;MsgBox(0,"","User " & $oUser.Handle & " online status is " & $oSkype.Convert.OnlineStatusToText($oUser.OnlineStatus))
;MsgBox(0,"",$oSkype.Convert.TextToCallStatus("INPROGRESS"))
;// Place a call:
$oCall = $oSkype.PlaceCall($oUser.Handle)
;// Wait until the call is in progress and return the relevant error if any other status occurs:
While $oCall.Status <> $cCallStatus_Finished
If $oCall.Status = $cCallStatus_Failed Or _
$oCall.Status = $cCallStatus_Refused Or _
$oCall.Status = $cCallStatus_Cancelled Or _
$oCall.Status = $cCallStatus_Ringing Or _
$oCall.Status = $cCallStatus_Busy Then
GUICtrlSetData ($Label2, "Call status: " & $oSkype.Convert.CallStatusToText($oCall.Status))
EndIf
If $oCall.Status = $cCallStatus_Failed Then
GUICtrlSetData ($Label2, "Call status: " & $oSkype.Convert.CallStatusToText($oCall.Status))
If $i >= UBound($numbersArray) Then
ExitLoop
Else
doCall($i+1)
EndIf
EndIf
If $oCall.Status = $cCallStatus_Finished Then
GUICtrlSetData ($Label2, "Call status: " & $oSkype.Convert.CallStatusToText($oCall.Status))
If $i >= UBound($numbersArray) Then
ExitLoop
EndIf
EndIf
Sleep(500)
WEnd
If $oCall.Status = $cCallStatus_Finished Then
GUICtrlSetData ($Label2, "Call status: " & $oSkype.Convert.CallStatusToText($oCall.Status))
If $i >= UBound($numbersArray) Then
Exit
EndIf
EndIf
;// Finish the call:
Sleep(3000)
Next
EndIf
EndFunc