我正在尝试在屏幕上找到图像,如果不存在,则单击按钮。这是我一直在尝试的代码:
Ex 1:
if pyautogui.locateOnScreen\
(['C:\\Users\\Me\\Desktop\\Prog\\File\\pictures\\x.png']) is None:
pyautogui.press('f6')
else:
pass
练习2:
while pyautogui.locateOnScreen(['C:\\Users\\Me\\Desktop\\Prog\\File\\pictures\\x.png']) is None:
pyautogui.press('f6')
# I don't understand why I would use this but I talked to a friend and he believed it may work better.
据我所知,问题是由于locateOnScreen函数没有真正返回None,但我想不出任何其他选项。任何帮助表示赞赏。谢谢