Search code examples
pythonpyautogui

accessing elements of locateall pyautogui


I don't understand why I am getting these results. I'm trying to access the coordinates of objects I find with pyautogui. here's my code:

import pyautogui
test = pyautogui.locateAllOnScreen('radiobutton.png', grayscale=True, region=(855,550, 30, 400))
print(test)
print(list(test))
print("length of list:",len(list(test)))
for item in test:
    print("looped")
[x[0] for x in list(test)]

and the output I receive from this code:

<generator object _locateAll_python at 0x000000000B7A8888>
[(859, 551, 24, 24), (859, 580, 24, 24), (859, 609, 24, 24), (859, 638, 24, 24)]
length of list: 0

I would like to be able to access the numbers specifically, for example: 859 or 551.

What do I do?


Solution

  • must be in line for some reason.

    radios = list(pyautogui.locateAllOnScreen('radiobutton.png', grayscale=True, region=(855,475, 30, 400)))