-
Notifications
You must be signed in to change notification settings - Fork 1.4k
macro recorder python #953
Copy link
Copy link
Open
Description
from pynput import keyboard, mouse
import time
events = []
def on_key_press(key):
events.append(("key", key, time.time()))
def on_click(x, y, button, pressed):
if pressed:
events.append(("mouse", (x, y, button), time.time()))
RECORD
print("Yozib olinmoqda... (5 sekund)")
with keyboard.Listener(on_press=on_key_press) as kl,
mouse.Listener(on_click=on_click) as ml:
time.sleep(5)
print("Tayyor! Endi qaytariladi...")
PLAYBACK
start = events[0][2]
for e in events:
delay = e[2] - start
time.sleep(delay)
if e[0] == "key":
try:
keyboard.Controller().press(e[1])
keyboard.Controller().release(e[1])
except:
pass
elif e[0] == "mouse":
m = mouse.Controller()
x, y, button = e[1]
m.position = (x, y)
m.click(button)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels