I'm create a project in Python using PyAutogui and I need to locate an object on the screen. First of all I crop a screenshot, and after that, I use pyautogui.locateOnScreen('element.png')
for found the location. The problem is, the element sometimes is resized so this method can't found it. I tried use confidence
but not work properly with that. How can i locate that element using pyautogui or something different?
This is my code:
png = ["Andrew","David","Emma","Jay","Jesse","Josh","Mickey"]
screen = pyautogui.screenshot(region=(x+1,y+1,1281,751))
for element in png:
if(pyautogui.locateOnScreen(element + '.png',confidence=0.7) != None):
print("Find " + element)