Jump to content
Sign in to follow this  
hrabikk

PixelSearch problem

Recommended Posts

Hello, what should i change in this code to make it work?

$firstpixel=PixelSearch(100,100,100,200,0xFFFFFF,0,0)
       If Not @error Then
        $secondpixel=PixelSearch(200,$firstpixel[1]200,$firstpixel[1],0xFFFFFF,0,0)
           If Not @error Then
             MsgBox(0, "X and Y are:", $pixel1[0] & "," & $pixel1[1])
       EndIf
    EndIf

I want the 2nd pixelsearch starts from the firstpixel[1] Y array but it keeps getting errors that firstpixel[1] is used without being declared or smthing like that.

Share this post


Link to post
Share on other sites

The error is more likely to be that $pixel1 is being used without being declared, and that would be because you are trying to use it, without declaring it.

Meaning there is no such variable.

Share this post


Link to post
Share on other sites

$firstpixel=PixelSearch(237,553,237,700,0xFEFEFE,0,0)
   If Not @error Then
      sleep(50)
      $2ndpixel=PixelSearch($firstpixel[0]+2,$firstpixel[1]-5,$firstpixel[0]+2,$firstpixel[1]+5,0xFFFFFF,0,0)
      If Not @error Then
      ToolTip("X and Y are:", $2ndpixel[0] & "," & $2ndpixel[1],0,0)
   EndIf
EndIf

And now error:

Subscript used with non-Array variable.:

ToolTip("X and Y are:", $2ndpixel[0] & "," & $2ndpixel[1],0,0)

ToolTip("X and Y are:", $2ndpixel^ ERROR

>Exit code: 1    Time: 4.119

So where is the mistake this time?

Share this post


Link to post
Share on other sites

$firstpixel=PixelSearch(237,553,237,700,0xFEFEFE,0,0)
   If Not @error Then
      sleep(50)
      $2ndpixel=PixelSearch($firstpixel[0]+2,$firstpixel[1]-5,$firstpixel[0]+2,$firstpixel[1]+5,0xFFFFFF,0,0)
      If Not @error Then
      ToolTip("X and Y are:", $2ndpixel[0] & "," & $2ndpixel[1],0,0)
   EndIf
EndIf

And now error:

Subscript used with non-Array variable.:

ToolTip("X and Y are:", $2ndpixel[0] & "," & $2ndpixel[1],0,0)

ToolTip("X and Y are:", $2ndpixel^ ERROR

>Exit code: 1    Time: 4.119

So where is the mistake this time?

Check the PixelSearch details in the helpfile, esspecially the part that talks about when the Function fails to find the pixel.

The example shows what to do to test for this.

Jos

Edited by Jos

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  

×
×
  • Create New...