← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #680893]: find image and type pattern

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
this would be my solution (not tested ;-)

patterns = [Pattern("up.png").similar(0.85),Pattern("down.png").similar(0.85),Pattern("left.png").similar(0.85),Pattern("right.png").similar(0.85),Pattern("j.png").similar(0.85),Pattern("k.png").similar(0.85)]
start = Pattern("start.png").similar(0.90)
mm = []
iconsFound = []

def findAllIcons(pattern): 
   try:
       icons = findAll(pattern)
       while icons.hasNext(): # loop as long there is a first and more matches
           iconsFound.append(icons.next())
       icons.destroy()
   except FindFailed:
       pass # we miss it
    
while exists(start):#This is the main loop of the application. 
   for pattern in patterns:
       findAllIcons(pattern)
   iconsFound.sort(key = lambda match: match.x)
   message = ""
   for match in iconsFound:
       message += os.path.basename(match.getImageFilename()).replace(".png", "")
   print message
   mm = []
   all_icons = []

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.