Multiple Similar Images

Hello, guys i have similar images on the screen, how can i acess each?
I tried by setting a location for look with x, y, width and length but i keep getting this error:

IndexError: index 560 is out of bounds for axis 0 with size 354

Is there any other way? Best regards

Hi cso.rodrigo, how’s going?

You can use the method find_multiple which find multiple elements, and return a dictionary with the label and coordinates of each one, like this:

# List with the elements label
elements_to_find = ["ele1", "ele2", "ele3", "ele4"]

# Searching for all elements will return a dictionary with the label and coordinates of each one
elements = bot.find_multiple(labels=elements_to_find, matching=0.97, waiting_time=20000)

print(elements)

Or, if the elements are the same, you can use the approach of using the method find_all which will return a list of the images found, being able to access the coordinates, like this:

# Searching for all "element" occurrences
elements = bot.find_all(label="element", matching=0.97, waiting_time=20000)

for ele in elements:
   print(ele) # Printing element coordinates
   bot.mouse_move(ele.left, ele.top)
   bot.click()

Thank you! It worked, thank you for fast reply
Best regards

1 Like