Skip to content

Introduction to pyautogui

Warning

GUI automation can click/delete the wrong things.

  • keep failsafes
  • prefer APIs when possible

Basic controls

pyautogui_basics.py
import pyautogui
 
print(pyautogui.size())
print(pyautogui.position())
pyautogui_basics.py
import pyautogui
 
print(pyautogui.size())
print(pyautogui.position())

Failsafe

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

Keep it enabled.

If this helped you, consider buying me a coffee ☕

Buy me a coffee

Was this page helpful?

Let us know how we did