#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.0 Author: Skysnake Date: 2015.11.10 Script Function: Implement BulkSMS sending in AutoIt www.bulksms.com BulkSMS Windows 32 API.doc ~ API version 1.0.0.6, 13 November 2008 SMSTxt32.dll ~ The core API and redistributable This is the core API file and royalty free redistributable that contains all the functionality. #ce ---------------------------------------------------------------------------- ; Script Start - #include #cs Function List These functions are members of the API API Function Description sms_sendsms Function used to send the same text message to one or more mobile phones. Allows more detail to be specified than using SMSTextSimple_SendSMS(). sms_sendbatch Function used to send different text message to one or more mobile phones (use it for mail merge type messaging). Allows more detail to be specified than using SMSTextSimple_SendBatch(). sms_getreport Function used to get the status of a message that was sent. The function returns a detailed status code per mobile number. sms_getcredits Function to determine the number of text message credits available for the specified account sms_getinbox Function used to retrieve the incoming messages for the specified account. #CE ; Required Global $__g_hDll_BulkSMS = "SMSTxt32.dll" ; name of the DLL to use Local $smsapi_sendsms = "sms_sendsms" ; name of the API member to SEND single SMS Global $BSMSuser = 'myusername' ; BulkSMS username Global $BSMSpwd = 'mypwd' ; BulkSMS password Global $BSMSeapi = 'http://bulksms.2way.co.za/eapi' ; BulkSMS eapi for HTTP Global $BSMSserverID = 'BSMS_SERVER_CO_ZA' ; BulkSMS server for sending Global $SMSDest ='27823311929' ; destination cell number Global $SMSmsgtxt ='Hello+World!' ; message text to send __TestBulkSMS() Func __TestBulkSMS() __BulkSMS_ds_Init() ; initialize with default values data structure __BulkSMS_ds_AccInfo() ; required to authenticate account data structure __BulkSMS_ds_MsgInfo() ; message data structure __BulkSMS_ds_ResponseInfo() ; response data structure __BulkSMS_f_SMSSend() ; function send message EndFunc ;==>__TestBulkSMS() Func __BulkSMS_ds_Init() ; BulkSMS network configuration #cs ;;;; example for C code, page 10 typedef struct { bool bKeepConnectionAlive; bool bUseSSL; HWND hWndUI; int nAcessType; int nIdealPort; int nProxyPort; char szProxyAddress[BSMS_LEN_STANDARD_BUFFER+1]; char szProxyUsername[BSMS_LEN_STANDARD_BUFFER+1]; char szProxyPassword[BSMS_LEN_STANDARD_BUFFER+1]; } SMSAPI_NETWORKCONFIGURATION, *LPSMSAPI_NETWORKCONFIGURATION; #CE ; Assign a Local constant variable the definition of a structure (read carefully the DllStructCreate remarks). Local Const $tagSTRUCT1 = "struct;bool bKeepConnectionAlive;bool bUseSSL;HWND hWndUI;int nAcessType;int nIdealPort;int nProxyPort;char szProxyAddress;char szProxyUsername;char szProxyPassword;endstruct" ; Note: The tag variable is declared as Constant because its value will never change for any script execution. ; Assign a Local variable the structure. Local $SMSAPI_NETWORKCONFIGURATION = DllStructCreate($tagSTRUCT1) ; If an error occurred display the error code and return False. If @error Then MsgBox($MB_SYSTEMMODAL, "", "Error in DllStructCreate, Code: " & @error) Return False EndIf Local $res = DllCall($__g_hDll_BulkSMS, _ ; name of DLL "NONE", _ ; return type "SMSAPI_initialize_defaults", _ ; function "STRUCT", _ ; type1 $SMSAPI_NETWORKCONFIGURATION _ ; param1 ) ConsoleWrite("BulkSMS Init" & @CRLF) ConsoleWrite("Struct pointer: " & DllStructGetPtr($SMSAPI_NETWORKCONFIGURATION) & @CRLF) If $res=0 Then ConsoleWrite("Okay: " & $res & @CRLF) ;Return ($res) Else ConsoleWrite("Error: " & $res & @CRLF) Return (SetError(1, 0, 0)) EndIf Global $gSMSAPI_NETWORKCONFIGURATION=$SMSAPI_NETWORKCONFIGURATION EndFunc ;==>__BulkSMS_Init Func __BulkSMS_ds_AccInfo() ; BulkSMS network authentication #cs ;;;; example for C code, page 12 typedef struct { char szSMSTextUsername[BSMS_LEN_STANDARD_MSG+1]; char szSMSTextPassword[BSMS_LEN_STANDARD_MSG+1]; BSMS_SERVER defaultServerID; char szServerOverride[BSMS_LEN_STANDARD_BUFFER+1]; } SMSAPI_ACCOUNTINFO, *LPSMSAPI_ACCOUNTINFO; #CE ; Assign a Local constant variable the definition of a structure (read carefully the DllStructCreate remarks). Local Const $tagSTRUCT2 = "struct;char szSMSTextUsername;char szSMSTextPassword;int defaultServerID;char szServerOverride;endstruct" ; Note: The tag variable is declared as Constant because its value will never change for any script execution. ; Assign a Local variable the structure. Local $SMSAPI_ACCOUNTINFO = DllStructCreate($tagSTRUCT2) ; If an error occurred display the error code and return False. If @error Then MsgBox($MB_SYSTEMMODAL, "", "Error in DllStructCreate, Code: " & @error) Return False EndIf ; update struct woth user defined values ; Set the data of the element var1 (int) in the $SMSAPI_NETWORKCONFIGURATION. DllStructSetData($SMSAPI_ACCOUNTINFO, 1, $BSMSuser) DllStructSetData($SMSAPI_ACCOUNTINFO, 2, $BSMSpwd) DllStructSetData($SMSAPI_ACCOUNTINFO, 3, $BSMSserverID) Local $res = DllCall($__g_hDll_BulkSMS, _ ; name of DLL "NONE", _ ; return type "SMSAPI_initialize_defaults", _ ; function "STRUCT", _ ; type1 $SMSAPI_ACCOUNTINFO _ ; param1 ) ConsoleWrite("BulkSMS Auth" & @CRLF) ConsoleWrite("Struct pointer: " & DllStructGetPtr($SMSAPI_ACCOUNTINFO) & @CRLF) If $res=0 Then ConsoleWrite("Okay: " & $res & @CRLF) ;Return ($res) Else ConsoleWrite("Error: " & $res & @CRLF) Return (SetError(1, 0, 0)) EndIf GLobal $gSMSAPI_ACCOUNTINFO = $SMSAPI_ACCOUNTINFO EndFunc ;==>__BulkSMS_AccInfo Func __BulkSMS_ds_MsgInfo() ; BulkSMS network authentication #cs ;;;; example for C code, page 12 typedef tagSMSAPI_MESSAGEINFO { char * lpszCommaSeperatedMobileList; ;1 destination char szMessageText[BSMS_LEN_STANDARD_MSG+1]; ;2 msg text char szSenderID[BSMS_LEN_STANDARD_BUFFER+1]; ;3 SENDER ID bool bLongMessage; ;4 looong msg int nMaxLongMessageParts; ;5 parts of looong msg bool bScheduleForLaterDelivery; ;6 scheduled? char szScheduleYYYYMMDDHHMMSS[BSMS_LEN_SCHEDULE_DATETIME+1]; ;7 scheduled time int nMessageClass; ;8 "2" normal SMS msg unsigned long dwMessageID; ;9 msg ID } SMSAPI_MESSAGEINFO; #CE ; Assign a Local constant variable the definition of a structure (read carefully the DllStructCreate remarks). Local Const $tagSTRUCT3 = "struct;char lpszCommaSeperatedMobileList;char szMessageText;char szSenderID;bool bLongMessage;int nMaxLongMessageParts;bool bScheduleForLaterDelivery;char szScheduleYYYYMMDDHHMMSS;int nMessageClass;ulong dwMessageID;endstruct" ; Note: The tag variable is declared as Constant because its value will never change for any script execution. ; Assign a Local variable the structure. Local $SMSAPI_MESSAGEINFO = DllStructCreate($tagSTRUCT3) ; If an error occurred display the error code and return False. If @error Then MsgBox($MB_SYSTEMMODAL, "", "Error in DllStructCreate, Code: " & @error) Return False EndIf ; update struct woth user defined values ; Set the data of the element var1 (int) in the $SMSAPI_NETWORKCONFIGURATION. DllStructSetData($SMSAPI_MESSAGEINFO, "lpszCommaSeperatedMobileList", $SMSDest) ; destination DllStructSetData($SMSAPI_MESSAGEINFO, "szMessageText", $SMSmsgtxt) ; msg Local $res = DllCall($__g_hDll_BulkSMS, _ ; name of DLL "NONE", _ ; return type "SMSAPI_initialize_defaults", _ ; function "STRUCT", _ ; type1 $SMSAPI_MESSAGEINFO _ ; param1 ) ConsoleWrite("BulkSMS MsgInfo" & @CRLF) ConsoleWrite("Struct pointer: " & DllStructGetPtr($SMSAPI_MESSAGEINFO) & @CRLF) If $res=0 Then ConsoleWrite("Okay: " & $res & @CRLF) ;Return ($res) Else ConsoleWrite("Error: " & $res & @CRLF) Return (SetError(1, 0, 0)) EndIf Global $gSMSAPI_MESSAGEINFO=$SMSAPI_MESSAGEINFO EndFunc ;==>__BulkSMS_AccInfo Func __BulkSMS_ds_ResponseInfo() ; BulkSMS network authentication #cs ;;;; example for C code, page 12 typedef struct { int cbSizeOfResultBuffer; char * lpszResult; int nResult; } SMSAPI_RESPONSEINFO #CE ; Assign a Local constant variable the definition of a structure (read carefully the DllStructCreate remarks). Local Const $tagSTRUCT3 = "struct;int cbSizeOfResultBuffer;char lpszResult;int nResult;endstruct" ; Note: The tag variable is declared as Constant because its value will never change for any script execution. ; Assign a Local variable the structure. Local $SMSAPI_RESPONSEINFO = DllStructCreate($tagSTRUCT3) ; If an error occurred display the error code and return False. If @error Then MsgBox($MB_SYSTEMMODAL, "", "Error in DllStructCreate, Code: " & @error) Return False EndIf Local $res = DllCall($__g_hDll_BulkSMS, _ ; name of DLL "NONE", _ ; return type "SMSAPI_initialize_defaults", _ ; function "STRUCT", _ ; type1 $SMSAPI_RESPONSEINFO _ ; param1 ) ConsoleWrite("BulkSMS ResponseInfo" & @CRLF) ConsoleWrite("Struct pointer: " & DllStructGetPtr($SMSAPI_RESPONSEINFO) & @CRLF) If $res=0 Then ConsoleWrite("Okay: " & $res & @CRLF) ;Return ($res) Else ConsoleWrite("Error: " & $res & @CRLF) Return (SetError(1, 0, 0)) EndIf Global $gSMSAPI_RESPONSEINFO=$SMSAPI_RESPONSEINFO EndFunc ;==>__BulkSMS_ds_ResponseInfo Func __BulkSMS_f_SMSSend() ; function send message ;do something :) #CS ; Display the results. MsgBox($MB_SYSTEMMODAL, "", "Struct Size: " & DllStructGetSize($gSMSAPI_NETWORKCONFIGURATION) & @CRLF & _ "Struct pointer: " & DllStructGetPtr($gSMSAPI_NETWORKCONFIGURATION) & @CRLF & _ "Data:" & @CRLF & _ DllStructGetData($gSMSAPI_NETWORKCONFIGURATION, 1) & @CRLF & _ ; Or "var1" instead of 1. DllStructGetData($gSMSAPI_NETWORKCONFIGURATION, 2) & @CRLF & _ ; Or 2 instead of "var2". DllStructGetData($gSMSAPI_ACCOUNTINFO, 1) & @CRLF & _ ; Or "var3" instead of 3. DllStructGetData($gSMSAPI_ACCOUNTINFO, 2) & @CRLF & _; Or "var4" instead of 4. DllStructGetData($gSMSAPI_ACCOUNTINFO, 3) & @CRLF & _; DllStructGetData($gSMSAPI_MESSAGEINFO, 1) & @CRLF & _; DllStructGetData($gSMSAPI_MESSAGEINFO, 2) & @CRLF & _; DllStructGetData($gSMSAPI_MESSAGEINFO, 3) & @CRLF & _; DllStructGetData($gSMSAPI_MESSAGEINFO, 1)) ; #CE Local $res = DllCall($__g_hDll_BulkSMS, _ ; name of DLL "BOOL", _ ; return type "SMSAPI_sendsms", _ ; function "LONG", _ ; type1 $gSMSAPI_NETWORKCONFIGURATION, _ ; param1 "LONG", _ ; type2 $gSMSAPI_ACCOUNTINFO, _ ; param2 "LONG", _ ; type3 $gSMSAPI_MESSAGEINFO, _ ; param3 "LONG", _ ; type4 $gSMSAPI_RESPONSEINFO _ ; param4 ) ConsoleWrite("BulkSMS SMS Sent" & @CRLF) If $res=0 Then ConsoleWrite("Okay: " & $res & @CRLF) ;Return ($res) Else ConsoleWrite("Error: " & $res & @CRLF) Return (SetError(1, 0, 0)) EndIf EndFunc; ==> __BulkSMS_f_SMSSend() ; function send message ; Release the resources used by the structure. $SMSAPI_NETWORKCONFIGURATION = 0 $gSMSAPI_NETWORKCONFIGURATION = 0 $SMSAPI_ACCOUNTINFO = 0 $gSMSAPI_ACCOUNTINFO = 0 $SMSAPI_MESSAGEINFO = 0 $gSMSAPI_MESSAGEINFO = 0 $SMSAPI_RESPONSEINFO = 0 $gSMSAPI_RESPONSEINFO = 0