Jump to content
Sign in to follow this  

Pixelsearch not working half the time

Recommended Posts


The program I'm running is meant to scroll over an object (ego.bmp) where a box will pop up to the lower right of it, and I'm using pixelsearch to determine if there is red. It works perfectly about half the time, but the other half -- it seems to be returning @error when the pixel is there. I can simply exit the compiled exe and start it again and again until the loop works correctly. But I'm sure there's a way to avoid that!

Here is the function I'm using. The function is looped until $hungry=1:

Func IsHungry()
    $h = PixelSearch($x+100,$y+160,$x+200,$y+260,0xFF0000)
    If Not @error Then
        $hungry = 1
        $hungry = 0

Any help or ideas would be much appreciated!

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