【发布时间】:2017-11-19 03:02:51
【问题描述】:
我的程序运行良好,使用 pyautogui.locateOnScreen 定位按钮所在的区域,然后使用 pyautogui.locateCenterOnScreen 显然带有指向正确图像的文件路径来定位按钮的中心。
不过,现在运行它会返回中心和位置的 none 值。
我已经卸载了pyautogui并重新安装它并没有修复它。
我只关注 RecordMP3 代码
这是我的代码
import pyautogui, time
def RecordMP3():
time.sleep(5)
RecordMP3 = pyautogui.locateOnScreen("D:/Programming/Python/AutoGUI/Images/SaveButton.PNG")
print(RecordMP3)
CenterRecordMP3 = pyautogui.locateCenterOnScreen("D:/Programming/Python/AutoGUI/Images/SaveButton.PNG",region = (RecordMP3))
print(CenterRecordMP3)
pyautogui.click(CenterRecordMP3)
def SaveButton():
while True:
counter = 0
SaveButton = pyautogui.locateOnScreen("D:/Programming/Python/AutoGUI/Images/SaveButton.PNG")
print("Location",SaveButton)
SaveButtonCenter = pyautogui.locateCenterOnScreen("D:/Programming/Python/AutoGUI/Images/SaveButton.PNG", region = (SaveButton))
print("Center",SaveButtonCenter,)
pyautogui.click(SaveButtonCenter)
time.sleep=(2)
counter +=1
if counter < 10:
continue
else:
break
#print("it worked!!")
RecordMP3()
这是我搜索的屏幕:
这是我要查找的按钮:
【问题讨论】:
-
当程序行为发生变化时,记下您所做的可能会影响行为变化的事情非常有帮助。在这里你只是简单地声明
"it worked before, now it doesn't",这根本没有用。你更新软件版本了吗?网站布局有变化吗?你改变文件路径了吗?提供指示发生了什么变化的信息对于正确调试是必要的。
标签: python-3.x automation pyautogui