seandisanti Posted January 10, 2006 Share Posted January 10, 2006 (edited) there were a couple of topics on this in the last few days,seemed a simple udf might be in order... ;This is a UDF to perform a pixelsearch for multiple colors. ;pass a 1 based array (with element 0 being a count of colors) of colors, function returns a 2 dimensional array, with coords for each found color. ;each color not found will have coordinates -1,-1. if no colors found, @error is set to 1 Func _PixelSearchX($left, $top, $right, $bottom, $ColorArray, $ShadeVar = 0, $step = 1) If Not IsArray($ColorArray) Then Return (PixelSearch($left, $top, $right, $bottom, $ColorArray, $ShadeVar, $step)) Dim $ToBeReturned[$ColorArray[0]][2] $ToBeReturned[0][0] = $ColorArray[0] $x = 1 Local $tmp[2] $found = 0 While $x <= $ColorArray[0] $tmp = PixelSearch($left, $top, $right, $bottom, $ColorArray[$x], $ShadeVar, $step) If Not @error Then $ToBeReturned[$x][0] = $tmp[0] $ToBeReturned[$x][1] = $tmp[1] $found = 1 Else $ToBeReturned[$x][0] = -1 $ToBeReturned[$x][1] = -1 EndIf $x = $x + 1 WEnd If Not $found Then SetError(1) Else Return ($ToBeReturned) EndIf EndFunc ;==>_PixelSearchX Edited January 10, 2006 by cameronsdad Link to comment Share on other sites More sharing options...
=sinister= Posted February 5, 2006 Share Posted February 5, 2006 Very nice, but where do I input the color to search for? Link to comment Share on other sites More sharing options...
greenmachine Posted February 5, 2006 Share Posted February 5, 2006 That's the ColorArray parameter. Read his notes. Link to comment Share on other sites More sharing options...
seandisanti Posted February 7, 2006 Author Share Posted February 7, 2006 Very nice, but where do I input the color to search for?That's the ColorArray parameter. Read his notes.Glad you like it, and thanks for answering, green, i don't get to this forum enough... Link to comment Share on other sites More sharing options...
=sinister= Posted April 29, 2006 Share Posted April 29, 2006 I still don't quite understand. Can you give me an example? Link to comment Share on other sites More sharing options...
ConsultingJoe Posted April 30, 2006 Share Posted April 30, 2006 this seems very useful but can you explain a little more [center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center] Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted April 30, 2006 Moderators Share Posted April 30, 2006 I still don't quite understand. Can you give me an example?This is what I had in mind, but it throws errors. #include <Array.au3> $NumColors = 3 $Color_1 = 21989 $Color_2 = 15526360 $Color_3 = 13421772 $Color_Array = _ArrayCreate($NumColors, $Color_1, $Color_2, $Color_3) $ReturnArray = _PixelSearchX(1, 1, (@DesktopWidth-1), (@DesktopHeight-1), $Color_Array) _ArrayDisplay($ReturnArray, "This is your pixelsearch array.") Link to comment Share on other sites More sharing options...
ConsultingJoe Posted April 30, 2006 Share Posted April 30, 2006 This is what I had in mind, but it throws errors. #include <Array.au3> $NumColors = 3 $Color_1 = 21989 $Color_2 = 15526360 $Color_3 = 13421772 $Color_Array = _ArrayCreate($NumColors, $Color_1, $Color_2, $Color_3) $ReturnArray = _PixelSearchX(1, 1, (@DesktopWidth-1), (@DesktopHeight-1), $Color_Array) _ArrayDisplay($ReturnArray, "This is your pixelsearch array.")thats exactly what i tried but it showed 2 numbers [center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center] Link to comment Share on other sites More sharing options...
greenmachine Posted May 1, 2006 Share Posted May 1, 2006 Here, try this: #include <Array.au3> $NumColors = 3 $Color_1 = 21989 $Color_2 = 15526360 $Color_3 = 13421772 $Color_Array = _ArrayCreate($NumColors, $Color_1, $Color_2, $Color_3) $ReturnArray = _PixelSearchX(1, 1, (@DesktopWidth-1), (@DesktopHeight-1), $Color_Array) $msg = "" For $i = 1 To $ReturnArray[0][0] $msg &= $ReturnArray[$i][0] & ", " & $ReturnArray[$i][1] & @CRLF Next MsgBox (0, $ReturnArray[0][0] & " colors seached, " & $ReturnArray[0][1] & " colors found", $msg) Func _PixelSearchX($left, $top, $right, $bottom, $ColorArray, $ShadeVar = 0, $step = 1) If Not IsArray($ColorArray) Then Return (PixelSearch($left, $top, $right, $bottom, $ColorArray, $ShadeVar, $step)) Dim $ToBeReturned[$ColorArray[0]+1][2] = [[$ColorArray[0], 0]] Local $tmp[2] For $x = 1 To $ColorArray[0] $tmp = PixelSearch($left, $top, $right, $bottom, $ColorArray[$x], $ShadeVar, $step) If Not @error Then $ToBeReturned[$x][0] = $tmp[0] $ToBeReturned[$x][1] = $tmp[1] $ToBeReturned[0][1] += 1 Else $ToBeReturned[$x][0] = -1 $ToBeReturned[$x][1] = -1 EndIf Next If ($ToBeReturned[0][1] = 0) Then SetError(1) Return $ToBeReturned EndFunc;==>_PixelSearchX Requires beta for += and &=, but that can be changed if required. Link to comment Share on other sites More sharing options...
ConsultingJoe Posted May 1, 2006 Share Posted May 1, 2006 Here, try this: #include <Array.au3> $NumColors = 3 $Color_1 = 21989 $Color_2 = 15526360 $Color_3 = 13421772 $Color_Array = _ArrayCreate($NumColors, $Color_1, $Color_2, $Color_3) $ReturnArray = _PixelSearchX(1, 1, (@DesktopWidth-1), (@DesktopHeight-1), $Color_Array) $msg = "" For $i = 1 To $ReturnArray[0][0] $msg &= $ReturnArray[$i][0] & ", " & $ReturnArray[$i][1] & @CRLF Next MsgBox (0, $ReturnArray[0][0] & " colors seached, " & $ReturnArray[0][1] & " colors found", $msg) Func _PixelSearchX($left, $top, $right, $bottom, $ColorArray, $ShadeVar = 0, $step = 1) If Not IsArray($ColorArray) Then Return (PixelSearch($left, $top, $right, $bottom, $ColorArray, $ShadeVar, $step)) Dim $ToBeReturned[$ColorArray[0]+1][2] = [[$ColorArray[0], 0]] Local $tmp[2] For $x = 1 To $ColorArray[0] $tmp = PixelSearch($left, $top, $right, $bottom, $ColorArray[$x], $ShadeVar, $step) If Not @error Then $ToBeReturned[$x][0] = $tmp[0] $ToBeReturned[$x][1] = $tmp[1] $ToBeReturned[0][1] += 1 Else $ToBeReturned[$x][0] = -1 $ToBeReturned[$x][1] = -1 EndIf Next If ($ToBeReturned[0][1] = 0) Then SetError(1) Return $ToBeReturned EndFunc;==>_PixelSearchX Requires beta for += and &=, but that can be changed if required.That works great, thanks. What about multiple occourences??? [center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center] Link to comment Share on other sites More sharing options...
greenmachine Posted May 1, 2006 Share Posted May 1, 2006 That works great, thanks.What about multiple occourences???Multiple occurrences, like more than one pixel of a certain search color? PixelSearch only returns the first match, so unless an option is added to PixelSearch that returns all matches (which, by the way, would really slow down the function), I don't see that as an option for this. It could be done I suppose, but it would be a very difficult task (at least the way I imagine it). Link to comment Share on other sites More sharing options...
ConsultingJoe Posted May 1, 2006 Share Posted May 1, 2006 Multiple occurrences, like more than one pixel of a certain search color? PixelSearch only returns the first match, so unless an option is added to PixelSearch that returns all matches (which, by the way, would really slow down the function), I don't see that as an option for this. It could be done I suppose, but it would be a very difficult task (at least the way I imagine it).yeah but I think that atleast pixelsearch shoul have that option or atleast a function called pixelfindnext, what do u think [center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center] Link to comment Share on other sites More sharing options...
greenmachine Posted May 1, 2006 Share Posted May 1, 2006 yeah but I think that atleast pixelsearch shoul have that option or atleast a function called pixelfindnext, what do u thinkI think you should request it in the Idea forum if it's something you'd like to see implemented into AutoIt. Link to comment Share on other sites More sharing options...
=sinister= Posted March 25, 2007 Share Posted March 25, 2007 (edited) --Edit-- Nvm Edited March 26, 2007 by =sinister= 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