Leaderboard
Popular Content
Showing content with the highest reputation on 10/14/2020 in all areas
-
WinHTTP This site requires Javascript to work
JockoDundee and one other reacted to TheXman for a topic
Did you not read my post? You will continue to get the same response using WinHttp (COM or API) because it doesn't have the ability to process client-side scripting. I just provided an example using COM to show you what the same request would look like and how much simpler it is to use than APIs, which is what the WINHTTP UDF is based on. Given JackoDundee's question, he's probably going to suggest an alternate solution which would be to use server-side scripting to render the information in the response instead of using client-side scripting. It looks like most of the information you are trying to display is coming from the request header. So most, if not all, of the information should be available to render using server-side scripting.2 points -
PiD “challenge”
JockoDundee and one other reacted to TheSaint for a topic
Alas, if I could only give TheDcoder the thrashing he deserves, but he is hard to come by and my laid back Cowboy is not up to his elusive lazyboy Indian. And to make matters worse, he is now batting for the other side .... Linux ... and showing great Nerdity, which is not a thing to engage with lightly ... frankly, he scares me with his rate of progress ... but in an all out battle I am sure to win .... for now .... he is moving beyond the grasshopper stage though, and it won't be long before he has snatched more pebbles than I have marbles. He can also be imagined as a caterpillar reaching toward the butterfly his mother and father imagine ... a young man of many colors. His single biggest failing so far, is he doesn't find enough of my words funny enough.2 points -
PiD “challenge”
TheDcoder and one other reacted to JockoDundee for a topic
Perhaps you should see to that at once. His alarming generality and lack of specificity continues to go unchecked, and with each passing day his posts are growing more vague and indistinct, as his proper noun usage continues to plummet. And, so I would feel honored if you would give @TheDcoder a good thrashing on my very own thread, one with as many obscure references, inside jokes and disarming non-sequiturs as possible, and I pray that @TheDcoder will respond in kind, with a sustained volley of off-hand dismissals, special pleadings and rhetorical flourishes, and the both of you will lay waste to the thread, so that it be ever be remembered in that way, and not as the thread in which “that guy”, aka me, was wrong.2 points -
Hello Recently, there was a need to develop an SMS gateway. The machine is supposed to send notifications to employees, the number of sms sent is not much 10-50 a month, so it makes no sense to buy a subscription to the www-sms API. The machine is based on a USB-GSM modem: LC SIM800C V3 (aliexp.. price 3-8$) I used UDF: ComUDF.au3 Thank you mLipok for your work! Below is the program code with an example WARNING! The program is written very extensively (not optimized) - it was created with a novice programmer as part of exercises. But it makes it very understandable (lots of comments) There are ONLY functions here: - modem initialization - sending SMS - deleting received sms (no possibility of reading) Maybe someone will be useful for further experiments with AT commands to communicate with the modem. The biggest challenge for me was the dependence of AT commands in different modem operation modes (instruction AT command for chip SIM800 ONLY 380 pages !) LCSIM800CV3.au3 #include "ComUDF.au3" #include <Array.au3> #include <Timers.au3> Global Const $SMS_NOPL = 0 ; send sms not POLISH characters set the SMS mode "GSM" look AT command AT+CSCS Global Const $SMS_PL = 1 ; send sms with POLISH characters set the SMS mode "HEX" look AT command AT+CSCS ; Write setting from PC with modem USB Global $LCSIM800CV3_sComPort = 'COM3' ; a com port with USB modem, e.g. COM1 Global $LCSIM800CV3_sPortSettings = ' baud=9600 data=8' ; speed settings (for default values see _COM_OpenPort) Global $LCSIM800CV3_hComPort Local $LCSIM800CV3_aPortsList = _COM_ListPorts() ; an array with COM ports ;_ArrayDisplay($LCSIM800CV3_aPortsList) ; displays the ports found in OS _Example() ; example function ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Example ; Description ...: Declaring an array with data to send an SMS (various phone number formats) ; Sending SMS in "HEX" mode ; Sending SMS in "GSM" mode ; Syntax ........: _Example() ; Parameters ....: None ; Return values .: None ; Author ........: ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _Example() ;MODIFY number phone vvvvvvv and vvvvvvvv Local $aTest[2][2] = [['123456789','Test pl liter: ęóąśłżźćń'],['+48123456789','Test PL liter: ĘÓĄŚŁŻŹĆŃ']] ConsoleWrite('==START send sms mode "HEX" with diacritical character==' & @CRLF) $Return = _SendSMSFromArray($aTest, $SMS_PL) $Error = @error $Extended = @extended If $Error Then ConsoleWrite('$Error: ' & $Error & @CRLF) ConsoleWrite('$Extended: ' & $Extended & @CRLF) ConsoleWrite('$Return: ' & $Return & @CRLF) Else _ArrayDisplay($Return, '$SMS_PL') EndIf ConsoleWrite('==END send sms mode "HEX" with diacritical character==' & @CRLF) ConsoleWrite('==START send sms mode "GSM" only basic alphabet==' & @CRLF) $Return = _SendSMSFromArray($aTest, $SMS_NOPL) $Error = @error $Extended = @extended If $Error Then ConsoleWrite('$Error: ' & $Error & @CRLF) ConsoleWrite('$Extended: ' & $Extended & @CRLF) ConsoleWrite('$Return: ' & $Return & @CRLF) Else _ArrayDisplay($Return, '$SMS_NOPL') EndIf ConsoleWrite('==END send sms mode "GSM" only basic alphabet==' & @CRLF) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: _SendSMSFromArray ; Description ...: Complete SMS sending function (opening the COM port; modem initialization; ; sending a text message; closing the COM port) ; Syntax ........: _SendSMSFromArray($aTableSMS, $PL) ; Parameters ....: $aTableSMS - an 2D array [NumberPhone_1][TextSMS_1] ; [NumberPhone_n][TextSMS_n] ; $PL - $SMS_NOPL (0) NO PL char send normal text "GSM" ; - $SMS_PL (1) PL char send mode "HEX" ; Return values .: success - input array and add col with status ; [NumberPhone_1][TextSMS_1][status_send _1] ; [NumberPhone_n][TextSMS_n][status_send _n] ; fail - set @error and description error ; Author ........: ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _SendSMSFromArray($aTableSMS, $PL) Local $Return, $Error, $Extended, $i $Return = _InitModem($PL) $Error = @error $Extended = @extended If $Error Then _COM_ClosePort($LCSIM800CV3_hComPort) Return SetError(1, 1, '[_SendSMSFromArray] ' & $Return) EndIf _DelAllSMS() _ArrayColInsert($aTableSMS, 2) ; add col to status sending sms For $i=0 to UBound($aTableSMS, $UBOUND_ROWS)-1 $Return = _SendSMS($aTableSMS[$i][0], $aTableSMS[$i][1], $PL) $Error = @error $Extended = @extended If $Error Then $aTableSMS[$i][2] = $Return Else $aTableSMS[$i][2] = 'OK' EndIf Next _COM_ClosePort($LCSIM800CV3_hComPort) Return $aTableSMS EndFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: _InitModem ; Description ...: Open port COM, verify modem reposnse, send command setting SMS mode ; Syntax ........: _InitModem($PL) ; Parameters ....: $PL - 0 no PL character - SMS mode "GSM" ; 1 PL character - SMS mode "HEX" ; Return values .: success - 1 ; failure - set @error and return description error ; Author ........: ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _InitModem($PL) Local $Return, $Error, $Extended $Return = _COM_OpenPort($LCSIM800CV3_sComPort & $LCSIM800CV3_sPortSettings) $Error = @error If $Error Then Return SetError(1, 1, '[_Init] error open port: ' & $LCSIM800CV3_sComPort & $LCSIM800CV3_sPortSettings) EndIf $LCSIM800CV3_hComPort = $Return $Return = __SendToModem('AT') ; ping modem If StringInStr($Return, 'OK') = 0 Then Return SetError(1, 2, '[_Init] communication error with modem - AT command returned: ' & $Return) EndIf $Return = __SendToModem('ATE0') ; disable "echo" 0= send "AT" received: "OK"; 1= send "AT" received: "AT @CR OK" If StringInStr($Return, 'OK') = 0 Then Return SetError(1, 2, '[_Init] communication error with modem - ATE0 command returned: ' & $Return) EndIf $Return = __SendToModem('AT+CMGF=1') ; format wiadomości SMS (0 - PDU, 1 - Text) If StringInStr($Return, 'OK') = 0 Then Return SetError(1, 2, '[_Init] communication error with modem - AT+CMGF=1 command returned: ' & $Return) EndIf If $PL=$SMS_NOPL Then $Return = __SendToModem('AT+CSCS="GSM"') ; set mode "GSM" all character is normal text If StringInStr($Return, 'OK') = 0 Then Return SetError(1, 2, '[_Init] communication error with modem - AT+CSCS=""GSM"" command returned: ' & $Return) EndIf $Return = __SendToModem('AT+CSMP=17,167,0,0') ; additional settings to "GSM" If StringInStr($Return, 'OK') = 0 Then Return SetError(1, 2, '[_Init] communication error with modem - AT+CSMP=17,167,0,0 command returned: ' & $Return) EndIf ElseIf $PL=$SMS_PL Then $Return = __SendToModem('AT+CSCS="HEX"') ; set mode "HEX" all character is hex 4digit If StringInStr($Return, 'OK') = 0 Then Return SetError(1, 2, '[_Init] communication error with modem - AT+CSCS=""HEX"" command returned: ' & $Return) EndIf $Return = __SendToModem('AT+CSMP=17,167,0,8') ; additional settings to "HEX" If StringInStr($Return, 'OK') = 0 Then Return SetError(1, 2, '[_Init] communication error with modem - AT+CSMP=17,167,0,8 command returned: ' & $Return) EndIf Else Return SetError(1, 2, '[_Init] incorrect parameter $PL:' & $PL) EndIf Return 1 EndFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: _DelAllSMS ; Description ...: Deletes all received sms ; Syntax ........: _DelAllSMS() ; Parameters ....: None ; Return values .: success - 1 ; failure - set @error and return description error ; Author ........: ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _DelAllSMS() $Return = __SendToModem('AT+CMGDA="DEL ALL"') ; send command AT delete all sms and receives text "OK" If StringInStr($Return, 'OK') = 0 Then Return SetError(1, 1, '[_DelAllSMS] SMS erase error - AT+CMGDA="DEL ALL" command returned: ' & $Return) EndIf Return 1 EndFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: _SendSMS ; Description ...: Send sms. Restriction of sending to the country POLAND (+48) ; Syntax ........: _SendSMS($sPhoneNumber, $sSMS, $PL) ; Parameters ....: $sPhoneNumber - a string value. ; $sSMS - a string value. ; $PL - 0=no PL character - SMS mode "GSM"; 1=PL character - SMS mode "HEX" ; Return values .: success - 1 ; failure - set @error and return description error ; Author ........: ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _SendSMS($sPhoneNumber, $sSMS, $PL) Local $Return, $Error, $Extended ;verifying and modifying of the telephone number $sPhoneNumber = StringRegExpReplace($sPhoneNumber, "\D", '') If Not StringLen($sPhoneNumber) = 9 Or Not StringLen($sPhoneNumber) = 11 Then ;Number MUST 9 or 11 digit Return SetError(1, 9, '[_SendSMS] wrong phone number: ' & $sPhoneNumber) EndIf ;START ONLY country +48 ;NOTE this section allows you to send text messages only to the area code PL ;CHANGE 48 with your country code or delete this part If StringLen($sPhoneNumber) = 9 Then $sPhoneNumber = '+48' & $sPhoneNumber ; ElseIf StringLen($sPhoneNumber) = 11 Then If StringLeft($sPhoneNumber, 2) <> '48' Then Return SetError(1, 9, '[_SendSMS] wrong phone area code: ' & $sPhoneNumber) Else $sPhoneNumber = '+' & $sPhoneNumber EndIf EndIf ;END ONLY country +48 ;verifying and modifying of the text sms If StringLen($sSMS) > 250 Then Return SetError(1, 10, '[_SendSMS] the content of the SMS exceeds 250 characters: ' & StringLen($sSMS)) EndIf ;sending SMS ;step 1 -send phone number & <CR> $Return = __SendToModem('AT+CMGS="' & $sPhoneNumber & '"') ; send command AT & number and receives char ">" If StringInStr($Return, '>') = 0 Then Return SetError(1, 1, '[_SendSMS] modem communication error - command AT+CMGS="' & $sPhoneNumber & '": ' & $Return) EndIf ;step 2 - send text sms & <ESC> / Ctrl+Z If $PL=$SMS_PL Then ; convert to HEX with PL char $sSMS = Hex(StringToBinary($sSMS, $SB_UTF16BE)) ElseIf $PL=$SMS_NOPL Then ; $SMS_NOPL $sSMS = __ReplacePLChar($sSMS) ; if "GSM" then normal text and replace ą=>a etc. Else Return SetError(1, 1, '[_SendSMS] incorrect parameter $PL:' & $PL) EndIf $Return = __SendToModem($sSMS, Chr(26)) ;send text and Ctrl-Z If StringInStr($Return, 'ERROR') > 0 Then Return SetError(1, 2, '[_SendSMS] modem communication error - command AT+CSCS="GSM" returned: ' & $Return) ElseIf StringInStr($Return, '+CMGS:') > 0 And StringInStr($Return, 'OK') > 0 Then Return 1 Else Return SetError(1, 3, '[_SendSMS] communication error with modem - unknown answer: ' & $Return) EndIf EndFunc Func __SendToModem($sText, $sEnter=Chr(13)) Local $Return, $Error, $hTimerStart If $sEnter <> Chr(13) And $sEnter <> Chr(26) Then Return SetError(1, 10, '[__SendToModem] argument value not allowed $sEnter: ' & $sEnter) EndIf $Return = _COM_SendString($LCSIM800CV3_hComPort, $sText & $sEnter) $Error = @error If $Error Then Return SetError(1, 1, '[__SendToModem][_COM_SendString] it returned an error: ' & $Error) EndIf Sleep(500) ; wait 500ms to allow the receive buffer to fill up $hTimerStart = _Timer_Init() Do Do Sleep(100) $Return = _COM_GetInputcount($LCSIM800CV3_hComPort) $Error = @error If $Error Then Return SetError(1, 1, '[__SendToModem][_COM_GetInputcount] it returned an error: ' & $Error) EndIf $iCount = $Return If _Timer_Diff($hTimerStart) > 61*1000 Then ;WARNING! Must be> 60 sec - instruction from modem: "Max response time send sms: 60s" Return SetError(1, 1, '[__SendToModem][_COM_GetInputcount] no answer from modem for 60 seconds') EndIf Until $iCount > 0 $Return = _COM_ReadString($LCSIM800CV3_hComPort, $iCount) $Error = @error If $Error Then Return SetError(1, 1, '[__SendToModem][_COM_ReadString] it returned an error: ' & $Error) EndIf Until StringInStr($Return, '+CMTI: "')=0 ; we omit modem responses informing about receiving an SMS Return $Return EndFunc ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ..........: __ReplacePLChar ; Description ...: Replace polish characters to NO polish ; Syntax ........: __ReplacePLChar($sText) ; Parameters ....: $sText - a string value. ; Return values .: String no polish character ; Author ........: ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func __ReplacePLChar($sText) $sText = StringReplace($sText, 'Ą', 'A', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'ą', 'a', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'Ć', 'C', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'ć', 'c', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'Ę', 'E', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'ę', 'e', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'Ł', 'L', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'ł', 'l', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'Ń', 'N', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'ń', 'n', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'Ó', 'O', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'ó', 'o', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'Ś', 'S', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'ś', 's', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'Ź', 'Z', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'ź', 'z', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'Ż', 'Z', 0, $STR_CASESENSE) $sText = StringReplace($sText, 'ż', 'z', 0, $STR_CASESENSE) Return $sText EndFunc1 point
-
HandleImgSearch (Image Search with ImageSearchDLL embedded)
mutleey reacted to lamnhan066 for a topic
Today, I will share my work with image search in inactive windows (windows that run in the background) with tolerances (variations). After a long time of searching and using image search UDF on the internet. I combined all of that with my experienced and created a UDF name HandleImgSearch. I have embedded the .dll file in this script so it doesn't need any external files, just include it and run. However, this UDF uses a pure AutoIT loop to make the multiple positions returned work so it may be slower if you set the $MaxImg to a high number. Some highlights: Very fast with imagesearchdll embedded, no external files required. Tolerances and Max Images are supported. Optimized. Use with a handle or full screen easily. Included global functions, so you can run multiple functions in one capture. Examples used for testing included. Notes: Only used to compile to 32-bit AutoIt version (It can completely run on Windows 64-bit) The image used for searching should be in a "24-bit Bitmap" format. I included the $IsUser32 variable in some places like _GlobalImgInit, _HandleCapture. This variable allowed you to use DllCall with the "PrintWindow" parameter instead of _WinAPI_BitBlt with $SRCCOPY. $IsUser32 = True is useful for the window explorer handle, $IsUser32 = False is useful for the emulator handle (NoxPlayer handle example included). If hwnd parameter equals "", it will use the whole screen instead. Functions: Global Functions: Run multiple functions with one capture. _GlobalImgInit: Initialization variables. _GlobalImgCapture: Capture the handle. _GlobalGetBitmap: Get captured bitmap handle. _GlobalImgSearch: This is the main function of this UDF. _GlobalGetPixel: Get pixel color in the captured image. _GlobalPixelCompare: Compare pixel color with captured image pixel color. Handle Functions: Capture every time. _HandleImgSearch: This is the main function of this UDF. Search for images in the handle of the window with the tolerance and maximum image options. _BmpImgSearch: Search the picture in the picture instead of the handle. _HandleGetPixel: Get pixel in the handle image. _HandlePixelCompare: Compare color with pixel color of handle image. _HandleCapture: Capture handle screen. Source code: v1.0.5 (First release): https://github.com/vnniz/HandleImgSearch/releases/tag/v1.0.5 v2.0.0 (14/04/2023): https://github.com/vnniz/HandleImgSearch/releases/tag/v2.0.0 Thanks to: ImageSearchDLL (Author: kangkeng 2008) MemoryCall (Author: Joachim Bauch) BinaryCall (Author: Ward) GAMERS - Asking for help with ANY kind of game automation is against the forum rules. DON'T DO IT.1 point -
OutlookEX
DonChunior reacted to water for a file
Version 1.7.0.2
10,396 downloads
Extensive library to control and manipulate Microsoft Outlook. This UDF holds the functions to automate items (folders, mails, contacts ...) in the background. Can be seen like an API. There are other UDFs available to automate Outlook: OutlookEX_GUI: This UDF holds the functions to automate the Outlook GUI. OutlookTools: Allows to import/export contacts and events to VCF/ICS files and much more. Threads: Development - General Help & Support - Example Scripts - Wiki BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort KNOWN BUGS (last changed: 2020-02-09) None1 point -
I have made an change to au3check to strip any trailing backslashes from the registry entries so one can't make that mistake. It's available in the Beta dir: https://www.autoitscript.com/autoit3/scite/download/beta_SciTE4AutoIt3/Au3Check.exe in case you want to test it. Jos1 point
-
COM Error Handler not working for some strange reason
seadoggie01 reacted to mLipok for a topic
Yes. this is it.1 point -
RegExp: repeatable pattern
Musashi reacted to seadoggie01 for a topic
This mostly satisfies your request, but leaves a trailing ", ": $sTags = StringRegExpReplace($aEntry[$i], "(?:.*?)<li>(.*?)<\/li>(?:(?!<\/?li>).)*", "$1, ") Personally though, I would match everything between <li> and </li> tags with StringRegExp option 3 and concatenate the results back together... Func ConcatRegExp($sText) Local $aResults = StringRegExp($sText, "<li>(.*?)<\/li>", 3) If @error Then Return SetError(1, 0, False) Local $sReturn = "" For $i=0 To Ubound($aResults) - 1 $sReturn &= $aResults[$i] & ", " Next Return StringTrimRight($sReturn, 2) EndFunc1 point -
Excel Hidden on some PCs (as coded) but shows on others.
seadoggie01 reacted to water for a topic
Ahh, those 👿 Add-Ins. Most of unexplainable problems are caused by badly written Add-Ins.1 point -
First post, so hello everyone! I may have a solution (or a workaround) depending on how you use the data pasted to Excel. Do you make any calculations with the data? If not, then try the method below (I added the whole script that worked for me with your example HTML table). The step you have missed is the .PasteSpecial("Text") part. While HTML table is in clipboard: #include <Excel.au3> Local $oWB = _excel_Open() _Excel_BookNew($oWB) sleep(2000) $oWB.Activesheet.Range("A1").Select ;Select the appropriate cell in the worksheet you want $oWB.Activesheet.Paste ;Paste as usual $oWB.Selection.NumberFormat = "@" ;The paste method will select the effected cells, which can be referred as "selection". Change number format to "text". $oWB.Selection.PasteSpecial("Text") ;Paste again to the "selection" as PasteSpecial("Text"), maybe "Unicode Text" would work too, haven't tried. Note: You don't need to select cells/range in Excel (while using VBA) to paste stuff unless AutoIt requires it. I have only been using AutoIt for a week now and I haven't used Excel.au3 yet until this post. Hopefully, someone else will correct any inefficient steps in my script. If you need calculations for the pasted data, maybe something else can be managed. Maybe a VBA macro to get things run smooth. I can try help with that side if you want.1 point
-
COM Error Handler not working for some strange reason
seadoggie01 reacted to mLipok for a topic
For all interested: https://www.autoitscript.com/trac/autoit/ticket/3167 Thanks to @jpm bug is fixed, one thing which we need to do is waiting for @Jon approoval and releasing new version. Do not ask when this will be done. The short answer is: When @Jon will have a spare time to work on this.1 point -
This UDF was created to facilitate the saving and reading of email configuration. Thanks to @water, @jchd, @Jos for helping in translation of _EmailConfig_GUI_Preset_**() Hope to have _EmailConfig_GUI_Preset_ES() version soon. If you want to create your national version of _EmailConfig_GUI_Preset_**() please do not hesitate ... contribute. _EmailConfig_GUI_Preset_EN() is translated by me and Google Translator (from my national Polish language), so if you have any fix for this please do not hesitate ... contribute. The EmailConfig_Example_STMP_Mailer.au3 is using modified version of Jos SMTP Mailer UDF #AutoIt3Wrapper_UseX64=N #AutoIt3Wrapper_Run_AU3Check=Y #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #Tidy_Parameters=/sort_funcs /reel #include <Array.au3> #include <AutoItConstants.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <Crypt.au3> #include <EditConstants.au3> #include <File.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include "EmailConfig.au3" #include "GDPR.au3" ; https://www.autoitscript.com/forum/files/file/509-gdpr/ Global $oMyRet[2] #Region - EXAMPLE _MY_EXAMPLE__EmailConfig() Func _MY_EXAMPLE__EmailConfig() _GDPR_Crypter_Wrapper(_EmailConfig_ExampleCrypter) _EmailConfig_GUI_Preset_EN() ;~ _EmailConfig_GUI_Preset_DE() ;~ _EmailConfig_GUI_Preset_FR() ;~ _EmailConfig_GUI_Preset_NL() ;~ _EmailConfig_GUI_Preset_PL() _EmailConfig_SaveWrapper(_EmailConfig_SaveToINI) _EmailConfig_LoadWrapper(_EmailConfig_LoadFromINI) _EmailConfig_LoadWrapper() If $IDYES = MsgBox($MB_YESNO + $MB_TOPMOST + $MB_ICONQUESTION + $MB_DEFBUTTON1, 'Question #' & @ScriptLineNumber, _ 'Do you want to set email configuration ?') Then _EmailConfig_ShowGUI() EndIf Local $s_ToAddress = 'whereisyourdestination@your.email.com' Local $s_Subject = 'Testing email sending : ' & @YEAR & @MON & @MDAY & ' ' & @HOUR & @MIN & @SEC Local $s_Body = 'This is only a test' Local $s_Attachments = '' _SMTP_SendEmail_Example($s_ToAddress, $s_Subject, $s_Body, $s_Attachments) EndFunc ;==>_MY_EXAMPLE__EmailConfig Func _EmailConfig_ExampleCrypter($dBinaryData, $bDataAlreadyEncrypted) _Crypt_Startup() ; Start the Crypt library. Local $dResult If $bDataAlreadyEncrypted Then $dResult = _Crypt_DecryptData($dBinaryData, 'securepassword', $CALG_AES_256) ; Decrypt the data using the generic password string. The return value is a binary string. Else $dResult = _Crypt_EncryptData($dBinaryData, 'securepassword', $CALG_AES_256) ; Encrypt the text with the new cryptographic key. EndIf _Crypt_Shutdown() ; Shutdown the Crypt library. Return $dResult EndFunc ;==>_EmailConfig_ExampleCrypter #EndRegion - EXAMPLE ; ; The UDF Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance = "Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0, $tls = 0) Local $oCOM_Error_Handler = ObjEvent("AutoIt.Error", "MyErrFunc") #forceref $oCOM_Error_Handler Local $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 #forceref $i_Error Local $i_Error_desciption = "" #forceref $i_Error_desciption If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress $objEmail.Subject = $s_Subject If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf If $s_AttachFiles <> "" Then Local $S_Files2Attach = StringSplit($s_AttachFiles, ";") For $x = 1 To $S_Files2Attach[0] $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x]) ;~ ConsoleWrite('@@ Debug : $S_Files2Attach[$x] = ' & $S_Files2Attach[$x] & @LF & '>Error code: ' & @error & @LF) ;### Debug Console If FileExists($S_Files2Attach[$x]) Then ConsoleWrite('+> File attachment added: ' & $S_Files2Attach[$x] & @LF) $objEmail.AddAttachment($S_Files2Attach[$x]) Else ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF) SetError(1) Return 0 EndIf Next EndIf $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer If Number($IPPort) = 0 Then $IPPort = 25 $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort ; Authenticated SMTP If $s_Username <> "" Then $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password EndIf ; Set security params If $ssl Then $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True If $tls Then $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendtls") = True ; Update settings $objEmail.Configuration.Fields.Update ; Set Email Importance Switch $s_Importance Case "High" $objEmail.Fields.Item("urn:schemas:mailheader:Importance") = "High" Case "Normal" $objEmail.Fields.Item("urn:schemas:mailheader:Importance") = "Normal" Case "Low" $objEmail.Fields.Item("urn:schemas:mailheader:Importance") = "Low" EndSwitch $objEmail.Fields.Update ; Sent the Message $objEmail.Send If @error Then SetError(2) Return $oMyRet[1] EndIf $objEmail = "" EndFunc ;==>_INetSmtpMailCom Func _SMTP_SendEmail_Example($s_ToAddress, $s_Subject, $s_Body, $s_Attachments) #Tidy_ILC_Pos=120 Local $aEMAIL_CONFIG = __EmailConfig__API() Local $SmtpServer = $aEMAIL_CONFIG[$EMAIL_CONFIG__22__SMTP_SERVER_NAME][$EMAIL_CONFIG__COL3_SAVELOAD_VALUE] ; address for the smtp-server to use - REQUIRED Local $FromName = $aEMAIL_CONFIG[$EMAIL_CONFIG__02__COMMON_NAME][$EMAIL_CONFIG__COL3_SAVELOAD_VALUE] ; name from who the email was sent Local $FromAddress = $aEMAIL_CONFIG[$EMAIL_CONFIG__03__EMAIL_ADDRESS][$EMAIL_CONFIG__COL3_SAVELOAD_VALUE] ; address from where the mail should come Local $ToAddress = $s_ToAddress ; destination address of the email - REQUIRED Local $Subject = $s_Subject ; subject from the email - can be anything you want it to be Local $Body = $s_Body ; the messagebody from the mail - can be left blank but then you get a blank mail Local $AttachFiles = $s_Attachments ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed Local $CcAddress = "" ; address for cc - leave blank if not needed Local $BccAddress = "" ; address for bcc - leave blank if not needed Local $Importance = "Normal" ; Send message priority: "High", "Normal", "Low" Local $Username = $aEMAIL_CONFIG[$EMAIL_CONFIG__20__SMTP_USER_NAME][$EMAIL_CONFIG__COL3_SAVELOAD_VALUE] ; username for the account used from where the mail gets sent - REQUIRED Local $Password = $aEMAIL_CONFIG[$EMAIL_CONFIG__21__SMTP_PASSWORD][$EMAIL_CONFIG__COL3_SAVELOAD_VALUE] ; password for the account used from where the mail gets sent - REQUIRED Local $IPPort = $aEMAIL_CONFIG[$EMAIL_CONFIG__23__SMTP_PORT_NUMBER][$EMAIL_CONFIG__COL3_SAVELOAD_VALUE] ; port used for sending the mail ; in many country port 25 is not recomended, in such case use 587 instead Local $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS Local $tls = 0 ; enables/disables TLS when required ;~ Local $IPPort = 465 ; GMAIL port used for sending the mail ;~ Local $ssl = 1 ; GMAIL enables/disables secure socket layer sending - put to 1 if using httpS Local $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl, $tls) If @error Then MsgBox(0, "Error sending email", "Error code: " & @error & @CRLF & "Description: " & $rc) EndIf EndFunc ;==>_SMTP_SendEmail_Example ; ; ; Com Error Handler Func MyErrFunc(ByRef $oMyError) Local $HexNumber = Hex($oMyError.number, 8) $oMyRet[0] = $HexNumber $oMyRet[1] = StringStripWS($oMyError.description, 3) ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF) SetError(1) ; something to check for when this function returns Return EndFunc ;==>MyErrFunc EmailConfig.au3 EmailConfig_Example_STMP_Mailer.au31 point