Skip to content

Instantly share code, notes, and snippets.

@FoxNeo
Created June 8, 2023 17:37
Show Gist options
  • Save FoxNeo/de6c2705c77d7b9aa42aebe67ec0f3d7 to your computer and use it in GitHub Desktop.
Save FoxNeo/de6c2705c77d7b9aa42aebe67ec0f3d7 to your computer and use it in GitHub Desktop.
To click automaticaly on web pages
import time
import threading
import sys
from pynput.mouse import Controller, Button
from pynput.keyboard import Listener, KeyCode
TOOGLE_KEY = KeyCode(char="t")
EXIT_KEY = KeyCode(char="q")
clicking = False
INTERVAL_IN_SECONDS = 1
mouse = Controller()
def clicker():
while True:
if clicking:
mouse.click(Button.left, 1)
time.sleep(INTERVAL_IN_SECONDS)
def toggle_event(key):
if key == TOOGLE_KEY:
global clicking
clicking = not clicking
if key == EXIT_KEY:
print("good bye!")
sys.exit()
click_thread = threading.Thread(target=clicker)
click_thread.start()
with Listener(on_press=toggle_event) as listener:
listener.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment