Sign in to follow this  
Followers 0
jubagreen

Help with PixelSearch

5 posts in this topic

Hey thanks for taking the time to help me....

Pretty much what i'm trying to do is get autoit to search for a pixel in a box, and if it's there press A. If it's not there, check another box and press D. Or do nothing if there's no pixel matching. This is what i've got so far..

-----------------------------------------------------------------------------------

$coord = PixelSearch( 670, 380, 685, 400, 7827804, 3 )

If @error = 1 Then

$coord = PixelSearch( 365, 365, 380, 385, 6116941, 3 )

Endif

If $coord[0] > 600 Then

Send("A")

Endif

If $coord[0] < 440 Then

Send("D")

Endif

----------------------------------------------------------------------------------

But then i get this error:

-------------------------------------------------------

If $coord[0] > 600 Then

If $coord^ ERROR

Error: Subscript used with non-Array variable.

-------------------------------------------------------

What i don't get is... how can this be a non-array variable, if it's declared with pixelsearch?

please help mee!!

Share this post


Link to post
Share on other sites



becuase if pixelsearch fails it doesn't return an array

Share this post


Link to post
Share on other sites

wow. i'm a retard. i must be tired....

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

ok i still need help, i'm getting the same error still...

------------------------------------------------------------------------------

Do

$coord = PixelSearch( 380, 430, 630, 530, 0x121611, 10, 2 )

Sleep(200)

If Not @error Then

If $coord[0] > 580 Then

Send("A")

Endif

If $coord[0] < 430 Then

Send("D")

Endif

Endif

checkfinish()

Until $finish = 1

Send("{ENTER}")

-------------------------------------------------------------------------------

so pretty much i want it to look for those pixels in those boxes, press the proper button, and do it again. if no pixel is found, do nothing and repeat. But i'm getting the same error in the same place, what i don't get is it's not even supposed to check that if the pixel isn't found!

Edited by jubagreen

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

ok i still need help, i'm getting the same error still...

Do
    $coord = PixelSearch( 380, 430, 630, 530, 0x121611, 10, 2 )
    
    Sleep(200)
    
    If Not @error Then

        If $coord[0] > 580 Then
        Send("A")
        Endif

        If $coord[0] < 430 Then
        Send("D")
        Endif
    Endif   

    checkfinish()
Until $finish = 1

Send("{ENTER}")

so pretty much i want it to look for those pixels in those boxes, press the proper button, and do it again. if no pixel is found, do nothing and repeat. But i'm getting the same error in the same place, what i don't get is it's not even supposed to check that if the pixel isn't found!

Running the Sleep() function may be resetting your @error indication (can't test right now to verify that). And you can use IsArray() to test your result, too. Try:

Do
    $coord = PixelSearch( 380, 430, 630, 530, 0x121611, 10, 2 )
    
    If IsArray($coord) And @error = 0 Then
        If $coord[0] > 580 Then
            Send("A")
        ElseIf $coord[0] < 430 Then
            Send("D")
        Endif
    Endif   

    Sleep(200)

    checkfinish()
Until $finish = 1

Send("{ENTER}")

:D

P.S. Please use code, codebox, or autoit tags on your code... :wacko:

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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