fRequEnCy Posted July 26, 2010 Share Posted July 26, 2010 I'm sorry for such a silly question but I'm stuck and finally broke down to post in the forums. I have an 1-dimensional array as follows: [0]| [1]|1 [2]|1 [3]|1 [4]|2 [5]|4 [6]|6 [7]|12 [8]|13 [9]|16 [10]|17 [11]|33 [12]|34 [13]|44 [14]|51 [15]|52 [16]|54 [17]|57 [18]|58 [19]|60 [20]|77 [21]|78 [22]|83 [23]|88 [24]|89 [25]|94 [26]|97 [27]|98 [28]|99 [29]|102 [30]|103 What I'm wanting is only the match with more than 1 result listed in the array. Wanted results: [0]| [1]|1 [2]|1 [3]|1 What is the best/fastest solution to remove all non duplicates? I've toyed with _ArrayDelete in a For Next loop but I always run into problems with exceeding the dimension range when comparing the index with the next among other issues. Any suggestions? Please help with any direction. Link to comment Share on other sites More sharing options...
MvGulik Posted July 26, 2010 Share Posted July 26, 2010 (edited) One 'general' way would be to create a new array2 from your initial data array1 that contains a count for all different values (per value), and use that array (if array2[entry][count] > 1) to do your thing. [entry]|(value)|(count) [0]|-|- [1]|1|3 [2]|2|1 ... Edited July 26, 2010 by MvGulik "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... Link to comment Share on other sites More sharing options...
fRequEnCy Posted July 26, 2010 Author Share Posted July 26, 2010 One 'general' way would be to create a new array2 from your initial data array1 that contains a count for all different values (per value), and use that array (if array2[entry][count] > 1) to do your thing. [entry]|(value)|(count) [0]|-|- [1]|1|3 [2]|2|1 ... Seems like the right idea but how would I go about creating the count in code? Link to comment Share on other sites More sharing options...
Spiff59 Posted July 26, 2010 Share Posted July 26, 2010 (edited) Something like this might work for you: #include <Array.au3> Global $aArray[15] = [0,1,2,2,2,3,5,8,9,9,13,15,22,22,23] _Discard_Singletons($aArray) _ArrayDisplay($aArray) Func _Discard_Singletons(ByRef $aTemp) Local $i = 0, $dupe = False While 1 If $aTemp[$i] = $aTemp[$i + 1] Then $dupe = True $i += 1 Else If $dupe = False Then _ArrayDelete($aTemp, $i) Else $i += 1 $dupe = False EndIf EndIf If $i = (UBound($aTemp) - 1) Then ExitLoop WEnd If $dupe = False Then _ArrayDelete($aTemp, $i) EndFunc Edit: This does assume the input array is already sorted (as per your example) Edited July 26, 2010 by Spiff59 Link to comment Share on other sites More sharing options...
ShawnW Posted July 26, 2010 Share Posted July 26, 2010 (edited) I've toyed with _ArrayDelete in a For Next loop but I always run into problems with exceeding the dimension range when comparing the index with the next among other issues. Any suggestions? The ending condition on For loops is not re-evaluated each iterations. Example. For $i = 0 To UBound($array) Just because the result of UBound gets smaller from _ArrayDelete calls, that doesn't mean the for loop is going to care. This works though and uses _ArrayFindAll(). Basically if ArrayFindAll returns more than 1 result then it's a duplicate, if not then the element is deleted. #include <Array.au3> Local $array[10] = [3,2,0,0,0,3,4,1,9,1] $i = 0 While $i <= UBound($array) - 1 $matches = _ArrayFindAll($array,$array[$i]) If UBound($matches) = 1 Then _ArrayDelete($array,$i) Else $i += 1 EndIf WEnd _ArrayDisplay($array) Edited July 26, 2010 by ShawnW Link to comment Share on other sites More sharing options...
MasonMill Posted July 26, 2010 Share Posted July 26, 2010 Can the same thing be done with an array of arrays? Link to comment Share on other sites More sharing options...
MasonMill Posted July 26, 2010 Share Posted July 26, 2010 I have an array of 200 different arrays of RGB values every .5 seconds and want to see if they changed over time. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 26, 2010 Moderators Share Posted July 26, 2010 MasonMill,As I got you to where you are now, best I jump in! You cannot do any sort of comparison between your screendump arrays-within-an-array in the same way as for the elements of an array of simple variables.As I mentioned in the other thread, to access your arrays you have to extract them from the holding array into a temp array - and then there is no way to make a direct comparison between arrays as with variables. However, if you are looking for changes between screenshots, have you thought of using PixelCheckSum? It is designed to get you a simple numeric value for a screen area. Then you need only save your screenshot array if it has changed - and you do no longer need to weed out duplicates. Give it a shot and start a new thread if you have problems. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
MasonMill Posted July 26, 2010 Share Posted July 26, 2010 You always find me! lol. The problem i see with pixelcheck sum is that its either changed or not changed. I'm trying to figure out a way to set a threshold but as of so far it cant be done. What prompted me to the whole topic was a thread in example scripts section where a script was made to find a BMP withing another BMP. I wanted to taek it a step forward and give it a threshold as well, but it seems that that is out of reach. Here is the script: Image Search expandcollapse popupOpt('MustDeclareVars', 1) ;#include <GUIConstants.au3> #include <GDIPlus.au3> #Include <ScreenCapture.au3> #Include<ImageSearch functions.au3> ;~ Constants for type of picture matching const $c24RGBFullMatch=1 ;Load as 24 bits and full match const $c24RGBPartialMatch=2 ;Load as 24 bits and partial match const $c16RGBFullMatch=3 ;Load as 16 bits and full match const $c16RGBPartialMatch=4 ;Load as 16 bits and partial match ; ** Example start ** ; Screen samples Global Const $Bitmap1Filename = @TempDir & "\FULLSCREEN.bmp" Global Const $Bitmap2Filename = @TempDir & "\CALCULATOR.bmp" Global Const $Bitmap3Filename = @TempDir & "\BACKSPACE.bmp" ;BMP samples Global Const $Bitmap4Filename = @TempDir & "\7WDS_BW.bmp" Global Const $Bitmap5Filename = @TempDir & "\SEVEN_BW.bmp" Global Const $Bitmap6Filename = @TempDir & "\CAT_BW.bmp" Global Const $Bitmap7Filename = @TempDir & "\AUTOIT3.bmp";Make sure the homepage of autoit with 3 is visible local $calcHWND, $begin, $pos, $aWinPos, $aWinCSize, $start local $pBitmap, $BitmapData, $pixelFormat Opt("WinTitleMatchMode", 4);Matching windows by advanced options ; Initialize GDI+ library _GDIPlus_Startup () ;Calculator, make sure its started $calcHWND = WinGetHandle("[CLASS:SciCalc]") if $calchwnd = "" Then run("calc.exe") sleep(2000) $calcHWND = WinGetHandle("[CLASS:SciCalc]") EndIf ;Capture the calculator screen $begin = TimerInit() winactivate($calcHWND) _ScreenCapture_CaptureWnd($Bitmap2Filename, $calcHWND,0,0,-1,-1,False) ConsoleWrite("Saving calculator window " & TimerDiff($begin) & " milliseconds " & @LF) winmove("[ACTIVE]","",223,341) ;Capture an area within the calculator area backspace $begin = TimerInit() $pos=controlgetpos("","","[CLASS:Button; INSTANCE:2]") $aWinPos = WinGetPos($calchWnd) $aWinCSize = WinGetClientSize($calchWnd) ;Q&D calculation of offsets to capture _ScreenCapture_Capture($Bitmap3Filename, ($aWinPos[0]+$pos[0]) + ($aWinPos[2] - $aWinCSize[0])-3, ($awinpos[1]+$pos[1])+ ($aWinPos[3]-$aWinCSize[1])-3, $aWinPos[0]+$pos[0]+$pos[2]+3, ($awinpos[1]+$pos[1])+ ($aWinPos[3]-$aWinCSize[1])+$pos[3]-3,false) ConsoleWrite("Saving backspacebutton " & TimerDiff($begin) & " milliseconds " & @LF) ; Capture full screen $begin = TimerInit() _ScreenCapture_Capture($Bitmap1Filename,0,0,-1,-1,False) ConsoleWrite("Saving full screen took " & TimerDiff($begin) & " milliseconds " & @LF) func filegetname($f) local $i $i=stringinstr($f,"\",false,-1) if $i > 0 Then return stringmid($f,$i+1) Else return $f EndIf EndFunc ;Do the actual find Func FindTester($BMP1, $BMP2, $Bool) local $tResult $start = TimerInit() $tResult=findBMP($BMP1,$BMP2, $Bool) ConsoleWrite($tResult & " " & FileGetName($BMP2) & " in " & FileGetName($BMP1) & " ** matchtype " & $Bool & " time elapsed: " & TimerDiff($start) & " milliseconds" & @LF) EndFunc ; Not very usefull to find full screen and tricky as screen is most likely changed (clock, output from application etc.) ; findTester("SCREEN",$Bitmap1Filename,TRUE);Find the full screen itself ; findTester($Bitmap1Filename,$Bitmap1Filename,$c24RGBFullMatch);Find the full screen itself 31 seconds findTester($Bitmap1Filename,$Bitmap1Filename,$c24RGBPartialMatch);Find the full screen itself 2.8529088255245 seconds ; findTester($Bitmap1Filename,$Bitmap1Filename,$c16RGBFullMatch);Find the full screen itself 21 seconds findTester($Bitmap1Filename,$Bitmap1Filename,$c16RGBPartialMatch);Find the full screen itself 1 seconds ; Be aware that overlapping windows, moving things on screen can make it difficult to find on full screen findTester("SCREEN",$Bitmap2Filename,$c24RGBFullMatch);Find the full calculatorscreen findTester("SCREEN",$Bitmap2Filename,$c24RGBPArtialMatch);Find the full calculatorscreen with partial match findTester("SCREEN",$Bitmap2Filename,$c16RGBFullMatch);Find the full calculatorscreen findTester("SCREEN",$Bitmap2Filename,$c16RGBPArtialMatch);Find the full calculatorscreen with partial match findTester($Bitmap1Filename,$Bitmap2Filename,$c16RGBFullMatch);Find the full calculatorscreen findTester($Bitmap1Filename,$Bitmap2Filename,$c16RGBPartialMatch);Find the full calculatorscreen with partial match findTester($Bitmap2Filename,$Bitmap3Filename,$c24RGBFullMatch);Find the backspace button findTester($Bitmap2Filename,$Bitmap3Filename,$c24RGBPartialMatch);Find the backspace button with partial match findTester($Bitmap2Filename,$Bitmap3Filename,$c16RGBFullMatch);Find the backspace button findTester($Bitmap2Filename,$Bitmap3Filename,$c16RGBPartialMatch);Find the backspace button with partial match winactivate($calcHWND);Make sure calculator is active on the screen findTester("[ACTIVE]",$Bitmap3Filename,$c24RGBFullMatch);Find the backspace button findTester("[ACTIVE]",$Bitmap3Filename,$c24RGBPartialMatch);Find the backspace button with partial match findTester("[ACTIVE]",$Bitmap3Filename,$c16RGBFullMatch);Find the backspace button on active screen findTester("[ACTIVE]",$Bitmap3Filename,$c16RGBPartialMatch);Find the backspace button with partial match findTester("SCREEN",$Bitmap3Filename,$c24RGBFullMatch);Find the backspace button findTester("SCREEN",$Bitmap3Filename,$c24RGBPartialMatch);Find the backspace button with partial match findTester("SCREEN",$Bitmap3Filename,$c16RGBFullMatch);Find the backspace button findTester("SCREEN",$Bitmap3Filename,$c16RGBPartialMatch);Find the backspace button with partial match findTester($Bitmap4Filename,$Bitmap5Filename,$c16RGBFullMatch);Find the seven findTester($Bitmap4Filename,$Bitmap5Filename,$c16RGBPartialMatch);Find the seven with partial match findTester($Bitmap4Filename,$Bitmap6Filename,$c16RGBFullMatch);Find the cat findTester($Bitmap4Filename,$Bitmap6Filename,$c16RGBPartialMatch);Find the cat with partial match findTester($Bitmap1Filename,$Bitmap7Filename,$c24RGBFullMatch);Find the 3 of Autoit Homepage findTester($Bitmap1Filename,$Bitmap7Filename,$c24RGBPartialMatch);Find the 3 of Autoit Homepage findTester($Bitmap1Filename,$Bitmap7Filename,$c16RGBFullMatch);Find the 3 of Autoit Homepage findTester($Bitmap1Filename,$Bitmap7Filename,$c16RGBPartialMatch);Find the 3 of Autoit Homepage _GDIPlus_Shutdown() ;** Example end ** Image Search functions expandcollapse popup;=============================================================================== ; Function Name: findBMP ; Description: Finds a bitmap (.BMP) in another BMP file (other formats BMP, GIF, JPEG, PNG, TIFF, Exif, WMF, and EMF should work but not tested) ; Syntax: findBMP($BMP1, $BMP2, $MatchType=TRUE) ; ; Parameter(s): $BMP1 = Filename of bitmap to search in ; $BMP2 = Filename of bitmap to search for ; $MatchType = c24RGBFullMatch, c24RGBPartialMatch, c16RGBFullMatch, c16RGBPartialMatch ; ; Return Value(s): On Success: = Returns Array List ; On Failure: = @error 1 (Control was found but there was an error with the DLLCall) ; ; Author(s): JunkEW ; ; Note(s): ; * Its never an exact match even with TRUE as last few bits are disposed in algorithm and lines below ; are not checked under assumption that those are 99.99% of the time correct ; * locking bits overview http://www.bobpowell.net/lockingbits.htm ; ToDo: ; * Transparency (when search letters on a different background) http://www.winprog.org/tutorial/transparency.html ; * Match quicker by doing a bitblt with srcinvert when first line is found (instead of checking line by line) ; * $BMP1 and $BMP2 to be HBITMAP handle as input instead of filenames (will make searching within partial screen easier) ; Example(s): ; ;=============================================================================== Func findBMP($BMP1, $BMP2, $MatchType=$c24RGBFullMatch) Dim $fLine[1];Line number of found line(s), redimmed when second picture size is known Dim $BMP1Data="", $BMP1Width=0, $BMP1Height=0, $BMP1LineWidth=0; Dim $BMP2Data="", $BMP2Width=0, $BMP2Height=0, $BMP2LineWidth=0 Dim $foundAt = "", $matchPossible=FALSE, $matchedLines=0, $foundAtLeft=-1, $foundAtTop=-1 Dim $bestMatchLine=-1, $HighestMatchingLines=-1; For knowing when no match is found where best area is Dim $iPos=1; dim $imgBytes; local $iFuzzyDist, $searchFor, $iAbove, $bMatchPossible, $aboveLine local $j, $imgBits if ($MatchType=$c24RGBFullMatch) or ($matchtype=$c24RGBPartialMatch) then $imgBytes=3 Else $imgBytes=2 endif ; Load the bitmap to search in getImage($BMP1, $BMP1Data, $BMP1Width, $BMP1Height, $BMP1LineWidth, $imgBytes) $BMP1Data = BinaryToString($BMP1Data) ; Load the bitmap to find getImage($BMP2, $BMP2Data, $BMP2Width, $BMP2Height, $BMP2LineWidth, $imgBytes) ;Make it strings to be able to use string functions for searching $BMP2Data = BinaryToString($BMP2Data) ;For reference of line where in BMP2FindIn a line of BMP2Find was found If $BMP2Height = 0 Then SetError(1,0,0) Return False EndIf ReDim $fline[$BMP2Height] ;If exact match check every 1 line else do it more fuzzy (as most likely other lines are unique) if ($MatchType=$c24RGBFullMatch) or ($matchtype=$c16RGBFullMatch) Then $iFuzzyDist = 1 Else ;Check fuzzy every 10% of lines $iFuzzyDist = ceiling(($bmp2height * 0.1)) endIf $begin = TimerInit() ;Look for each line of the bitmap if it exists in the bitmap to find in For $i = 0 To $BMP2Height - 1 ;Minus imgbytes as last bits are padded with unpredictable bytes (24 bits image assumption) or 2 when 16 bits $searchFor = StringMid($BMP2Data, 1 + ($i * $BMP2lineWidth), ($BMP2lineWidth - $imgBytes)) $iPos = StringInStr($BMP1Data, $searchFor, 2, 1, $iPos) ; $iPos = StringInStr($BMP1Data, $searchFor) ;Look for all lines above if there is also a match ;Not doing it for the lines below as speed is more important and risk of mismatch on lines below is small $iAbove=1 if $iPos > 0 then $bMatchPossible=True $matchedLines=1;As first found line is matched we start counting ;Location of the match $foundAtTop = Int($iPos / $BMP1lineWidth) -$i $foundAtLeft = int(mod($iPos,$bmp1linewidth) / $imgBytes) Else $bMatchPossible=false exitloop endif while (($i+$iAbove) <= ($BMP2Height -1)) and ($bMatchPossible=True) $searchFor = StringMid($BMP2Data, 1 + (($i + $iAbove) * $BMP2lineWidth), ($BMP2lineWidth - $imgBytes)) $aboveLine = stringmid($BMP1Data,$iPos + ($iAbove * $BMP1LineWidth), ($BMP2LineWidth - $imgBytes)) if $aboveLine <> $searchFor Then $bMatchPossible=False ;To remember the area with the best match if $matchedLines >= $HighestMatchingLines Then $HighestMatchingLines = $matchedLines ;Best guess of location ;~ $foundAtTop = $fline[$i] + $i - $BMP2Height $foundAtTop = Int($iPos / $BMP1lineWidth);+ $i - $BMP2Height $bestMatchLine = Int($iPos / $BMP1lineWidth) EndIf ExitLoop EndIf $matchedLines=$matchedLines + 1 $iAbove=$iAbove+$iFuzzyDist WEnd ;If bMatchPossible is still true most likely we have found the bitmap if $bmatchPossible = True then ;~ ConsoleWrite("Could match top: " & $foundAtTop & " left: " & $foundAtLeft & " in " & TimerDiff($begin) / 1000 & " seconds" & @LF) ; MouseMove($foundatleft,$foundatTop) exitloop else ;~ consolewrite("i not matched " & $ipos & " " & $matchedlines & @crlf ) EndIf Next ;For some debugging of time ; if $bMatchPossible = True Then ; ConsoleWrite("Searching took " & TimerDiff($begin) / 1000 & " seconds " & @LF) ; Else ; ConsoleWrite("NOT FOUND Searching took " & TimerDiff($begin) / 1000 & " seconds" & @LF) ; endif ;Return an error if not found else return an array with all information if $bMatchPossible = False Then SetError(1, 0, 0) endif ; return stringsplit($bMatchPossible & ";" & $matchedLines & ";" & $foundAtLeft & ";" & $foundAtTop & ";" & $bmp2width & ";" & $BMP2Height & ";" & $HighestMatchingLines & ";" & $bestMatchLine,";") return $bMatchPossible & ";" & $matchedLines & ";" & $foundAtLeft & ";" & $foundAtTop & ";" & $bmp2width & ";" & $BMP2Height & ";" & $HighestMatchingLines & ";" & $bestMatchLine EndFunc;==>findBMP Func GetImage($BMPFile, byref $BMPDataStart, byref $Width, byRef $Height, byref $Stride, $imgBytes=3) local $Scan0, $pixelData, $hbScreen, $pBitmap, $pBitmapCap, $handle ; Load the bitmap to search in If $BMPFile="SCREEN" Then $hbScreen=_ScreenCapture_Capture("",0,0,-1,-1,False) $pBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hbScreen); returns memory bitmap Else ;try to get a handle $handle = WinGetHandle($BMPFile) If @error Then ;Assume its an unknown handle so correct filename should be given $pBitmap = _GDIPlus_BitmapCreateFromFile($BMPFile) Else $hbScreen=_ScreenCapture_CaptureWnd("",$handle,0,0,-1,-1,False) $pBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hbScreen); returns memory bitmap EndIf EndIf ;Get $tagGDIPBITMAPDATA structure ;~ ConsoleWrite("Bitmap Width: " & _GDIPlus_ImageGetWidth($pBitmap) & @CRLF ) ;~ ConsoleWrite("Bitmap Height: " & _GDIPlus_ImageGetHeight($pBitmap) & @CRLF) ;~ 24 bits (3 bytes) or 16 bits (2 bytes) comparison if ($imgBytes=2) then $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF16RGB555) Else $BitmapData= _GDIPlus_BitmapLockBits($pBitmap, 0, 0, _GDIPlus_ImageGetWidth($pBitmap), _GDIPlus_ImageGetHeight($pBitmap), $GDIP_ILMREAD, $GDIP_PXF24RGB) endIf If @ERROR Then MsgBox(0,"","Error locking region " & @error) $Stride = DllStructGetData($BitmapData, "Stride");Stride - Offset, in bytes, between consecutive scan lines of the bitmap. If the stride is positive, the bitmap is top-down. If the stride is negative, the bitmap is bottom-up. $Width = DllStructGetData($BitmapData, "Width");Image width - Number of pixels in one scan line of the bitmap. $Height = DllStructGetData($BitmapData, "Height");Image height - Number of scan lines in the bitmap. $PixelFormat = DllStructGetData($BitmapData, "PixelFormat");Pixel format - Integer that specifies the pixel format of the bitmap $Scan0 = DllStructGetData($BitmapData, "Scan0");Scan0 - Pointer to the first (index 0) scan line of the bitmap. $pixelData = DllStructCreate("ubyte lData[" & (abs($Stride) * $Height-1) & "]", $Scan0) $BMPDataStart = $BMPDataStart & DllStructGetData($pixeldata,"lData") _GDIPlus_BitmapUnlockBits($pBitmap, $BitmapData) _GDIPlus_ImageDispose ($pBitmap) _WinAPI_DeleteObject ($pBitmap) EndFunc;==>GetImage Link to comment Share on other sites More sharing options...
MasonMill Posted July 26, 2010 Share Posted July 26, 2010 @ Melba23, so instead of an array of arrays could i just have a bunch of free standing arrays then start comparing them to each other? Like say if array1[1, 1] <> array2[1,1] then @error or something? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 26, 2010 Moderators Share Posted July 26, 2010 (edited) MasonMill, I wanted to taek it a step forward and give it a threshold as wellAnd the very best of luck with that! I think that the main problem would be AutoIt's speed (or lack of it!). The computational burden to make the threshold calculations on any image approaching a reasonable size would be enormous - which means the framerate would have to be veeeeeeery slow. This is something I wrote a while ago to determine the average colour of a display - but as you can see, it was not fast enough for the person who wanted it. I cannot see your project being any faster - although I would be delighted if you proved me wrong! M23 Edit: Our posts crossed. You can of course compare arrays in that way - and you can still store them in a big array. You just have to extract the 2 arrays before starting the compare. But just in that one line (array1[1, 1] <> array2[1,1] then @error) you can see how intensive the calculations would be for an image of a reasonable size. Edited July 26, 2010 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
MasonMill Posted July 26, 2010 Share Posted July 26, 2010 Oh yeah, no doubt it takes a long time. For a full screen capture it takes like 15 seconds to put the BMP into an array using a for loop. I use MATLAB for moment tensor inversions in Geophysics and i wonder if transfer times would bog it down as well. MATLAB crunches matrices lickity split fast. Link to comment Share on other sites More sharing options...
MasonMill Posted July 26, 2010 Share Posted July 26, 2010 Melba, i wonder if for finding certain images on a screen that might be a little different color, instead of looking for threshold changes for each pixel you could use your script to look for average colors. You would know the size of the object to look for so you could scan the screen with a designated size looking for average RGB values. Would that bog autoit down as well? Link to comment Share on other sites More sharing options...
Spiff59 Posted July 26, 2010 Share Posted July 26, 2010 (edited) The OP did mention wanting the "fastest", modifying post #4, this is the best I can offer: #include <Array.au3> Global $aArray[15] = [0,1,2,2,2,3,5,8,9,9,13,15,22,22,23] _Discard_Singletons($aArray) _ArrayDisplay($aArray) Func _Discard_Singletons(ByRef $aTemp) Local $i = 0, $max = UBound($aTemp) - 1, $dupe = False While $i < $max If $aTemp[$i] = $aTemp[$i + 1] Then ; current element matches next element - keep it $dupe = True $i += 1 Else If $dupe = False Then ; current element is unmatched - trash it $max -= 1 For $j = $i To $max ; shift remaining elements to left $aTemp[$j] = $aTemp[$j + 1] Next Else ; current element matches prior element - keep it $dupe = False $i += 1 EndIf EndIf WEnd If $dupe = False Then $max -= 1 ; if last element was unmatched - trash it ReDim $aTemp[$max + 1] ; truncate array EndFunc Edit: added some comments Edited July 27, 2010 by Spiff59 Link to comment Share on other sites More sharing options...
fRequEnCy Posted July 27, 2010 Author Share Posted July 27, 2010 (edited) I come home from work and have lots of toys to try. Whoohoooo. LOL. Thank you soooooo much! After looking at the code, I can see where I went wrong. And yet so simple. I appreciate all the responses. Was just expecting an idea but got some code (better yet a function. LOL.) to play with. Now I can move forward. The results are fast with Spiff59's code and haven't tried ShawnW's code yet but will try as well. Theses posts are exactly what I was looking for and didn't get hassled about search which I did. Was trying to break down the reverse option of removing duplicates and was having mixed results. Again thanks and will post again with results. Also thanks to Melba23 who had always been helpful to me in the past and for commenting in the thread. Also thanks to MvGulik for being the first to respond and giving me some direction. Edited July 27, 2010 by fRequEnCy Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 27, 2010 Moderators Share Posted July 27, 2010 MasonMill, look for average colors.[...] Would that bog autoit down as well?I have no idea - a lot depends on the size of the area to be scanned. Why not try and see! We are hijacking fRequEnCy's topic here - if you have any further questions please start a new topic. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now