Jump to content

Having a PixelSearch Issue


Recommended Posts

Func getcircs()
While 1
$getcircs1 = PixelSearch(19 + $Winpos[0], 86 + $Winpos[1], 250 + $Winpos[0], 372 + $Winpos[1], 0xFCE874)
If @error = Not 1 Then
    PixelSearch($getcircs1[0] - 10, $getcircs1[1] - 20, $getcircs1[0], $getcircs1[1], 0xCCFF4F4)
    If @error = Not 1 Then
    Sleep(400)
    MouseClick("right", $getcircs1[0], $getcircs1[1])
    Sleep(400)
    EndIf
EndIf

$getcoro1 = PixelSearch(19 + $Winpos[0], 86 + $Winpos[1], 250 + $Winpos[0], 372 + $Winpos[1], 0x8C4040)
If @error = 1 Then
    ExitLoop
Else
    PixelSearch($getcoro1[0] + 5, $getcoro1[1] +5 , $getcoro1[0] + 15, $getcoro1[1] -5, 0xCCFF4F4)
        If @error = Not 1 Then
            Sleep(400)
            MouseClick("right", $getcoro1[0], $getcoro1[1])
            Sleep(400)
        EndIf
EndIf
Send("{ESC}")
openup()
WEnd
EndFunc

What I want it to do...

Search for a color and if it doesn't find it search for another color and if both fail then go to another function.

If it finds the first color I want it to search a small area around where it found that color for another color and click the area if successful. Go to the next search if not.

Occasionally an error will pop up that says $getcoro1 or $getcirc1 aren't arrays. This seems odd to me because I don't think it will do the second search if the first one fails.

Link to comment
Share on other sites

Func getcircs()
While 1
$getcircs1 = PixelSearch(19 + $Winpos[0], 86 + $Winpos[1], 250 + $Winpos[0], 372 + $Winpos[1], 0xFCE874)
If @error = Not 1 Then
    PixelSearch($getcircs1[0] - 10, $getcircs1[1] - 20, $getcircs1[0], $getcircs1[1], 0xCCFF4F4)
    If @error = Not 1 Then
    Sleep(400)
    MouseClick("right", $getcircs1[0], $getcircs1[1])
    Sleep(400)
    EndIf
EndIf

$getcoro1 = PixelSearch(19 + $Winpos[0], 86 + $Winpos[1], 250 + $Winpos[0], 372 + $Winpos[1], 0x8C4040)
If @error = 1 Then
    ExitLoop
Else
    PixelSearch($getcoro1[0] + 5, $getcoro1[1] +5 , $getcoro1[0] + 15, $getcoro1[1] -5, 0xCCFF4F4)
        If @error = Not 1 Then
            Sleep(400)
            MouseClick("right", $getcoro1[0], $getcoro1[1])
            Sleep(400)
        EndIf
EndIf
Send("{ESC}")
openup()
WEnd
EndFunc

What I want it to do...

Search for a color and if it doesn't find it search for another color and if both fail then go to another function.

If it finds the first color I want it to search a small area around where it found that color for another color and click the area if successful. Go to the next search if not.

Occasionally an error will pop up that says $getcoro1 or $getcirc1 aren't arrays. This seems odd to me because I don't think it will do the second search if the first one fails.

I've had a similar seeminly randon problem similar to this

Solved by declaring my variables as local first

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

My concern is that it never seems to exit the loop and I don't know why. It doesn't ever leave that while loop.

I do apologise, I misread your post as having a problem with array errors popping up.

I dont see why you even need that loop to be honest.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

I do apologise, I misread your post as having a problem with array errors popping up.

I dont see why you even need that loop to be honest.

Because it's looking for more than one thing. It needs to click every match it finds until pixelsearch returns an error then go do something else.

Link to comment
Share on other sites

Because it's looking for more than one thing. It needs to click every match it finds until pixelsearch returns an error then go do something else.

I think I finally see what's wrong.

If it finds the first color and not the second it just keeps finding that same color over and over and won't leave the loop.

Does anyone have any ideas on how to exclude an area already searched?

Link to comment
Share on other sites

I'm going to bump this because I still haven't found a solution to my problem.

How does PixelSearch actually perform it's search? My guess is left to right and top to bottom until it finds a match?

The need for a secondary search is because I expect the same color pixel to appear in places I have no interest in. So what I want to do is search an area for a pixel and once found, search an area close to where the first match was found for another pixel. If both match do something and if there is no match then continue searching the first larger area excluding the area already searched until it finishing looking or finds a match.

Let me know if there is any confusion with my explanation and thanks ahead of time.

I tried _ImageSearch but I get DLL errors?

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...