Skip to content

Controlling Mouse Movements and Clicks

mouse_click.py
import pyautogui
 
pyautogui.moveTo(200, 200, duration=0.5)
pyautogui.click()
mouse_drag.py
import pyautogui
 
pyautogui.dragTo(400, 400, duration=0.5, button="left")
scroll.py
import pyautogui
 
pyautogui.scroll(-500)

GUI automation locates a target on screen, then moves and acts on it before checking the outcome.

diagram GUI automation flow mermaid
How a script locates, moves, and interacts with a UI target

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading