Steve H
Steve H

Reputation: 83

In Sikuli, How to find and click a minimum of 3 identical images?

I'm trying to click no less than 3 of the same image, but with findAll() I am having difficulty with sikuli wanting to select only 1 image when I don't want it to select any if there is not 3 or more.

if exists(Pattern("1474201252795.png").similar(0.95)):
    wait(1)
    for x in findAll(Pattern("1474201252795.png").similar(0.95)):
        click(x)

Upvotes: 1

Views: 988

Answers (1)

Eugene S
Eugene S

Reputation: 6910

So just count the images first and check if the count is higher than 3.

imageCount=0

images = []

# find all images and store them in a list to prevent additional search
for image in findAll("Win7StartBtn.png"):
    images.append(image)

#check list length and act accordingly
if len(images) >= 3:
    for image in images:
        image.click()

Upvotes: 2

Related Questions