#!/usr/bin/env python3 import time import random from pynput.mouse import Listener from pynput.keyboard import Controller kbd = Controller() def down(key): kbd.press(key) def up(key): kbd.release(key) go = False offtime = 0 def on_click(x, y, b, p): global go print(x, y, b, p) go = p listener = Listener(on_click=on_click) listener.start() actuallygo = True while True: if go: actuallygo = True offtime = time.time() if not actuallygo: continue if time.time() > offtime + 0.5 + (random.randint(1, 10) / 10): actuallygo = False if random.randint(0, 1) == 1: key = 'a' else: key = 'd' down(key) time.sleep(random.randint(1, 10) / 40 + 0.01) up(key) #time.sleep(random.randint(1, 10) / 20 + 0.1)