Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/30/2017 in all areas

  1. ; ;################################## ; Include ;################################## #Include<file.au3> ;################################## ; Variables ;################################## $SmtpServer = "MailServer" ; address for the smtp-server to use - REQUIRED $FromName = "Name" ; name from who the email was sent $FromAddress = "your@Email.Address.com" ; address from where the mail should come $ToAddress = "your@Email.Address.com" ; destination address of the email - REQUIRED $Subject = "Userinfo" ; subject from the email - can be anything you want it to be $Body = "" ; the messagebody from the mail - can be left blank but then you get a blank mail $AttachFiles = "" ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed $CcAddress = "CCadress1@test.com" ; address for cc - leave blank if not needed $BccAddress = "BCCadress1@test.com" ; address for bcc - leave blank if not needed $Importance = "Normal" ; Send message priority: "High", "Normal", "Low" $Username = "******" ; username for the account used from where the mail gets sent - REQUIRED $Password = "********" ; password for the account used from where the mail gets sent - REQUIRED $IPPort = 25 ; port used for sending the mail $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS $tls = 0 ; enables/disables TLS when required ;~ $SmtpServer = "smtp.gmail.com" ; GMAIL address for the smtp-server to use - REQUIRED ;~ $IPPort=465 ; GMAIL port used for sending the mail ;~ $ssl=1 ; GMAIL enables/disables secure socket layer sending - put to 1 if using https ;~ $SmtpServer = "smtp.office365.com" ; O365 address for the smtp-server to use - REQUIRED ;~ $IPPort=25 ; O365 port used for sending the mail ;~ $ssl=1 ; O365 enables/disables secure socket layer sending - put to 1 if using https ;~ SmtpServer = "smtp.mail.yahoo.com" ; Yahoo address for the smtp-server to use - REQUIRED ;~ $IPPort = 465 ; Yahoo port used for sending the mail ;~ $ssl = 1 ; Yahoo enables/disables secure socket layer sending - put to 1 if using https ;################################## ; Script ;################################## Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl, $tls) If @error Then MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc) EndIf ; ; 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 $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $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 ; ; ; Com Error Handler Func MyErrFunc() $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 Edit: Fixed Bcc ... Edit: Added support for different port and SLL which are used by GMail (Port 465) Edit: Added Importance support (10/2008) EDIT: Added $TLS option (07/2020 Some interesting Info from the thread:
    1 point
  2. JLogan3o13

    GUI ?

    The short answer to your question is yes, you can accomplish all you are trying to do. I would suggest as a beginning exercise to download and install the full version of AutoIt and SciTE, then choose Koda from the tools menu. You can use this form builder to try out creating a GUI shell with the different controls such as buttons and drop down menus. Once you have a framework you're happy with, look at the GUICtrlCreate* sections in the help file to show you how to interact with those controls. If you run into any issues, post your code here and we will do our best to assist.
    1 point
  3. mikell

    StringReplace Occurance?

    This could be done using StringRegExpReplace, with lookarounds in the pattern to base replacements upon what precedes/follows the string to be replaced
    1 point
  4. Skysnake

    Run binary

    There is a problem with page 9 of this thread. Page 8 works, and page 10 works. Page 9 does not load.
    1 point
  5. jchd

    Quotes in query SQLite...

    _SQLite_Exec($hDatabase, _ "CREATE TABLE Magazzino_Siemens (" & _ ; here Siemens is data put in schema name; will make your life much harder "ID integer primary key, " & _ ; wild guess it's an integer id "MARCA text, " & _ "QUANTITA numeric, " & _ ; can it be float? if not, use INT instead "SCAFFALE text, " & _ "DESCRIZIONE text, " & _ "COSTO numeric, " & _ ; prefer prices as integers (scale accordingly) "NOTE text, " & _ "INFO text, " & _ "BARCODE text, " & _ "DATA_INSERIMENTO text, " & _ ; beware that Excel dates are "special" "DATA_PRELIEVO text, " & _ ; convert them to UTC ISO (yyyy-mm-dd) "DATA_MODIFICA text" & _ ");" _ ) $oWorkbook.Sheets("Magazzino Siemens").Activate Local $aRisultatoSiemens = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("A:L"), 1, True) If (@error) Then MsgBox($MB_ICONERROR, "Errore!", "Errore: " & @error) Else For $i = UBound($aRisultatoSiemens) - 1 To 4 Step -1 If($aRisultatoSiemens[$i][4] = "") Then _ArrayDelete($aRisultatoSiemens, $i) Next _SQLite_Exec($hDatabase, "begin") For $i = 3 To UBound($aRisultatoSiemens) - 1 _SQLite_Exec($hDatabase, _ "INSERT INTO Magazzino_Siemens (" & _ "ID, " & _ "MARCA, " & _ "QUANTITA, " & _ "SCAFFALE, " & _ "DESCRIZIONE, " & _ "COSTO, " & _ "NOTE, " & _ "INFO, " & _ "BARCODE, " & _ "DATA_INSERIMENTO, " & _ "DATA_PRELIEVO, " & _ "DATA_MODIFICA" & _ ") VALUES (" & _ $aRisultatoSiemens[$i][0] & "," & _ ; ID _SQLite_FastEscape($aRisultatoSiemens[$i][1]) & "," & _ ; MARCA $aRisultatoSiemens[$i][2] & "," & _ ; QUANTITA _SQLite_FastEscape($aRisultatoSiemens[$i][3]) & "," & _ ; SCAFFALE _SQLite_FastEscape($aRisultatoSiemens[$i][4]) & "," & _ ; DESCRIZIONE $aRisultatoSiemens[$i][5] & "," & _ ; COSTO _SQLite_FastEscape($aRisultatoSiemens[$i][6]) & "," & _ ; NOTE _SQLite_FastEscape($aRisultatoSiemens[$i][7]) & "," & _ ; INFO _SQLite_FastEscape($aRisultatoSiemens[$i][8]) & "," & _ ; BARCODE | those last 4 fields are unlikely _SQLite_FastEscape($aRisultatoSiemens[$i][9]) & "," & _ ; DATA_INSERIMENTO | to contain single quotes _SQLite_FastEscape($aRisultatoSiemens[$i][10]) & "," & _ ; DATA_PRELIEVO | but this is bulletproof _SQLite_FastEscape($aRisultatoSiemens[$i][11]) & _ ; DATA_MODIFICA | convert dates before!!! ");" _ ) Next _SQLite_Exec($hDatabase, "commit") EndIf
    1 point
  6. Here you go doing it using Excel UDF added comments so hope it makes sense : #include <Array.au3> ;~ Include the Excel UDF #include <Excel.au3> ;~ Connects to an existing Excel instance or creates a new Excel instance Local $oExcel = _Excel_Open() If @error Then Exit MsgBox(16, "Excel UDF", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;~ Workbook name to open/read Local $sWorkbook = @ScriptDir & '\data.xls' ;~ Open Workbook $sWorkbook or Connect to existing Workbook $sWorkbook Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook) If @error Then Exit MsgBox(16, "Excel UDF", "Error opening '" & $sWorkbook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;~ Copy the cells used within $sWorkbook to an Array Local $aResult = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange) If @error Then Exit MsgBox(16, "Excel UDF", "Error reading from workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended) _ArrayDisplay($aResult) ;~ Chane the Array into a String Local $sResult = _ArrayToString($aResult, @TAB) ;~ Save the results to a data.txt in the same folder $hFileOpen = FileOpen(@ScriptDir & '\Data.txt', 2) ;~ Write $sResults to data.txt FileWrite($hFileOpen, $sResult) ;~ Close and Save the file FileClose($hFileOpen)
    1 point
  7. Using a conditional pattern : $res = StringRegExp($str, '^\d\d?([A-Z])?(?(1)\*?)$') or just a Or operator : $res = StringRegExp($str, '^\d\d?([A-Z]?|[A-Z]\*?)$')
    1 point
  8. water

    OutlookEX UDF

    I think I know why _OL_MailSignatureGet crashes As we do not call _OL_Open there is no COM error handler in place. But all versions of AutoIt after 3.3.12.0 need a COM error handler to grab COM Errors. If there is none the script crashes. As we do not want to call _OL_Open you simply could add _OL_ErrorNotify(4) at the top of your script.
    1 point
  9. If you write the Ini-file into the users @AppDataDir then this should work for multiple users.
    1 point
  10. Or you just write something to the users HKCU or to AppData, registry is generally better for this type of thing: #include <File.au3> ;======Main===== UserMSG();#UserMSG()# FunStuff() ;======Functions===== Func UserMSG() If RegRead('HKCU\Software\MyProgram', 'Show Message') = 0 Then Return $infomsg = MsgBox(4,"Info","Bla bla bla" & @CRLF & @CRLF & "Never see this again press ""YES""") If $infomsg == 6 Then RegWrite('HKCU\Software\MyProgram', 'Show Message', 'REG_DWORD', 0) endFunc;UserMSG() Func FunStuff() EndFunc
    1 point
  11. Danyfirex

    use DllCall

    Hello. You need to do this: #include <WinAPI.au3> Global Const $CP_UTF8 = 65001 Global $LibXslDll = 0 Global $LibXslDll = 0 _XslStart("libxlsxwriter.dll") Local $p = _OpenWorkBook("prova.xlsx") _CloseWorkBook($p) Func _XslStart($dll) $LibXslDll = DllOpen($dll) If $LibXslDll = -1 Then Return SetError(1, 0, 0) Return 1 EndFunc ;==>_XslStart Func _OpenWorkBook($filename) Local $tStringUTF8 = _WinAPI_WideCharToMultiByte($filename, $CP_UTF8, False) Local $pString = DllStructGetPtr($tStringUTF8) $result = DllCall($LibXslDll, "ptr:cdecl", "new_workbook", "ptr", $pString) If @error Then ConsoleWrite(@error) Return -1 Else Return $result[0] EndIf EndFunc ;==>_OpenWorkBook Func _CloseWorkBook($Work) $result = DllCall($LibXslDll, "int:cdecl", "workbook_close", "ptr", $Work) If @error Then ConsoleWrite(@error) EndIf EndFunc ;==>_CloseWorkBook Saludos
    1 point
  12. Made a few minor changes that I thought would help: #include <Excel.au3> #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> HotKeySet(("{ESC}"),"Terminate") Global $iBox, $oExcel, $oWorkbook VitalSite() ;~ Added Input Function Excel () Logon () Sleep (2000) Auto () WinWaitActive ("[CLASS:MagicFS]", "", "MagicFS Dispaly6") Func FormatDate($DATE) $SPLIT = StringSplit($DATE," ") $MM = StringMid($SPLIT[1],5,2) $YYYY = StringLeft($SPLIT[1],4) $DD = StringMid($SPLIT[1],7,2) Return $MM & "/" & $DD & "/" & $YYYY EndFunc Func Terminate() Exit EndFunc Func VitalSite() Local $iMsg While 1 ;~ Turn input into a number $iBox = Number(InputBox ("Vital Site", "How Many Times")) ;~ If user enters a string or cancels then get them to try again If $iBox = 0 Then $iMsg = MsgBox(1,'Vital Site', 'Please enter a valid number') If $iMsg = 2 Then Exit Else ExitLoop EndIf WEnd EndFunc Func Excel() While ProcessExists("EXCEL.EXE") $ms = MsgBox(5,"","Process error. You have an Excel sheet open. You must close it in order to let this program work. Please close it now.") If $ms=2 Then Exit ;~ Doesn't require sleep since the script is paused by the MsgBox above ;~ Sleep(250) WEnd ;~ Shouldn't use Global Scope inside functions moved to top of script Local $sExcelFile = FileOpenDialog("Choose/Create Excel File", @ScriptDir, "(*.xlsx)") If FileExists($sExcelFile) Then ;~ Shouldn't use Global Scope inside functions moved to top of script $oExcel = _Excel_Open () $oWorkbook = _Excel_BookOpen($oExcel,$sExcelFile) ;this will open the chosen xls file. Else $oExcel = _Excel_Open() $oWorkbook = _Excel_BookNew($oExcel, 2);this is here to create the xls file if it does not exist. EndIf EndFunc Func Logon () $portal = ShellExecute ("C:\Program Files (x86)\MEDITECH\SSDWEB.Universe\SSDWEB.LIVEF.Ring\Client.mtad") ;MediTech WinWaitActive ("[CLASS:MagicFS]", "", "MagicFS Dispaly5") Sleep (300) ControlSend("[CLASS:MagicFS]", "", "", ("{F12}")) Sleep (700) ControlSend("[CLASS:MagicFS]", "", "", ("{RIGHT}")) Sleep (700) ControlSend("[CLASS:MagicFS]", "", "", ("{DOWN}")) Sleep (700) ControlSend("[CLASS:MagicFS]", "", "", ("{RIGHT}")) Sleep (700) ControlSend("[CLASS:MagicFS]", "", "", ("{RIGHT}")) Sleep (700) ControlSend("[CLASS:MagicFS]", "", "", ("{RIGHT}")) EndFunc Func Auto () Local $r = 1 Local $aArray = _Excel_RangeRead($oWorkbook) ;~ If $iBox is greater than no. of rows in $aArray then $iBox equals the number of rows in $aArray If $iBox > (UBound($aArray) - 1) Then $iBox = UBound($aArray) - 1 For $i = 1 To UBound($aArray) - 1 ;$i =0 Start from row A $sR0 = $aArray[$i][0] ;status $sR1 = $aArray[$i][1] ;first name $sR2 = $aArray[$i][2] ;Last name $sR3 = $aArray[$i][3] ;Last 4 SSN $sR4 = $aArray[$i][4] ;DOB $sR5 = $aArray[$i][5] ;Email Address $sR6 = $aArray[$i][6] ;Mailling Address $sR7 = $aArray[$i][7] ;City $sR8 = $aArray[$i][8] ;state $sR9 = $aArray[$i][9] ;Zip Code $sR10 = $aArray[$i][10] ;Gender $sR11 = $aArray[$i][11] ;Phone ControlSend("[CLASS:MagicFS]", "", "", ("{F8}")) Sleep (500) ControlSend("[CLASS:MagicFS]", "", "", ("{F8}")) Sleep (500) ControlSend("[CLASS:MagicFS]", "", "", ("N")) ControlSend("[CLASS:MagicFS]", "", "", ("{TAB}")) Sleep (3000) ControlSend("[CLASS:MagicFS]", "", "Edit1", $sR1 & @CR) Sleep (200) ControlSend("[CLASS:MagicFS]", "", "", ("{TAB}")) Sleep (200) ControlSend("[CLASS:MagicFS]", "", "Edit1", $sR2 & @CR) Sleep (200) ControlSend("[CLASS:MagicFS]", "", "", ("{TAB}")) Sleep (200) ControlSend("[CLASS:MagicFS]", "", "Edit1", $sR6& @CR) Sleep (200) ControlSend("[CLASS:MagicFS]", "", "", ("{TAB}")) Sleep (200) ControlSend("[CLASS:MagicFS]", "", "Edit1", $sR7 & @CR) Sleep (200) ControlSend("[CLASS:MagicFS]", "", "Edit1", $sR8 & @CR) Sleep (200) ControlSend("[CLASS:MagicFS]", "", "Edit1", $sR9 & @CR) Sleep (200) ControlSend("[CLASS:MagicFS]", "", "Edit1", $sR11& @CR) Sleep (200) ControlSend("[CLASS:MagicFS]", "", "Edit1", $sR5 & @CR) ;Email7 Sleep (200) ControlSend("[CLASS:MagicFS]", "", "Edit1", $sR5 & @CR) ;Email Sleep (200) ControlSend("[CLASS:MagicFS]", "", "", (FormatDate($sR4) & @CR)) Sleep (200) ControlSend("[CLASS:MagicFS]", "", "Edit1", $sR10 & @CR) Sleep (200) ControlSend("[CLASS:MagicFS]", "", "Edit1", $sR3 & @CR) Sleep (200) ControlSend("[CLASS:MagicFS]", "", "", ("{F8}")) Sleep (200) ControlSend("[CLASS:MagicFS]", "", "", ("P")) Sleep (200) $hBox = MsgBox($MB_OK & $MB_TOPMOST,"Patient Portal","After you have entered the patient push OK") ControlSend("[CLASS:MagicFS]", "", "", ("{F8 3}")) Sleep (200) ControlSend("[CLASS:MagicFS]", "", "", ("{ESC}")) Sleep (200) ControlSend("[CLASS:MagicFS Modal(3)]", "", "", ("{ENTER}")) $r += 1 If $r > $iBox Then Exit Next EndFunc
    1 point
  13. When the msgbox appears and you click ok, you set $sbox to 1, which after the second pass $r will be > $sbox
    1 point
  14. Demo of REG_BINARY read/modify/write/verify: Global $binData = Binary("0xFEDCBA9876543210FEDCBA9876543210FEDCBA9876543210") Global $binRead, $binWrite ; Initial conditions ConsoleWrite("$binData = " & $binData & @LF) RegWrite("HKLM\SOFTWARE\AutoIt v3\Test", "Bin_Test", "REG_BINARY", $binData) ; Read $binRead = RegRead("HKLM\SOFTWARE\AutoIt v3\Test", "Bin_Test") ConsoleWrite("$binRead = " & $binRead & @LF) ; Modify 8th byte (15th/16th char in Hex) $binWrite = BinaryMid($binRead, 1, 7) & Binary("0xCC") & BinaryMid($binRead, 9) ConsoleWrite("$binWrite = " & $binWrite & @LF) RegWrite("HKLM\SOFTWARE\AutoIt v3\Test", "Bin_Test", "REG_BINARY", $binWrite) ; Re-read $binRead = RegRead("HKLM\SOFTWARE\AutoIt v3\Test", "Bin_Test") ConsoleWrite("$binRead = " & $binRead & @LF)
    1 point
  15. I just give you a clue. @ScriptName But still Im not convinced with your purpose.
    1 point
  16. Yo suplada, Try This:: $MsgRet = MsgBox(1,"Hello "& @USERNAME,"Would you like to continue?") IF $MsgRet = 2 THEN EXIT MsgBox(0,"","You clicked ok") If you check out the helpfile on MsgBox() You will see that the cancel button returns with a msg code of 2. By allocating a variable to the return value of MsgBox, you can retrieve and use these msg codes. Vlad
    1 point
×
×
  • Create New...