sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #17341
Re: [Question #226074]: grabbing location details of matches out of a list
Question #226074 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/226074
Status: Open => Answered
RaiMan proposed the following answer:
>From another answer:
If you want to grab many matches of the same image at once, you have to
use findAll().
matches = findAll(Pattern("image.png").similar(0.9))
for match in matches:
click(match)
The returned matches are in arbitrary order. If you want them sorted
somehow:
matches = findAll(Pattern("image.png").similar(0.9))
sorted_matches = sorted(matches, key=lambda m:m.y)
for match in sorted_matches:
click(match)
This will go through the matches according to their y coordinate. Still
the matches having the same y value, are in arbitrary order.
in the for loop you can do what you want: e.g build your list
points = ()
for match in sorted_matches:
points.append((match.x, match.y))
or an iterator shortcut:
points = [ (m.x, m.y) for m in sorted_matches]
or just this:
matches = findAll(Pattern("image.png").similar(0.9))
points = [ (m.x, m.y) for m in sorted(matches, key=lambda m:m.y)]
now in points you have the 2-element-lists (x,y) of the top left corners
of your matches from findAll in the order of increasing y value.
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.