Jump to content

Compairing PixelGetColor using If will only detect black or not black


Zachlr
 Share

Recommended Posts

I am trying to make a simple bot that beeps when a certain pixel changes color, such as watching a health bar to alert you when it is low. So far my code looks like this:

$pos = MouseGetPos()

$desired_color = PixelGetColor($pos[0], $pos[1])

ToolTip("Watching: "& $pos[0] & $pos[1], $pos[0], $pos[1], "Information", 1, 1)

Sleep(5000)

ToolTip("For the color: "& $desired_color, $pos[0], $pos[1], "Information", 1, 1)

Sleep(5000)

ToolTip("", $pos[0], $pos[1], "", 0, 1)

While 1

$actual_color = PixelGetColor($pos[0], $pos[1])

If Not $actual_color = $desired_color Then

Beep(400, 500)

EndIf

ToolTip("Color: "& $actual_color, $pos[0], $pos[1], "Information", 1, 1) ;(line 13) this line was added only to make sure the color value did in fact change

Sleep(50)

Wend

What I can conclude is that it will only compare black vs not black. So say I put my cursor on a white explorer window, if I move the window so that the watched pixel is at a yellow icon, it will not beep. However, when I slide a black icon under the watched pixel, it will beep. It seems as though 0 is the only value not equal to any other color value, but I know it isn't by using line 13 of my script. I guess I could use pixel checksum, but I'd rather not unless I have to. And because as far as I can tell, there is no reason why this should not be working.

I'm rather new to AutoIt3 scripting, so it could easily be something obvious.

Thanks,

Zach

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...