you store pyautogui.locateOnScreen('image.png', confidence = 0.6)
in the variable location
. Then you check the condition (if
/else
). But then you never recheck for pyautogui.locateOnScreen('image.png', confidence = 0.6)
. I am still not sure what you are trying to achieve here, but at least the check needs to go into the while
:
while 1:
location = pyautogui.locateOnScreen('image.png', confidence = 0.6)
if location:
print("I found it ")
time.sleep(2)
print(pyautogui.moveTo(location))
else:
print("I am unable to find it")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…