← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #203262]: Iterating through a tree

 

Question #203262 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/203262

Dave Marsden posted a new comment:
With the help of RaiMan I have come up with some code that might help
other with a similar issue, it's not pretty and I'm sure it can be
tidied up.

item = tree.find("1342434656796.png")
x = item.x
y = item.y+2
for c in range(x, -1, -1):
    PixColour = MyRobot.getPixelColor(c,y)
#    pColour = PixColour.getRGB()
#    print c, PixColour, hex(pColour), hex(colour)
    if PixColour.getRed() == 49 and PixColour.getGreen() == 106 and PixColour.getBlue() == 197:
        MinX = c
for c in range(x, tree.w):
    PixColour = MyRobot.getPixelColor(c,y)
    if PixColour.getRed() == 49 and PixColour.getGreen() == 106 and PixColour.getBlue() == 197:
        MaxX = c
for r in range(y, -1, -1):
    PixColour = MyRobot.getPixelColor(MinX,r)
    if PixColour.getRed() == 49 and PixColour.getGreen() == 106 and PixColour.getBlue() == 197:
        MinY = r
for r in range(y, tree.h):
    PixColour = MyRobot.getPixelColor(MinX,r)
    if PixColour.getRed() == 49 and PixColour.getGreen() == 106 and PixColour.getBlue() == 197:
        MaxY = r

print MinX,MinY,MaxX,MaxY        
item = Region(MinX-5,MinY-5,5+MaxX-MinX,5+MaxY-MinY)
#item.highlight()
title = item.text()
print title

Only problem is the OCR reads "Interrogating fault memory" as
"Intcrruuatlnufault mcmurv "

I've tried various fonts with very similiar results, not sure how to
proceed from here, but OCR is stopping me here really.

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