dimanche 20 novembre 2016

IfEqual always evaluating to False (AutoHotKeys)

I have two methods which I'm using to get and compare two colors. The first is to get the color

/*
This function returns the color at the given coordinates in hexadecimal format 
*/
GetColor(x, y) {
    MouseMove x, y
    PixelGetColor, colorToReturn, x, y
    Return %colorToReturn%
}

And here is my check color method

/*
This function checks the passed color with the color at 600, 475.
*/
CheckColor(colorToCheck) {
    colorToCompare := GetColor(600, 475)
    MsgBox %colorToCheck% - %colorToCompare%
    IfEqual %colorToCheck%, %colorToCompare%, Return, 1
    Return 0
}

I call it with this hotkey but I always get 0 back even though the two colors are the same color.

^t:: ; CTRL + T test color compare
colorToTest := GetColor(600, 475)
result := CheckColor(colorToTest)
MsgBox %result%
RETURN

Why does my check color always return false?

Aucun commentaire:

Enregistrer un commentaire