Sign in to follow this  
Followers 0
seandisanti

_PixelSearchX

14 posts in this topic

#1 ·  Posted (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 by cameronsdad

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites



Very nice, but where do I input the color to search for?

Share this post


Link to post
Share on other sites

That's the ColorArray parameter. Read his notes.

Share this post


Link to post
Share on other sites

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...


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

I still don't quite understand. Can you give me an example?

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

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.")

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#10 ·  Posted

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]

Share this post


Link to post
Share on other sites

#11 ·  Posted

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).

Share this post


Link to post
Share on other sites

#12 ·  Posted

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]

Share this post


Link to post
Share on other sites

#13 ·  Posted

yeah but I think that atleast pixelsearch shoul have that option or atleast a function called pixelfindnext, what do u think

I think you should request it in the Idea forum if it's something you'd like to see implemented into AutoIt.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

--Edit--

Nvm

Edited by =sinister=

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0