Jump to content

Odd PixelSearch Behavior


inter
 Share

Recommended Posts

I've just recently begun using Auto It for automation and have run into a strange problem with PixelSearch that I can't seem to figure out.

I'm trying to navigate through my cable box menus as can be seen in my example image.

My approach has been simple, PixelSearch on the left side of the menu listing for the yellow color when a menu is highlighted. Starting at menu 1, it this color is found I send a keystroke to navigate right to menu 2, if the color isn't found I send a keystroke down and then left to navigate to menu 3. This works for me until I reach menu 7 and then the MenuRight function is repeated so that menus 8 and 10 are never highlighted. Once it reaches the next page the script continues to work correctly again until it reaches menu 7 and the process repeats itself.

Am I doing something incorrectly or is there another approach I can take to achieve what I want? Thanks in advance for any help provided.

While 1
    $coord = PixelSearch( 108, 261, 361, 428, 0xBBCC7E, 20 )
    If @error = 0 Then
        MenuLeft()
        Sleep (3000)
    ElseIf @error = 1 Then
        MenuRight()
        Sleep (3000)
    EndIf
WEnd

Func MenuLeft()
    Send("{Right}")
EndFunc

Func MenuRight()
    Send("{Down}")
    Sleep (1500)
    Send("{Left}")
EndFunc
Link to comment
Share on other sites

The most obvious reason would be that your pixelsearch coordinates are incorrect.

Possibly because you've used the pixel coordinates relative to the control, rather than absolute screen coordinate.

Double check those coordinates, if you can't find an error in them, just set the bottom coordinate much higher and test again.

If that gets it working you can schrink the search area to the smallest size as possible for performance. (1 pixel wide should be enough)

Link to comment
Share on other sites

Assuming your co-ordiates are correct, there are more colours in that yellow area than the one you are looking for.

So perhaps you should lower the step of the pixels you are skipping.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Possibly because you've used the pixel coordinates relative to the control, rather than absolute screen coordinate.

It seems that this was the problem (though I swore I checked and double checked) and after fixing the coordinates things appear to be working. Many thanks! :graduated: Edited by inter
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...