Skip to content

Introduction to pyautogui

diagram a GUI script drives the whole machine, not just your program mermaid
pyautogui has no idea what it is clicking. It moves the real cursor and types into whatever has focus, so a window appearing at the wrong moment redirects the input somewhere unintended. Everything about writing these safely is about keeping a way to stop and never assuming what is on screen.

GUI automation can click/delete the wrong things.

  • keep failsafes
  • prefer APIs when possible
pyautogui_basics.py
import pyautogui
 
print(pyautogui.size())
print(pyautogui.position())

By default, moving the mouse to the top-left corner raises pyautogui.FailSafeException.

Keep it enabled.

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading