Last active
April 2, 2024 12:53
-
-
Save starch0/6af9d4461928fa700f5c81c0bca80f09 to your computer and use it in GitHub Desktop.
auto clicker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pynput.mouse import Button, Controller | |
from pynput.keyboard import Key, Listener | |
import threading | |
import time | |
mouse = Controller() | |
clicking = False | |
def on_press(key): | |
global clicking | |
if key.char == 'k': | |
clicking = True | |
threading.Thread(target=auto_click).start() | |
def on_release(key): | |
global clicking | |
if key == Key.esc: | |
clicking = False | |
return False | |
def auto_click(): | |
while clicking: | |
mouse.click(Button.left, 1) | |
time.sleep(0.1) | |
def start_listener(): | |
with Listener(on_press=on_press, on_release=on_release) as listener: | |
listener.join() | |
if __name__ == "__main__": | |
start_listener() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment