Search code examples
pythonautomationjythonsikuli

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)

Solution

  • 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()