【发布时间】:2020-01-03 18:38:29
【问题描述】:
def perfect_click(name): # Performs a click after checking for loaded image
location = None
image_file = name
while location is None:
try:
location = pyautogui.locateOnScreen(image_file)
except Exception as e:
print(e)
coordinates = pyautogui.center(location)
x, y = coordinates
print(coordinates)
pixel = False
while pixel is False:
try:
pixel = pyautogui.pixelMatchesColor(coordinates, (241, 63, 83), tolerance=10)
except Exception as e:
print(e)
pyautogui.click(coordinates)
我正在尝试创建一个函数来检查按钮并等待按钮可单击然后单击它并完成此操作我尝试使用像素匹配并且不可单击的按钮只是颜色较浅的阴影.. 至少在我的情况下,在屏幕上定位并没有检测到它。
这是错误:
pixelMatchesColor() missing 1 required positional argument: 'expectedRGBColor'
我知道你的反应会是什么“正如它所说的那样 它缺少 'expectedRGBColor'"
但问题是即使在按钮匹配后它也不会退出循环。 我尝试过容忍它也不起作用。
我运行程序来打印坐标,但它不是只在这个函数中打印 x 和 y 坐标,在其他函数中工作得很好,它只是循环直到找到图像并单击它。 缺少坐标不会出错
谁能帮我解决这个问题?
【问题讨论】:
标签: python python-3.x colors pyautogui pixelmatch