sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #11218
Re: [Question #200617]: Get pixel color in region and compare to Color
Question #200617 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/200617
Status: Open => Answered
j proposed the following answer:
aColor = Color(0x6969FF)
Here you are creating an Object of the class Color.
myRobot.getPixelColor(p.x, p.y)
Here you are creating another Object of the class Color (I guess).
if myRobot.getPixelColor(p.x, p.y) == aColor:
Here you are comparing the objects and since they are not the same object (do not have the same memory address) the comparison will always fail.
In Python and Java you can only compare primitive datatypes with == to
check if they have the same value. Not primitive objects like Color are
normally compared by their address in memory if no special behaviour is
implemented. I do not know the Color-class but I guess they cannot be
compared like this. If this is the case, you have to get the raw color
value as a float or string from the two color objects and then you can
compare them like you did.
If I'm wrong and the Color class does indeed implement the ==
functionality, I don't know why your code does not work, sorry.
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.