Clicking after Region.findAny?

Asked by Jasper on 2020-12-26

So as the title says, I am trying to click after a Region.findAny but alas I cannot get it to work.
I've read a bit of the documentation and https://answers.launchpad.net/sikuli/+faq/1483 which didn't help me unfortunately, so if anyone can help me with this simple issue it'd be much appreciated!

Here is my part of the code I'm struggling with:
while True:

   if region1.exists(img1,0): - waiting for an image to appear before searching for other 3 images that are on screen already, but change colors at times.
            region2.findAny(img1,img2,img3)
            click(region2.getLastMatches())
I've tried other methods to get this to work as well but to no luck - the only way I can have this work right now by using a or statement region.2click(img1) or region2.click(img2) ect ect. Which is slower and not preferable. I'd also like to note that I can get sikuli to click after findAny, but it won't actually click on the images of course.

tl;dr I think I'm not properly using the getlastmatches() and I do not know how to implement that into the click function.

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2020-12-26
Last reply:
2020-12-27
masuo (masuo-ohara) said : #1

You can understand your issue when you confirm return value of getLastMatch.

[example1:]
r = Region(0,0,400,400)
r.find("1609040733533.png")
print r.getLastMatch()
r.click()

[example2:]
r = Region(0,0,400,400)
mlist = r.findAny("1609040733533.png","1609040739663.png","1609040747454.png")
print mlist
print r.getLastMatch()
for m in mlist:
  m.click()

Can you help with this problem?

Provide an answer of your own, or ask Jasper for more information if necessary.

To post a message you must log in.