I'm trying to use the click function. Even though the cursor moves to the exact coordinates, it doesn't click, and the process finishes with code 0
import tkinter as tk
import pydirectinput as p
import time
coords = [0, 0]
p.FAILSAFE = False
def white_screen():
overlay = tk.Tk()
def close(event):
coords[0] = event.x
coords[1] = event.y
overlay.quit()
overlay.attributes("-fullscreen", True)
overlay.attributes("-alpha", 0.3)
overlay.configure(bg='white')
overlay.bind("<Button-1>", close)
overlay.mainloop()
white_screen()
time.sleep(1)
p.click(x=coords[0], y=coords[1],clicks = 2)
I used pyautogui first, and then I saw someone recommend pydirectinput, but that didn't work either. i also tried running the code as admin.
"Using overlay.destroy() instead of overlay.quit() fixed the problem for me, as someone mentioned in the comments.