Skip to content

Instantly share code, notes, and snippets.

@makesomelayouts
Created August 1, 2023 11:00
Show Gist options
  • Select an option

  • Save makesomelayouts/aa73b54f029067e79b3bb20bdc92cf99 to your computer and use it in GitHub Desktop.

Select an option

Save makesomelayouts/aa73b54f029067e79b3bb20bdc92cf99 to your computer and use it in GitHub Desktop.
import time
import threading
from pynput.mouse import Controller, Button
from pynput.keyboard import Listener, KeyCode
toggle_key = KeyCode(char='q')
clicking = False
mouse = Controller()
def clicker():
while True:
if clicking:
mouse.click(Button.left, 1)
time.sleep(0.1)
def toggle_event(key):
if key == toggle_key:
global clicking
clicking = not clicking
def main():
clicking_thread = threading.Thread(target=clicker)
clicking_thread.start()
with Listener(on_press=toggle_event) as listener:
listener.join()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment