Sign in to follow this  
Followers 0
cpil

Pixelsearch not working half the time

2 posts in this topic

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()
    _ImageSearch("Ego.bmp",1,$x,$y,60)
    MouseMove($x,$y,1)
    Sleep(1000)
    $h = PixelSearch($x+100,$y+160,$x+200,$y+260,0xFF0000)
    If Not @error Then
        $hungry = 1
    Else
        $hungry = 0
        MouseMove($x,$y+100,1)
        Sleep(60000)
    EndIf
EndFunc

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  
Followers 0