Files
ai_mouse/examples/quickstart.py

31 lines
928 B
Python

"""Minimal example: generate one trajectory + click event.
Run: uv run python examples/quickstart.py
"""
from __future__ import annotations
from ai_mouse import generate
start = (100, 200)
end = (900, 400)
points = generate(start, end, seed=0)
print(f"Generated {len(points)} events:")
print(f" first move: {points[0]}")
print(f" middle move: {points[len(points) // 2]}")
print(f" last move: {points[-3]}")
print(f" click-down: {points[-2]}")
print(f" click-up: {points[-1]}")
# Typical replay loop pattern. t_ms is cumulative from the start of the trace,
# so block your sender thread until time-since-start reaches each event's t_ms.
#
# import time
# t0 = time.monotonic()
# for x, y, t_ms in points:
# target_wallclock = t0 + t_ms / 1000.0
# while time.monotonic() < target_wallclock:
# pass
# # replace this with pyautogui / pynput / win32 mouse_event:
# # send_mouse_move(x, y)