如何解决参数2:<类"类型错误">:不知道如何转换pyautogui像素匹配方法的参数2错误?


def perfect_click(name, r, g, b):    # 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(x, y, (r, g, b), tolerance=10)
except Exception as e:
print(e)
pyautogui.click(coordinates)

上面的代码应该检查按钮是否可点击,然后通过检查像素颜色来单击它,因为不可点击的按钮通常有点沉闷,并且 PyAutogui 在屏幕上的位置在那里不起作用。 我没有给我这个错误,有人可以帮我解决这个问题吗?我真的尽力了!

argument 2: <class 'TypeError'>: Don't know how to convert parameter 2

为了解决这个问题,我只是将位置的值转换为整数:

x=location.top
x=int(x)

相关内容

最新更新