how to do 1 scan and then click on multiple targets of the same image (about 100)?

Asked by JD

Hi guys,
I have just started to figure out sikuli and have come across something I can't figure out.

Im trying to 'scan' a region and with one single scan pick up on about 100 of my target images and then I would like to click on each one of these 100 targets one after the other with no repeats.

I have played around with the match similarity settings and the number of samples and have managed to pick all my targets up, however the code that I wrote seems to 'scan' after everytime it clicks on one rather than to click on all of them after the single initial scan.
Any suggestions and tips are very appreciated.

here is my snippet of the related example code:

while exists (Pattern("Image 1").similar(0.55)):

    if exists (Pattern("Image 1").similar(0.55)):
       click (getLastMatch())

Looking forward to working some more with Sikuli

thank you very much

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
JD
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

If you want to grab many matches of the same image at once, you have to use findAll().

matches = findAll(Pattern("Image 1").similar(0.55))
for match in matches:
    click(match)

The returned matches are in arbitrary order. If you want them sorted somehow:

matches = findAll(Pattern("Image 1").similar(0.55))
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.

One more thing: Pattern().similar(0.55)
the lower the similarity value, the higher the risk of getting false positives. A good match has a score above 0.8 or even 0.9, which depends on how much background is in the screenshot. A good screenshot has as little background as possible and concentrates on the key aspects.

more information in the docs: http://doc.sikuli.org

Revision history for this message
JD (keelbo) said :
#2

Thank you very much, that has done the trick. ;-)