Search code examples
pythonpyautogui

How can I make an auto clicker with pyautogui only when I activate it


I have been wanting to make this for a while and have finally gotten around to it. But could not get it to work. I need it to be able to work on macOS Linux and windows, I also need it to be able to be deactivated and activated with the press of a button. This is what I have tried. ` import pyautogui import time

while True: cookie = pyautogui.locate("cookie.png") pyautogui.click("cookie.png") `


Solution

  • First, you should check if "cookie.png" looks the same in macOS, Linux and Windows. If it does not then you may need two or three different .png

    Second, the code is quite ok. If you want to stop the clicking then you can use the library keyboard (better than pyautogui for keyboard control). Then you can define the keyword to stop the clicking.