Created
June 8, 2023 17:37
-
-
Save FoxNeo/de6c2705c77d7b9aa42aebe67ec0f3d7 to your computer and use it in GitHub Desktop.
To click automaticaly on web pages
This file contains hidden or 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 | |
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