Sign in to follow this  
Followers 0
Seppai

Need help with an multiple pixel search function!

2 posts in this topic

Hi I've only been using autoit for around 2 days now and I am trying to figure out why this segment I am trying to right isn't working as intended.

Global $coord1 = 482
Global $coord2 = 496






;lc($coord1, $coord2)
Global $val1 = False
WhileDem($val, 699, 676, 708, 688)


func PST($a, $b, $c, $d)
    PixelSearch($a, $b, $c, $d, 0x4E614E)
    PixelSearch($a, $b, $c, $d, 0x7F1A0C)
    PixelSearch($a, $b, $c, $d, 0x540C6C)
    PixelSearch($a, $b, $c, $d, 0xC4BDBB)
    PixelSearch($a, $b, $c, $d, 0x109416)
    PixelSearch($a, $b, $c, $d, 0x10169C)
EndFunc

func WhileDem($fillvar, $PSTfill1, $PSTfill2, $PSTfill3, $PSTfill4)
    While(not($fillvar))
    PST($PSTfill1, $PSTfill2, $PSTfill3, $PSTfill4)
    if NOT(@error) Then
        lc($coord1, $coord2)
        $fillvar = True
    EndIf
WEnd
EndFunc

func lc($x, $y)
    MouseClick("left", $x, $y, 1, 10)
EndFunc

I think the problem lies in the PST(). I'm guessing it has something to do with it not being able to use the @error correctly because it is embedded in a different function?

The outcome is it is just following out the MouseClick even if there is no pixel present in the area.

Share this post


Link to post
Share on other sites



found the solution if this helps anyone here you go

each pixelsearch has to be follow by an if statement and from what i see it has to be contained in one function.

Global $coord1 = 482
Global $coord2 = 496






;lc($coord1, $coord2)
Global $inv1_full = False

WhileDem($inv1_full, 690, 672, 710, 692)



func WhileDem($fillvar, $PSTfill1, $PSTfill2, $PSTfill3, $PSTfill4)
    While(not($fillvar))
        PixelSearch($PSTfill1, $PSTfill2, $PSTfill3, $PSTfill4, 0x4E614E)
        if NOT(@error) Then
            lc($coord1, $coord2)
            $fillvar = True
        EndIf
        PixelSearch($PSTfill1, $PSTfill2, $PSTfill3, $PSTfill4, 0x7F1A0C)
        if NOT(@error) Then
            lc($coord1, $coord2)
            $fillvar = True
        EndIf
        PixelSearch($PSTfill1, $PSTfill2, $PSTfill3, $PSTfill4, 0x540C6C)
        if NOT(@error) Then
            lc($coord1, $coord2)
            $fillvar = True
        EndIf
        PixelSearch($PSTfill1, $PSTfill2, $PSTfill3, $PSTfill4, 0xC4BDBB)
        if NOT(@error) Then
            lc($coord1, $coord2)
            $fillvar = True
        EndIf
        PixelSearch($PSTfill1, $PSTfill2, $PSTfill3, $PSTfill4, 0x109416)
        if NOT(@error) Then
            lc($coord1, $coord2)
            $fillvar = True
        EndIf
        PixelSearch($PSTfill1, $PSTfill2, $PSTfill3, $PSTfill4, 0x10169C)
        if NOT(@error) Then
            lc($coord1, $coord2)
            $fillvar = True
        EndIf
    WEnd
EndFunc

 

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