Search code examples
pythonpyautoguiappjar

Why is my autoclicker in python not working?


I'm still a newbie, don't be angry if I make some mistakes :) So, I wanted to code an auto clicker with a little interface, where I can enter the size of the interval between each click. Here's the code:

import pyautogui
import appJar

pyautogui.PAUSE = 0.01


def buttonPress(button):
    if (button == "Go"):
        amount = float(app.getEntry("amount"))
        button = app.radioButton("click")
        if (button == "Right Click"):
            button = "right"
        else:
            button = "left"
        
        pyautogui.click(button=button, interval=amount)


app = appJar.gui("autoclicker")
app.setSize("300x200")
app.setSticky("new")
app.addLabel("Enter size of Intervall between clicks", row=0)
app.addEntry("amount", row=1)
app.addButton("Go", buttonPress, row=3)
app.setSticky("e")
app.radioButton("click", "Right Click", row=2)
app.setSticky("w")
app.radioButton("click", "Left Click", row=2)

app.go()

When I run it, the little window opens, I enter the interval, and press "Go". Nothing happens. What did I do wrong?


Solution

  • There isn't anything wrong with your code but you probably didn't notice anything happening because there wasn't anything in particular to notice. Try doing this:

    1. The value you input in time interval is the time the auto clicker pauses before clicking anything so set it to something like 2 sec.

    2. Choose left click and click go

    3. Now within 2 sec move your mouse cursor to an app on your desktop and now that app will be selected after 2 sec