Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/27/2015 in all areas

  1. If you have been using AutoIt for any length of time you will know that it is a great, and powerful scripting language. As with all powerful languages there comes a downside. Virus creation by those that are malicious. AutoIt has no virii installed on your system, and if a script you have created has been marked as a virus, (and you're not malicious) then this is a false positive. They found a set of instructions in an AutoIt EXE out there somewhere, took the general signature of the file, and now all AutoIt EXE's are marked (or most of them). This can be due to several reasons. AutoIt is packed with UPX. UPX is an open source software compression packer. It is used with many virii (to make them smaller). Malicious scripter got the AutoIt script engine recognized as a virus. And I am sure there are more ways your executable could be marked, but that covers the basics. Now I am sure you are wanting to know what you can do to get back up and running without being recognized as a virus. You have to send in a report to the offending AV company alerting them to the false positive they have made. It never hurts to send in your source code along with a compiled exe, to help them realize their mistake. You may have to wait up to 24 hours for them to release an update. The time it takes really depends on the offending AV company. Anti-Virus Links AntiVir Website Contact Avast! Website Contact McAfee Website Contact (email address) Symantec (Norton) Website Contact AVG Website Contact (It says sales or other ?'s I assume this will work) ClamWin Website Contact ClamAV Website Contact (I would only contact the ones with "virusdb maintainer or virus submission management") BitDefender Website Contact ZoneLabs Website Contact Norman Website Contact (email address) eSafe Website Contact (login required) A2 (A-Squared) Website Contact (email address) Edit: Added Website links and Contact links. I hope this helps you understand why your AutoIt executables are marked as virii. JS
    1 point
  2. BinaryToAu3Kompressor v1.0.5.4 It's now possible to see the best compression ratio using LZMA, LZNT and Base64 compressions with differents combinations. Nothing too complicate, you drag'n drop a file on the picture and script Test all compression types and return the ratios. ( Test duration depends of file size, slowest compression is LZNT, but all decompressions are fast ) Free to you after, to choose the compression(s) you want... Yes, LZMA needs a dll ( embedded & compressed in script ) but brings a powerfull compression. It opens scite with your file compressed to an au3 script with or without decompression function as you want. Hold Left Shift key when clicking button for just copy script to clipboard. Use the 3 compressions at a time works but doesn't give a good ratio, that's why i don't display it. Usefull for little files you want include in your scripts ! No externals files needed, they are already in script. Previous downloads : 1103 Source and Executable BinaryToAu3Kompressor will be added to the next version of >SciTEHopper Thanks to Ward for his >Base64.au3 and LZMA.au3, and trancexx for his >LZNT functions and his >Base64Decode function.
    1 point
  3. XvidCapture, demo capturing made easy, into avi video file with stereo sound. Script use XvidCapture.dll made for freebasic by D.J.Peters Major defects : The frame rate need to be limited due to the time for write datas (80-130 ms by frame with a 1920x1080 screen size and a 640x480 video size). The dll support only uncompressed wav audio format (do not work with mp3) The quality setting doesn't seem to change anything. Tested with AutoIt 3.3.8.1 on WinXP SP3 and AutoIt 3.3.12.0 on Win7/Win8.1 On my netbook using XP, i need to set fps to 5 with 320x240 ! On my Destop PC using W7 or W8.1 , i need to set fps to 7 with 854x480 ! So don't expect a video in high-definition with dolby surround from a little dll of 153 ko ! If FPS can be respected by the script, the audio and video can be synchronized, so adjust settings depending on the config of your pc. As usual externals files are embedded in script. Thanks to Smashly for his wave functions and also UEZ, Authenticity, Eukalyptus and jpm for the new GDIPLUS functions. source for 3.3.12.0 : XvidCapture v1.0.1.6.au3.html source for previous versions : XvidCapture v1.0.1.6 PreviousAutoItVersions.au3.html executable : XvidCapture.exe.html
    1 point
  4. TinyPicSharer : A simple and handy tool for capture window or picture by mouse grab and an uploader for 10 Pic Hosters ! You can also Resize, Convert, Optimize, add WaterMark to your images easily. (optimization with jpegtran.exe, optipng.exe, gifsicle.exe command line tools) In plus it can extract images from Docs (pdf, doc, docx, odt, odp, ppt, pptx, pps, ppsx) (Doc extraction with b2xtranslator and pdfextract.exe command line tools) Just Drag'n drop a picture/doc on the Host Logo for load it. I have replaced Curl by WinHttp functions and TrIDLib.DLL by my own FileGetType function. Previous downloads : 1343 Update of 8 June 2013 source and executable are available in the Download Section See Tray menu for options. Double click on his tray icon for restore the gui. >zlib.au3, WinHttp.au3, >WinAPIEx UDF are needed. ( Thanks to Ward, trancexx, Yashield ) Hope you 'll find it usefull !
    1 point
  5. Bowmore

    When a Loop isn't a Loop

    I write lots of data validation routines that run several hundred validation checks on each row of data and I use the same sort of structure as sown in your first post. The alternative would be a ridiculous set of nested IFs or ElseIfs. The loop that never loops in combination with If False Then ExitLoop statements is my opinion an elegant way to implement this for the following reasons: It is clear to read and understand. It is easy to add additional tests The order of the tests is easy to change It can be optimised by putting the tests most likely to fail at the top.
    1 point
  6. Where did this strange obsession to try and cram code into as few lines as possible, resulting in unreadable and almost impossible to debug code, come from?
    1 point
  7. The benefits of a GOTO statement without using a GOTO statement. I find it very clever.
    1 point
  8. water

    Using User Input

    Ok, thanks.
    1 point
  9. UPDATED - see first post. (v1.7) Added little fix to Summary (Book Description) read, for too many blank lines occasionally. Two more List context menu items added - "Price History" and "SETTINGS". 'Price History' means you can now disable it showing in "Selected Entry Detail" dialog, if you wish. 'SETTINGS' is a window to access all settings that previously required manual editing of INI file. This quick easy 'Settings' access, also has options to restore defaults. 'Remove' and 'ON TOP' buttons on main window, have now swapped positions. Main 'Information' dialog updated for a missing element from last version. NOTES - Having discovered too many blank lines in one of my ebook summaries, I decided to add a fix. Not wanting to make an update just for that, I racked my brain for some other elements worthy of coding for the update, and came up with the other improvements and features. While I haven't made a change to the default setting, I will never-the-less now set 'Show ALL price changes ...' to de-selected, for myself, as I see it becoming a size issue for some ebooks with large summaries. You shoud probably do the same. If you haven't made any user additions for VALUE (characters), and you haven't done what was suggested last version, and are not installing for the first time, then you should benefit from doing an UPDATE on the SETTINGS window for that option (just click UPDATE, with no VALUE selected).
    1 point
  10. water

    When a Loop isn't a Loop

    When I start a new project my code should be as clean as possible (means: adhere to good coding practices. A good starting point is the "Good Coding Practices" thread on the forum). Over time the code gets more complex as new functionality gets implemented. The script should be so well documented that you still understand what you have intented with your code even when you have a look at it again a few years later.
    1 point
  11. water

    When a Loop isn't a Loop

    Then I would stick with your current approach. Seems to be the best way to do what you want.
    1 point
  12. I just had an eye surgery ... but I do not think this is what you mean by "fresh pair of eyes"
    1 point
  13. Best thing you can do here when looking for help, is only say exactly what you mean and try to be as precise as you possibly can. I never offered further code help as I thought you were actually familiar working with arrays, and you just made a schoolboy error, I suspect the poster above thought the same. Sorry I got you wrong, no harm done.
    1 point
  14. '?do=embed' frameborder='0' data-embedContent>>
    1 point
  15. Ok the new IE free version (v7) is up ..it has got the works..! Jsonpath + array add and delete , object type checking. See example file.
    1 point
  16. Tray Radio is a very nice radio and MP3 player with great potential. Everything works with an icon in your systray (icon at the bottom right next to your clock). Key features: - Easy add radio stations - Set your own favorite stations - Record Radio stations - All Radio Station are regularly checked for operation - Automatic updating of stations - Equalizer - Playback MP3, M4a, WMA and FLAC files - Jukebox option (full screen) - Multi user - Freeware - Commercial, virus, spyware and adware free! Tray Radio is for Windows Vista or above There are 3 program language: - Netherlands - English - German There are 4 radio station language: - Netherlands station - Belgium station - UK stations - Geman station Tray Radio has a minimal on interface so you won't be distracted if you listen music. Radio stations are daily tested for operation. You can download the program on (no source code available so used it or leave it) More screenshot
    1 point
  17. Try like this #Region ;************ Includes ************ #include <WinHTTP.au3> #Include <String.au3> #include <Array.au3> #include <zlib.au3> #EndRegion ;************ Includes ************ Global $sBoundary = '--' & _GenerateBoundary ( 30 ) Global $sImgurApiKey = 'f77d0b8cd41eb62792be0bf303e649df' Global $sUserAgent = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)' $sPicPath = @ScriptDir & '\large.png' $upload = _HostImGurUpload ( $sPicPath ) If Not @error Then $aLinks = _HostImGurExtractLinks ( $upload ) If Not @error Then MsgBox ( 0, "Picture Link : ", $aLinks[0] ) EndIf $upload2 = _HostImagebamUpload ( $sPicPath ) If Not @error Then $aLinks2 = _HostImagebamExtractLinks ( $upload2 ) If Not @error Then MsgBox ( 0, "Picture Link : ", $aLinks2[0] ) EndIf Func _GenerateBoundary ( $iLen ) Local $sString = '' Do Switch Random ( 1, 3, 1 ) Case 1 $sString &= Chr ( Random ( 48, 57, 1 ) ) ; 0 to 9 Case 2 $sString &= Chr ( Random ( 65, 90, 1 ) ) ; A to Z Case 3 $sString &= Chr ( Random ( 97, 122, 1 ) ) ; a to z EndSwitch Until StringLen ( $sString ) = $iLen Return $sString EndFunc ;==> _GenerateBoundary () Func _GetExtByFullPath ( $sFullPath ) Local $aFileName = StringSplit ( $sFullPath, '.' ) If Not @error Then Return $aFileName[$aFileName[0]] Return SetError ( 1 ) EndFunc ;==> _GetExtByFullPath () Func _GetFullNameByFullPath ( $sFullPath ) Local $aFileName = StringSplit ( $sFullPath, '\' ) If Not @error Then Return $aFileName[$aFileName[0]] Return SetError ( 1 ) EndFunc ;==> _GetFullNameByFullPath () Func _HostImagebamExtractLinks ( $HtmlData ) ;~ Return Links Array ;~ [0] Link only ( viewer only, not download link) ;~ [1] Thumb ;~ [2] BBCode ;~ [3] HTML $HtmlData = StringMid ( $HtmlData, StringInStr ( $HtmlData, 'dlinput_container', 0, 1 ) - StringLen ( 'dlinput_container' ) -1 ) Local $aRet = StringRegExp ( StringReplace ( $HtmlData, @LF, '' ), "(?s)(?i)dlinput_container(.*?)</div>", 3 ) If Not @error Then Local $aLinks[3], $aRet1 For $i = 0 To UBound ( $aRet ) -2 $aRet1 = StringRegExp ( $aRet[$i], "(?s)(?i)value='(.*?)>", 3 ) If Not @error Then $aRet1[0] = StringStripWS ( StringTrimRight ( $aRet1[0], 1 ), 1+2 ) $aLinks[$i] = $aRet1[0] EndIf Next _ArrayReverse ( $aLinks ) Local $sUrl = _StringBetween ( $aLinks[1], '[IMG]', '[/IMG]' ) If Not @error Then _ArrayInsert ( $aLinks, 1, $sUrl[0] ) Else Return SetError ( 2 ) EndIf If $aLinks[UBound ( $aLinks )-1] <> '' Then Return $aLinks Else Return SetError ( 3 ) EndIf Else Return SetError ( 1 ) EndIf EndFunc ;==> _HostImagebamExtractLinks () Func _HostImagebamSetDataToSend ( $sPicPath ) Local $sData = _PicReadData ( $sPicPath ) If @error Then Return SetError ( 1 ) Local $sImageName = _GetFullNameByFullPath ( $sPicPath ) If @error Or $sImageName = '' Then Return SetError ( 2 ) Local $sContentType = _PicGetContentType ( $sPicPath ) If @error Then Return SetError ( 3 ) Local $sCdfdn = 'Content-Disposition: form-data; name' Local $sCtaos = 'Content-Type: application/octet-stream' Local $sString = $sBoundary & @CRLF & _ $sCdfdn & '="file[]"; filename="' & $sImageName & '"' & @CRLF & _ $sContentType & @CRLF & @CRLF & $sData & @CRLF & $sBoundary & @CRLF For $i = 1 To 29 $sString &= $sCdfdn & '="file[]"; filename=""' & @CRLF & _ $sCtaos & @CRLF & @CRLF & @CRLF & $sBoundary & @CRLF Next $sString &= $sCdfdn & '="content_type"' & @CRLF & @CRLF & '0' & @CRLF & $sBoundary & @CRLF & _ $sCdfdn & '="thumb_size"' & @CRLF & @CRLF & '100' & @CRLF & $sBoundary & @CRLF & _ $sCdfdn & '="thumb_aspect_ratio"' & @CRLF & @CRLF & 'resize' & @CRLF & $sBoundary & @CRLF & _ $sCdfdn & '="thumb_file_type"' & @CRLF & @CRLF & 'jpg' & @CRLF & $sBoundary & '--' Return SetError ( 0, '', $sString ) EndFunc ;==> _HostImagebamSetDataToSend () Func _HostImagebamUpload ( $sPicPath ) Local $hOpen, $hConnect, $hRequest, $sHost, $sDataToSend, $sReceivedData, $iError, $sResponse, $sPostData, $sContentType $sHost = 'www.imagebam.com' $hOpen = _WinHttpOpen ( $sUserAgent ) If @error Then SetError ( 1 ) Else $hConnect = _WinHttpConnect ( $hOpen, $sHost ) If @error Then SetError ( 2 ) Else $hRequest = _WinHttpOpenRequest ( $hConnect, 'POST', '/sys/upload/save', 'HTTP/1.1' ) If @error Then SetError ( 3 ) Else _WinHttpSetTimeouts ( $hRequest, 10000, 60000, 90000, 90000 ) $sDataToSend = _HostImagebamSetDataToSend ( $sPicPath ) _WinHttpAddRequestHeaders ( $hRequest, 'Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/x-silverlight, */*' ) _WinHttpAddRequestHeaders ( $hRequest, 'Referer: http://www.imagebam.com/basic-upload' ) _WinHttpAddRequestHeaders ( $hRequest, 'Accept-Encoding: gzip, deflate' ) _WinHttpAddRequestHeaders ( $hRequest, 'Connection: Keep-Alive' ) _WinHttpAddRequestHeaders ( $hRequest, 'Cache-Control: no-cache' ) $sContentType = 'Content-Type: multipart/form-data; boundary=' & StringTrimLeft ( $sBoundary, 2 ) _WinHttpSendRequest ( $hRequest, $sContentType, $WINHTTP_NO_REQUEST_DATA, StringLen ( $sDataToSend ) ) If @error Then SetError ( 4 ) Else _PicUploadProgress ( $hRequest, $sPicPath, $sDataToSend ) If Not @error Then _WinHttpReceiveResponse ( $hRequest ) If @error Then SetError ( 5 ) Else If _WinHttpQueryDataAvailable ( $hRequest ) Then $sReceivedData = Binary ( '' ) While 1 $sReceivedData &= _WinHttpReadData ( $hRequest , 2 ) If Not @extended Then SetError ( 0 ) ExitLoop ;~ EndIf WEnd $sReceivedData = BinaryToString ( _ZLIB_GZUncompress ( $sReceivedData ) ) If StringInStr ( $sReceivedData, 'box_error' ) Then SetError ( 6 ) ; The thumbnail for the file pic.jpg could not be created. Else SetError ( 7 ) EndIf EndIf Else SetError ( 8 ) EndIf EndIf EndIf EndIf EndIf $iError = @error If $hRequest Then _WinHttpCloseHandle ( $hRequest ) If $hConnect Then _WinHttpCloseHandle ( $hConnect ) If $hOpen Then _WinHttpCloseHandle ( $hOpen ) Return SetError ( $iError, 0, $sReceivedData ) EndFunc ;==> _HostImagebamUpload () Func _HostImGurExtractLinks ( $XmlData ) Local $aImGurChars[5] = ['original', 'imgur_page', 'delete_page', 'small_square', 'large_thumbnail' ] Local $aLinks[5] For $i = 0 To UBound ( $aLinks ) -1 $aLinks[$i] = StringRegExpReplace ( $XmlData, '(?is).*<(' & $aImGurChars[$i] & ')>(.*?)</\1>.*', '\2' ) Next If $aLinks[4] <> '' Then If $aLinks[UBound ( $aLinks )-1] <> '' Then Local $sTmp = $aLinks[1] $aLinks[1] = $aLinks[3] $aLinks[3] = $sTmp $sTmp = $aLinks[4] $aLinks[4] = $aLinks[2] $aLinks[2] = $sTmp Return $aLinks Else Return SetError ( 3 ) EndIf Else Return SetError ( 1 ) EndIf EndFunc ;==> _HostImGurExtractLinks () Func _HostImGurSetDataToSend ( $sPicPath ) Local $sData = _PicReadData ( $sPicPath ) If @error Then Return SetError ( 1 ) Local $sImageName = _GetFullNameByFullPath ( $sPicPath ) If @error Or $sImageName = '' Then Return SetError ( 2 ) Local $sContentType = _PicGetContentType ( $sPicPath ) If @error Then Return SetError ( 3 ) Return SetError ( 0, '', $sBoundary & @CRLF & _ 'Content-Disposition: form-data; name="image"; filename="' & $sImageName & '"' & @CRLF & _ $sContentType & @CRLF & @CRLF & $sData & @CRLF & $sBoundary & @CRLF & _ 'Content-Disposition: form-data; name="key"' & @CRLF & @CRLF & $sImgurApiKey & @CRLF & $sBoundary ) EndFunc ;==> _HostImGurSetDataToSend () Func _HostImGurUpload ( $sPicPath ) Local $hOpen, $hConnect, $hRequest, $sHost, $sDataToSend, $sReceivedData, $iError, $sResponse, $sPostData, $sContentType $sHost = 'api.imgur.com' $hOpen = _WinHttpOpen ( $sUserAgent ) If @error Then SetError ( 1 ) Else $hConnect = _WinHttpConnect ( $hOpen, $sHost ) If @error Then SetError ( 2 ) Else $hRequest = _WinHttpOpenRequest ( $hConnect, 'POST', '/2/upload.xml', 'HTTP/1.1' ) If @error Then SetError ( 3 ) Else _WinHttpSetTimeouts ( $hRequest, 10000, 60000, 90000, 90000 ) $sDataToSend = _HostImGurSetDataToSend ( $sPicPath ) _WinHttpAddRequestHeaders ( $hRequest, 'Accept: */*' ) _WinHttpAddRequestHeaders ( $hRequest, 'Expect: 100-continue' ) $sContentType = 'Content-Type: multipart/form-data; boundary=' & StringTrimLeft ( $sBoundary, 2 ) _WinHttpSendRequest ( $hRequest, $sContentType, $WINHTTP_NO_REQUEST_DATA, StringLen ( $sDataToSend ) ) If @error Then SetError ( 4 ) Else _PicUploadProgress ( $hRequest, $sPicPath, $sDataToSend ) If Not @error Then _WinHttpReceiveResponse ( $hRequest ) If @error Then SetError ( 5 ) Else If _WinHttpQueryDataAvailable ( $hRequest ) Then $sReceivedData = '' While 1 $sReceivedData &= _WinHttpReadData ( $hRequest ) If Not @extended Then SetError ( 0 ) ExitLoop EndIf WEnd If StringInStr ( $sReceivedData, 'error' ) Then SetError ( 6 ) Else SetError ( 7 ) EndIf EndIf Else SetError ( 8 ) EndIf EndIf EndIf EndIf EndIf $iError = @error If $hRequest Then _WinHttpCloseHandle ( $hRequest ) If $hConnect Then _WinHttpCloseHandle ( $hConnect ) If $hOpen Then _WinHttpCloseHandle ( $hOpen ) Return SetError ( $iError, 0, $sReceivedData ) EndFunc ;==> _HostImGurUpload () Func _PicGetContentType ( $sPicPath ) If Not FileExists ( $sPicPath ) Then Return SetError ( -1 ) Local $sExt = _GetExtByFullPath ( $sPicPath ) If @error Or $sExt = '' Then Return SetError ( 1 ) Local $sContentType Switch $sExt Case 'jpg', 'jpe', 'jpeg' $sContentType = 'Content-Type: image/jpeg' ; ie 'Content-Type: image/pjpeg' Case 'gif' $sContentType = 'Content-Type: image/gif' Case 'bmp' $sContentType = 'Content-Type: image/bmp' Case 'png' $sContentType = 'Content-Type: image/png' ; ie Content-Type: image/x-png Case 'tif', 'tiff' $sContentType = 'Content-Type: image/tiff' Case Else Return SetError ( 2 ) EndSwitch Return $sContentType EndFunc ;==> _PicGetContentType () Func _PicReadData ( $sPicPath ) If Not FileExists ( $sPicPath ) Then Return SetError ( -1 ) Local $hFile = FileOpen ( $sPicPath ) If $hFile = -1 Then Return SetError ( 1 ) Local $sData = FileRead ( $hFile ) If @error Then Return SetError ( 2 ) FileClose ( $hFile ) Return $sData EndFunc ;==> _PicReadData () Func _PicUploadProgress ( $hRequest, $sPicPath, $sDataToSend ) If Not FileExists ( $sPicPath ) Then Return SetError ( -1 ) Local $sDatas = StringToBinary ( $sDataToSend ) Local $iNumberOfBytesToSend = 2048 Local $Bin, $iPercent, $iStart = 1, $iExtended = 0 While 1 $Bin = BinaryMid ( $sDatas, $iStart, $iNumberOfBytesToSend ) If BinaryLen ( $Bin ) = 0 Then Return _WinHTTPWriteData ( $hRequest, $Bin, 1 ) If Not @error Then $iExtended += @extended $iPercent = Round ( ( $iExtended ) / ( StringLen ( $sDataToSend ) ) * 100, 2 ) ConsoleWrite ( '-->-- [' & StringFormat ( '%03i', @ScriptLineNumber ) & '][' & @HOUR & @MIN & @SEC & '] $iPercent : ' & $iPercent & @Crlf ) If $iPercent > 97 Then $iPercent = 97 $iStart += $iNumberOfBytesToSend Else $Bin = 0 Return SetError ( 1 ) EndIf WEnd EndFunc ;==> _PicUploadProgress () You forgot to set the value of the $sBoundary variable !
    1 point
  18. DatMCEyeBall

    AutoIt Snippets

    Improved _ArrayFindAll(): #include <Array.au3> ;For _ArrayFindAll() #AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w- 7 Global $Dim = 10, $Timer, $iPercDiff Do $Dim *= 10 ; Create an array and fill it with random numbers Global $avArray[$Dim] For $x = 0 To UBound($avArray) - 1 $avArray[$x] = Random(0, 5, 1) Next ConsoleWrite("$avArray[" & UBound($avArray) & "]" & @CRLF) ; Get how long _ArrayFindAll() takes $Timer = TimerInit() Global $aiResult1 = _ArrayFindAll($avArray, 0) Global $iTimerDiff1 = TimerDiff($Timer) ConsoleWrite("_ArrayFindAll = " & Round($iTimerDiff1, 2) & " ms" & @CRLF) ; Get how long _ArrayFindAllFast() takes $Timer = TimerInit() Global $aiResult2 = _ArrayFindAllFast($avArray, 0) Global $iTimerDiff2 = TimerDiff($Timer) ConsoleWrite("_ArrayFindAllFast = " & Round($iTimerDiff2, 2) & " ms" & @CRLF) ; Display the difference in % If $iTimerDiff1 > $iTimerDiff2 Then $iPercDiff = Round(($iTimerDiff1 - $iTimerDiff2) / $iTimerDiff1 * 100, 2) & "% faster" Else $iPercDiff = Round(($iTimerDiff2 - $iTimerDiff1) / $iTimerDiff1 * 100, 2) & "% slower" EndIf ConsoleWrite("_ArrayFindAllFast() is " & $iPercDiff & " than _ArrayFindAll()" & @CRLF & @CRLF) Until $Dim = 1000000 Func _ArrayFindAllFast(Const ByRef $avArray, $vValue, $iStart = 0, $iEnd = 0, $iCase = 0, $iCompare = 0, $iForward = 1, $iSubItem = -1) If Not IsArray($avArray) Then Return SetError(1, 0, -1) If UBound($avArray, 0) > 2 Or UBound($avArray, 0) < 1 Then Return SetError(2, 0, -1) Local $iUBound = UBound($avArray) - 1 ; Bounds checking If $iEnd < 1 Or $iEnd > $iUBound Then $iEnd = $iUBound If $iStart < 0 Then $iStart = 0 If $iStart > $iEnd Then Return SetError(4, 0, -1) ; Direction (flip if $iForward = 0) Local $iStep = 1 If Not $iForward Then Local $iTmp = $iStart $iStart = $iEnd $iEnd = $iTmp $iStep = -1 EndIf ; same var Type of comparison Local $iCompType = False If $iCompare = 2 Then $iCompare = 0 $iCompType = True EndIf Local $aiFoundData ; Search Switch UBound($avArray, 0) Case 1 ; 1D array search If Not $iCompare Then If Not $iCase Then For $i = $iStart To $iEnd Step $iStep If $iCompType And VarGetType($avArray[$i]) <> VarGetType($vValue) Then ContinueLoop If $avArray[$i] = $vValue Then $aiFoundData &= "|" & $i Next Else For $i = $iStart To $iEnd Step $iStep If $iCompType And VarGetType($avArray[$i]) <> VarGetType($vValue) Then ContinueLoop If $avArray[$i] == $vValue Then $aiFoundData &= "|" & $i Next EndIf Else For $i = $iStart To $iEnd Step $iStep If StringInStr($avArray[$i], $vValue, $iCase) > 0 Then $aiFoundData &= "|" & $i Next EndIf Case 2 ; 2D array search Local $iUBoundSub = UBound($avArray, 2) - 1 If $iSubItem > $iUBoundSub Then $iSubItem = $iUBoundSub If $iSubItem < 0 Then ; will search for all Col $iSubItem = 0 Else $iUBoundSub = $iSubItem EndIf For $j = $iSubItem To $iUBoundSub If Not $iCompare Then If Not $iCase Then For $i = $iStart To $iEnd Step $iStep If $iCompType And VarGetType($avArray[$i][$j]) <> VarGetType($vValue) Then ContinueLoop If $avArray[$i][$j] = $vValue Then $aiFoundData &= "|" & $i Next Else For $i = $iStart To $iEnd Step $iStep If $iCompType And VarGetType($avArray[$i][$j]) <> VarGetType($vValue) Then ContinueLoop If $avArray[$i][$j] == $vValue Then $aiFoundData &= "|" & $i Next EndIf Else For $i = $iStart To $iEnd Step $iStep If StringInStr($avArray[$i][$j], $vValue, $iCase) > 0 Then $aiFoundData &= "|" & $i Next EndIf Next Case Else Return SetError(7, 0, -1) EndSwitch If $aiFoundData <> "" Then Return StringSplit(StringTrimLeft($aiFoundData, 1), "|", 2) Else Return SetError(6, 0, -1) EndIf EndFunc ;==>_ArrayFindAllFast
    1 point
×
×
  • Create New...