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)
I'm trying to create a function that checks for a button and waits till the button is clickable and then click it and to accomplish this I've tried to use pixel matching and unclickable buttons are just a lil lighter shade in colour.. atleast it is in my case and locate on screen dosen't detect it.
here is the error:
pixelMatchesColor() missing 1 required positional argument: 'expectedRGBColor'
I know what your reaction will be "well its as its says its missing 'expectedRGBColor'"
But the thing is it's not getting outta loop even after the button matches. I tried playing with tolerance it's not working either.
I ran the program to print coordinates but it's not printing x and y coordinates only in this function, works just fine in other function where it's just looping till it finds the image and clicks it. It's not giving an error for missing coordinates
can anyone please please help me with this?