[Python] Creating a basic auto clicker in python

Discussão em 'Python' iniciado por Stack, Abril 25, 2025.

  1. Stack

    Stack Membro Participativo

    I want to create a pretty simple automatic-clicker that will take the position of your mouse, and clicks in that position as long as "active" is true and at "input" 's speed (clicks per second)

    I have seen this code floating around, but it does not suit my needs

    import win32api, win32con
    def click(x,y):
    win32api.SetCursorPos((x,y))
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
    click(10,10)


    I would like the code to look something like this,

    import library

    input = 5 ## in clicks per second

    if (some key) is held:
    active = True

    if (some key) is released:
    active = False


    while active:
    *gets position of mouse*
    *clicks at that position at input's speed (5)


    It would also be nice if there was an option to click in the very center of the screen.

    Continue reading...

Compartilhe esta Página