Jump to content

Leaderboard

Popular Content

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

  1. I want to present BETA Version of my ADO.au3 UDF. This is modifed version of _sql.au3 UDF. For that I want to thanks : ; Chris Lambert, eltorro, Elias Assad Neto, CarlH This is first public release , and still is as BETA DOWNLOAD LINK (in download section): Have fun, mLipok EDIT: 2016-06-03 Below some interesting topics about databases: EDIT 2016/07/04: For more info about ADO look here: https://www.autoitscript.com/wiki/ADO FOR EXAMPLE DATABASE use AdventureWorksDW2016_EXT.bak from: https://github.com/microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksDW2016_EXT.bak I will relay on this database in my examples. Here is link to post which shows how "ODBC Data Source Administrator" looks like.
    1 point
  2. mLipok

    SMTP Mailer UDF

    I very long time was using In the end, I found that at present my needs I need to modify it. And here it is: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ;~ #AutoIt3Wrapper_Run_Debug_Mode=Y ;(Y/N) Run Script with console debugging. Default=N #Region INCLUDE ;################################## ; Include ;################################## #include <file.au3> #EndRegion INCLUDE #Region Variables ;################################## ; Variables ;################################## Global Enum _ $g__INetSmtpMailCom_ERROR_FileNotFound = 1, _ $g__INetSmtpMailCom_ERROR_Send, _ $g__INetSmtpMailCom_ERROR_ObjectCreation, _ $g__INetSmtpMailCom_ERROR_COUNTER Global Const $g__cdoSendUsingPickup = 1 ; Send message using the local SMTP service pickup directory. Global Const $g__cdoSendUsingPort = 2 ; Send the message using the network (SMTP over the network). Must use this to use Delivery Notification Global Const $g__cdoAnonymous = 0 ; Do not authenticate Global Const $g__cdoBasic = 1 ; basic (clear-text) authentication Global Const $g__cdoNTLM = 2 ; NTLM ; Delivery Status Notifications Global Const $g__cdoDSNDefault = 0 ; None Global Const $g__cdoDSNNever = 1 ; None Global Const $g__cdoDSNFailure = 2 ; Failure Global Const $g__cdoDSNSuccess = 4 ; Success Global Const $g__cdoDSNDelay = 8 ; Delay Global Const $g__cdoDSNSuccessFailOrDelay = 14 ; Success, failure or delay #EndRegion Variables #Region Example Script ;################################## ; Example Script ;################################## ;~ _Example() Func _Example() Local $sSmtpServer = "MailServer" ; address for the smtp-server to use - REQUIRED Local $sFromName = "Name" ; name from who the email was sent Local $sFromAddress = "your@Email.Address.com" ; address from where the mail should come Local $sToAddress = "your@Email.Address.com" ; destination address of the email - REQUIRED Local $sSubject = "Userinfo" ; subject from the email - can be anything you want it to be Local $sBody = "" ; the messagebody from the mail - can be left blank but then you get a blank mail Local $sAttachFiles = "" ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed Local $sCcAddress = "CCadress1@test.com" ; address for cc - leave blank if not needed Local $sBccAddress = "BCCadress1@test.com" ; address for bcc - leave blank if not needed Local $sImportance = "Normal" ; Send message priority: "High", "Normal", "Low" Local $sUsername = "******" ; username for the account used from where the mail gets sent - REQUIRED Local $sPassword = "********" ; password for the account used from where the mail gets sent - REQUIRED Local $iIPPort = 25 ; port used for sending the mail Local $bSSL = False ; enables/disables secure socket layer sending - set to True if using httpS ; Local $iIPPort = 465 ; GMAIL port used for sending the mail ; Local $bSSL = True ; GMAIL enables/disables secure socket layer sending - set to True if using httpS Local $bIsHTMLBody = False Local $iDSNOptions = $g__cdoDSNDefault Local $rc = _INetSmtpMailCom($sSmtpServer, $sFromName, $sFromAddress, $sToAddress, $sSubject, $sBody, $sAttachFiles, $sCcAddress, $sBccAddress, $sImportance, $sUsername, $sPassword, $iIPPort, $bSSL, $bIsHTMLBody, $iDSNOptions) If @error Then MsgBox(0, "_INetSmtpMailCom(): Error sending message", _ "Error code: " & @error & @CRLF & @CRLF & _ "Error Hex Number: " & _INetSmtpMailCom_ErrHexNumber() & @CRLF & @CRLF & _ "Description: " & _INetSmtpMailCom_ErrDescription() & @CRLF & @CRLF & _ "Description (rc): " & $rc & @CRLF & @CRLF & _ "ScriptLine: " & _INetSmtpMailCom_ErrScriptLine() _ ) ConsoleWrite("### COM Error ! Number: " & _INetSmtpMailCom_ErrHexNumber() & " ScriptLine: " & _INetSmtpMailCom_ErrScriptLine() & " Description:" & _INetSmtpMailCom_ErrDescription() & @LF) EndIf EndFunc ;==>_Example #EndRegion Example Script #Region UDF Functions ; The UDF ; #FUNCTION# ==================================================================================================================== ; Name ..........: _INetSmtpMailCom ; Description ...: ; Syntax ........: _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[, $bSSL = False[, $bIsHTMLBody = False[, $iDSNOptions = $g__cdoDSNDefault]]]]]]]]]]]]) ; Parameters ....: $s_SmtpServer - A string value. ; $s_FromName - A string value. ; $s_FromAddress - A string value. ; $s_ToAddress - A string value. ; $s_Subject - [optional] A string value. Default is "". ; $s_Body - [optional] A string value. Default is "". ; $s_AttachFiles - [optional] A string value. Default is "". ; $s_CcAddress - [optional] A string value. Default is "". ; $s_BccAddress - [optional] A string value. Default is "". ; $s_Importance - [optional] A string value. Default is "Normal". ; $s_Username - [optional] A string value. Default is "". ; $s_Password - [optional] A string value. Default is "". ; $IPPort - [optional] An integer value. Default is 25. ; $bSSL - [optional] A binary value. Default is False. ; $bIsHTMLBody - [optional] A binary value. Default is False. ; $iDSNOptions - [optional] An integer value. Default is $g__cdoDSNDefault. ; Return values .: None ; Author ........: Jos ; Modified ......: mLipok ; Remarks .......: ; Related .......: http://www.autoitscript.com/forum/topic/23860-smtp-mailer-that-supports-html-and-attachments/ ; Link ..........: http://www.autoitscript.com/forum/topic/167292-smtp-mailer-udf/ ; Example .......: Yes ; =============================================================================================================================== Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $s_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance = "Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $bSSL = False, $bIsHTMLBody = False, $iDSNOptions = $g__cdoDSNDefault) ; init Error Handler _INetSmtpMailCom_ErrObjInit() Local $objEmail = ObjCreate("CDO.Message") If Not IsObj($objEmail) Then Return SetError($g__INetSmtpMailCom_ERROR_ObjectCreation, Dec(_INetSmtpMailCom_ErrHexNumber()), _INetSmtpMailCom_ErrDescription()) ; Clear previous Err information _INetSmtpMailCom_ErrHexNumber(0) _INetSmtpMailCom_ErrDescription('') _INetSmtpMailCom_ErrScriptLine('') $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress $objEmail.Subject = $s_Subject ; Select whether or not the content is sent as plain text or HTM If $bIsHTMLBody Then $objEmail.Textbody = $s_Body & @CRLF Else $objEmail.HTMLBody = $s_Body EndIf ; Add Attachments If $s_AttachFiles <> "" Then Local $S_Files2Attach = StringSplit($s_AttachFiles, ";") For $x = 1 To $S_Files2Attach[0] $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x]) 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) Return SetError($g__INetSmtpMailCom_ERROR_FileNotFound, 0, 0) EndIf Next EndIf ; Set Email Configuration $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = $g__cdoSendUsingPort $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") = $g__cdoBasic $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 $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = $bSSL ;Update Configuration 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 ; Set DSN options If $iDSNOptions <> $g__cdoDSNDefault And $iDSNOptions <> $g__cdoDSNNever Then $objEmail.DSNOptions = $iDSNOptions $objEmail.Fields.Item("urn:schemas:mailheader:disposition-notification-to") = $s_FromAddress ;~ $objEmail.Fields.Item("urn:schemas:mailheader:return-receipt-to") = $s_FromAddress EndIf ; Update Importance and Options fields $objEmail.Fields.Update ; Sent the Message $objEmail.Send If @error Then _INetSmtpMailCom_ErrObjCleanUp() Return SetError($g__INetSmtpMailCom_ERROR_Send, Dec(_INetSmtpMailCom_ErrHexNumber()), _INetSmtpMailCom_ErrDescription()) EndIf ; CleanUp $objEmail = "" _INetSmtpMailCom_ErrObjCleanUp() EndFunc ;==>_INetSmtpMailCom ; ; Com Error Handler Func _INetSmtpMailCom_ErrObjInit($bParam = Default) Local Static $oINetSmtpMailCom_Error = Default If $bParam == 'CleanUp' And $oINetSmtpMailCom_Error <> Default Then $oINetSmtpMailCom_Error = '' Return $oINetSmtpMailCom_Error EndIf If $oINetSmtpMailCom_Error = Default Then $oINetSmtpMailCom_Error = ObjEvent("AutoIt.Error", "_INetSmtpMailCom_ErrFunc") EndIf Return $oINetSmtpMailCom_Error EndFunc ;==>_INetSmtpMailCom_ErrObjInit Func _INetSmtpMailCom_ErrObjCleanUp() _INetSmtpMailCom_ErrObjInit('CleanUp') EndFunc ;==>_INetSmtpMailCom_ErrObjCleanUp Func _INetSmtpMailCom_ErrHexNumber($vData = Default) Local Static $vReturn = 0 If $vData <> Default Then $vReturn = $vData Return $vReturn EndFunc ;==>_INetSmtpMailCom_ErrHexNumber Func _INetSmtpMailCom_ErrDescription($sData = Default) Local Static $sReturn = '' If $sData <> Default Then $sReturn = $sData Return $sReturn EndFunc ;==>_INetSmtpMailCom_ErrDescription Func _INetSmtpMailCom_ErrScriptLine($iData = Default) Local Static $iReturn = '' If $iData <> Default Then $iReturn = $iData Return $iReturn EndFunc ;==>_INetSmtpMailCom_ErrScriptLine Func _INetSmtpMailCom_ErrFunc() _INetSmtpMailCom_ErrObjInit() _INetSmtpMailCom_ErrHexNumber(Hex(_INetSmtpMailCom_ErrObjInit().number, 8)) _INetSmtpMailCom_ErrDescription(StringStripWS(_INetSmtpMailCom_ErrObjInit().description, 3)) _INetSmtpMailCom_ErrScriptLine(_INetSmtpMailCom_ErrObjInit().ScriptLine) SetError(1); something to check for when this function returns Return EndFunc ;==>_INetSmtpMailCom_ErrFunc #EndRegion UDF Functions Creating this modification, I had to: 1. Object Error Handler used only for the duration of the function of Use, 2. Automatic ErrorHandler CleanUp so that previous ErrorHandler took the job. 3. Ability to get ErrorNumber and ErrorDescription ErrorScriptLine information even after the end of the function 4. Elimination of most global variables mLipok EDIT: attached SmtpMailer_UDF.au3 file EDIT 2: Any comments are welcome. EDIT 3: Script CleanUp EDIT 4: Download moved to "Download Section" (previously downloaded 379 times) EDIT 5: at 2016/01/31 there was many script breaking changes
    1 point
  3. thanks earthshine, well ur right, i first had to think how to generally run my thoughts in a script : ) now ive changed it to.... and this works perfectly : ) HotKeySet("{ESC}", "_ExitScript") ;~ Global $g_iTimerDiff = 1000 * 60 * 10 ;~ 10 minutes Global $g_iTimerDiff = 1000 * 10 ;~ 10 seconds for testing Global $g_hTimerInit, $fTimerDiff = $g_iTimerDiff Global $g_iProcessId $linktorun1 = '"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --profile-directory="Profile 1"' $linktorun2 = '"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --profile-directory="Profile 2"' Global $g_aPrograms[2] = [$linktorun1, $linktorun2& " /k"] Global $i = (UBound($g_aPrograms) - 1) While 1 If $fTimerDiff >= $g_iTimerDiff Then ProcessClose($g_iProcessId) $i = $i = (UBound($g_aPrograms) - 1) ? 0 : $i + 1 _RunProgram($g_aPrograms[$i]) EndIf Sleep(100) $fTimerDiff = TimerDiff($g_hTimerInit) WEnd Func _RunProgram($_sProgram) $g_hTimerInit = TimerInit() $g_iProcessId = Run($_sProgram) EndFunc Func _ExitScript() Exit EndFunc
    1 point
  4. Basic example, for testing I've set it to 10 seconds. HotKeySet("{ESC}", "_ExitScript") ;~ Global $g_iTimerDiff = 1000 * 60 * 10 ;~ 10 minutes Global $g_iTimerDiff = 1000 * 10 ;~ 10 seconds for testing Global $g_hTimerInit, $fTimerDiff = $g_iTimerDiff Global $g_iProcessId Global $g_aPrograms[2] = ["Notepad.exe", @ComSpec & " /k"] Global $i = (UBound($g_aPrograms) - 1) While 1 If $fTimerDiff >= $g_iTimerDiff Then ProcessClose($g_iProcessId) $i = $i = (UBound($g_aPrograms) - 1) ? 0 : $i + 1 _RunProgram($g_aPrograms[$i]) EndIf Sleep(100) $fTimerDiff = TimerDiff($g_hTimerInit) WEnd Func _RunProgram($_sProgram) $g_hTimerInit = TimerInit() $g_iProcessId = Run($_sProgram) EndFunc Func _ExitScript() Exit EndFunc
    1 point
  5. Do you think that we’re just going to cough them up because you asked for it? There’s a search feature provided on this forum that you should use and then create some Script using the REST udf. Once you provide that people here can help you more
    1 point
  6. Try: #include <Excel.au3> Global $sAnKcSbData = @ScriptDir & "\AnKcSbData.ini" Global $aSectionNames = IniReadSectionNames($sAnKcSbData) If @error Then Exit MsgBox(4096, "Error", "Error Reading Seciton Names") Global $aAnKcSbData[$aSectionNames[0] + 1][9] For $i = 1 To $aSectionNames[0] $aAnKcSbData[$i - 1][0] = IniRead($sAnKcSbData, $aSectionNames[$i], "Roww", "Not Found") $aAnKcSbData[$i - 1][1] = IniRead($sAnKcSbData, $aSectionNames[$i], "City", "Not Found") $aAnKcSbData[$i - 1][2] = IniRead($sAnKcSbData, $aSectionNames[$i], "Vill", "Not Found") $aAnKcSbData[$i - 1][3] = IniRead($sAnKcSbData, $aSectionNames[$i], "Strt", "Not Found") $aAnKcSbData[$i - 1][4] = IniRead($sAnKcSbData, $aSectionNames[$i], "Iden", "Not Found") $aAnKcSbData[$i - 1][5] = IniRead($sAnKcSbData, $aSectionNames[$i], "Name", "Not Found") $aAnKcSbData[$i - 1][6] = IniRead($sAnKcSbData, $aSectionNames[$i], "Fath", "Not Found") $aAnKcSbData[$i - 1][7] = IniRead($sAnKcSbData, $aSectionNames[$i], "Damg", "Not Found") $aAnKcSbData[$i - 1][8] = IniRead($sAnKcSbData, $aSectionNames[$i], "Expl", "Not Found") Next Local $oExcel = _Excel_Open() Local $oWorkbook = _Excel_BookNew($oExcel) _Excel_RangeWrite($oWorkbook, Default, $aAnKcSbData)
    1 point
  7. Do not think that works as the Icon is stored in the PE header of a program, which the a3x file doesn't have. Did you actually try?
    1 point
  8. How would this help? Jos
    1 point
  9. Total assumption that you are trying to click here, but try changing your Xpath to the iFrame to: $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='left-content']/div/iframe[2]") And the element you want to "possibly" click to: $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/html/body/div/div[1]/a[1]/img") This was the only element in that iFrame that I could find that "did something". Tested and works for me at least.
    1 point
  10. No, it appears to me that the script is running as written, but perhaps it isn't having the results you intended. What exactly do you expect to happen when you click on the element found with xpath of "//div[@id='contentbox-h']"? FWIW, Nothing happens when I manually click on this div, so I don't know what you would expect to occur. Perhaps you've targeted the wrong element? <shrug>
    1 point
  11. and the (simple) regex which fits nice... $txt = "text text tex text 123x 2x34 345" & @crlf & _ "text text tex text 123 23x4 3x45" & @crlf & _ "text text tex text 123 2x34 345" $res = StringRegExpReplace($txt, '(?m)^(.*?)\h{2,}.*', "$1") Msgbox(0,"", $res)
    1 point
  12. mylise

    Opencv UDF

    It has been a long time since my last visit and I notice nill's request. This maybe too late but here is how you can search for an image inside another image. Opencv uses cvMatchTemplate and cvMinMaxLoc. #include <GDIplus.au3> #include <Memory.au3> #include <GUIConstantsEx.au3> #include <OpenCVFcns.au3> ;start dll opencv _GDIPlus_Startup() _OpenCV_Startup() ;// load IPL type image both images must have same number of bits and color channels! $pimg = _cvLoadImage("whereWally3.jpg") $ptemp = _cvLoadImage("wally3.jpg") ;image to look for ;// Create some windows to show the input ;// and output images in. ;// _cvNamedWindow( "Where's Wally" ) ;// show our input image ;// _cvShowImage( "Where's Wally", $pimg) Sleep(1000) ;// Determine images height and width to create results matrix Local $width = DllStructGetData(_cvGetSize( $pimg ),"width") Local $height = DllStructGetData(_cvGetSize( $pimg ),"height") Local $width2 = DllStructGetData(_cvGetSize( $ptemp ),"width") Local $height2 = DllStructGetData(_cvGetSize( $ptemp ),"height") Local $rw = $width - $width2 + 1 Local $rh = $height - $height2 + 1 ;// Create Opencv matrix object 32 bit floating Local $presult=_cvCreateMat($rh,$rw,$CV_32FC1) ;// Template matching _cvMatchTemplate( $pimg , $ptemp , $presult , 5 ) _cvNormalize($presult,$presult,0,1,$CV_MINMAX,Null) _cvThreshold($presult,$presult,0.90,1,$CV_THRESH_BINARY) ;//locate matches ; ;// Create minmax variables to pass to opencv Local $tmaxloc = DllStructCreate($tagCvPoint) Local $tminloc = DllStructCreate($tagCvPoint) Local $tmaxval = DllStructCreate("double max;") Local $tminval = DllStructCreate("double min;") Local $pmaxloc = DllStructGetPtr($tmaxloc) Local $pminloc = DllStructGetPtr($tminloc) Local $pmaxval = DllStructGetPtr($tmaxval) Local $pminval = DllStructGetPtr($tminval) ;// create mask to find multiple matches Local $pmask = _cvCreateImage(_cvSize($rw, $rh), 8, 1) _cvSet($pmask,_cvScalar(1)) ;// Find location of maximum _cvMinMaxLoc( $presult, $pminval, $pmaxval, $pminloc, $pmaxloc, $pmask ) Do ;// Mask it to find others if exists and draw red rectangle on input image _cvRectangle($pmask,_cvPoint(DllStructGetData($tmaxloc, "x")- 5,DllStructGetData($tmaxloc, "y")-5),_cvPoint(DllStructGetData($tmaxloc, "x")+$width2,DllStructGetData($tmaxloc, "y")+$height2),_cvScalar(0),-1,8,0) _cvRectangle($pimg,_cvPoint(DllStructGetData($tmaxloc, "x")- 5,DllStructGetData($tmaxloc, "y")-5),_cvPoint(DllStructGetData($tmaxloc, "x")+$width2+10,DllStructGetData($tmaxloc, "y")+$height2+10),_CV_RGB(255, 0, 0),2,8,0) ;// Update input image _cvShowImage( "Where's Wally", $pimg) ;// Used to show that only one match is located each time sleep(3000) ;// Find location of maximum _cvMinMaxLoc( $presult, $pminval, $pmaxval, $pminloc, $pmaxloc, $pmask ) Until (DllStructGetData($tmaxval, "max")<.99) ;// Wait for the user to hit a key, then clean up the windows ;// _cvWaitKey( 0 ) ;// Be tidy ;// _cvReleaseImage( $pmask ) _cvReleaseMat( $presult ) _cvReleaseImage( $ptemp ) _cvReleaseImage( $pimg ) _cvDestroyAllWindows() _Opencv_CloseDLL() _GDIPlus_Shutdown() Exit
    1 point
  13. marshallprank, Easy (when you know how)! #include <Array.au3> Global $Content_Subfolder_include[3] = ["", "ABC", ""] ; Copy the array $arr_2 = $Content_Subfolder_include ; Move backwards through the array deleting the blank lines For $i = UBound($arr_2) - 1 To 0 Step -1 If $arr_2[$i] = "" Then _ArrayDelete($arr_2, $i) EndIf Next ; Et voila! _ArrayDisplay($arr_2)Note you need to move backwards through the array when deleting lines or you end up with element indexing errors. All clear? M23 Edit: And it still works if you add an element to the initial array as you have just done in your edit. But do rermember to increase the dimension size of the initial array if you do that.
    1 point
×
×
  • Create New...