I'm making a bot using pyautogui, at a certain point I need the function locateOnScreen to loop until it finds the desire image, searching throught internet I found this way of looping my code:
t = pyautogui.locateOnScreen("Templates.png")
while t == None:
t = pyautogui.locateOnScreen("Templates.png")
print("Templates found!")
pyautogui.click(t, clicks=2)
This method works perfectly fine, but my editor keeps warning me that a comparison to None should be if cond is None:
Example:
t = pyautogui.locateOnScreen("Templates.png")
if t is None:
t = pyautogui.locateOnScreen("Templates.png")
print("Templates found!")
pyautogui.click(t, clicks=2)
But when I use this method the loop doesn't work anymore. I want to know the differences between these two methods and If the first method I'm using is the right way to do it.