Last active
May 12, 2020 11:59
-
-
Save Pro496951/567339a35050fc079c31b868b04c82a2 to your computer and use it in GitHub Desktop.
This is an Auto Clicker Created Using Python.Don't Forget To Star this Gist And Follow Me This is My First Ever program in Python. But It will take an synatx error.To Fix it go here : https://nitratine.net/blog/post/how-to-setup-pythons-pip/
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
import time | |
import threading | |
from pynput.mouse import Button, Controller | |
from pynput.keyboard import Listener, KeyCode | |
delay = 0.001 | |
button = Button.left | |
start_stop_key = KeyCode(char='s') | |
exit_key = KeyCode(char='e') | |
class ClickMouse(threading.Thread): | |
def __init__(self, delay, button): | |
super(ClickMouse, self).__init__() | |
self.delay = delay | |
self.button = button | |
self.running = False | |
self.program_running = True | |
def start_clicking(self): | |
self.running = True | |
def stop_clicking(self): | |
self.running = False | |
def exit(self): | |
self.stop_clicking() | |
self.program_running = False | |
def run(self): | |
while self.program_running: | |
while self.running: | |
mouse.click(self.button) | |
time.sleep(self.delay) | |
time.sleep(0.1) | |
mouse = Controller() | |
click_thread = ClickMouse(delay, button) | |
click_thread.start() | |
def on_press(key): | |
if key == start_stop_key: | |
if click_thread.running: | |
click_thread.stop_clicking() | |
else: | |
click_thread.start_clicking() | |
elif key == exit_key: | |
click_thread.exit() | |
listener.stop() | |
with Listener(on_press=on_press) as listener: | |
listener.join() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment