sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #51726
Re: [Question #680893]: find image and type pattern
Question #680893 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/680893
Status: Answered => Open
ben is still having a problem:
starttime = time.time()
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)
aRegion = Region(600,600,800,300)
iconsFound = []
def findAllIcons(pattern):
try:
icons = aRegion.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
def typePattern():
iconsFound.sort(key = lambda match: match.x)
for p in iconsFound:
check = os.path.basename(p.getImageFilename()).replace(".png", "")
if(check == "up"):
type(Key.UP)
if(check == "down"):
type(Key.DOWN)
if(check == "left"):
type(Key.LEFT)
if(check == "right"):
type(Key.RIGHT)
if(check == "j"):
type('j')
if(check == "k"):
type('k')
while True:
if exists(start):#This is the main loop of the application.
for pattern in patterns:
findAllIcons(pattern)
typePattern()
iconsFound = []
print "Elapsed: %d seconds"%(int(time.time()-starttime))
wait(1)
Thanks for your help.
I have complete my code, but i am finding way to optimize it
it take about 27 sec to complete for a single pattern for example down arrow.
can it shorten to less than 4 sec?
--
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.