Definition
The tactical API for simulating human mouse input via the pyautogui module.
Why It Matters
These tools allow you to bridge the “last mile” of automation—applications with no API. Automating mouse movements allows you to bypass manual data entry for UI-only interfaces.
Core Concepts
- Movement:
moveTo(x, y, duration): Teleport or glide to coordinates.move(x, y): Move relative to current position.
- Interaction:
click(),doubleClick(),rightClick().dragTo(x, y): Moves with the button held down.scroll(n): Positivenscrolls up, negative scrolls down.
- Example Usage:
import pyautogui
# Move mouse to coordinates (100, 100) over 1 second
pyautogui.moveTo(100, 100, duration=1)
# Perform a click
pyautogui.click()
# Get current position
x, y = pyautogui.position()
print(f"Mouse is at: {x}, {y}")
- Screen Info:
size()returns resolution;position()returns current mouse coordinates.