← Back to team overview

sikuli-driver team mailing list archive

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: Answered => Open

HjalmarSn is still having a problem:
Tried string-comparison instead, but the whole script freezes if this
code is enabled.. Is there a better way to loop through a region's
pixels and compare them to a color? This is what my codes looks like
now:


def findItemsOfColor():
    area = Region(playground.x + 75,playground.y + 90,600,400)
    area.highlight(1)
    wait(1)
    x = area.x
    y = area.y
    i=0 
    while i==0:
        x = x+1
        p = Location(x,y)
        aColor = Color(0x6969FF)
        bColor = myRobot.getPixelColor(p.x, p.y)
        if bColor.toString() == aColor.toString():
            print "FOUND ITEM!!!"
            click(x+4,y+4)
            wait(1)
        if x > area.x + area.w:
            x = area.x
            y = y + 1
            if y > area.y + area.h:
                i = 1
                break

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.