PyAutoGUI
PyAutoGUI lets Python control the mouse and keyboard, and other GUI automation tasks. For Windows, macOS, and Linux, on Python 3 and 2.
What it is and what it does
PyAutoGUI is a cross-platform Python library that abstracts away the complexity of controlling the mouse and keyboard on Windows, macOS, and Linux. It provides a simple API to move the cursor, click, type, press keys, and perform other GUI automation tasks by hiding the platform-specific details—using ctypes and the Windows API on Windows, the Cocoa API on macOS, and Xlib on Linux.
The package also includes screenshot capture and image-location features (powered by Pillow) to find and interact with on-screen elements. It is commonly used for test automation, repetitive task scripting, and GUI interaction workflows. Installation requires platform-specific system dependencies and Pillow, and the package is currently dormant but remains stable and widely downloaded.
Use it for:
- Automate repetitive GUI tasks such as form filling, data entry, or clicking through dialogs in applications without native APIs.
- Write end-to-end GUI tests that simulate user interactions like mouse clicks, keyboard input, and screenshot verification.
- Build scripts to control legacy applications or third-party software that lack programmatic interfaces.
- Capture screenshots and locate UI elements on screen to enable conditional automation workflows.
- Create accessibility tools or macros that simulate keyboard and mouse events for users with mobility constraints.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
PyAutoGUI programmatically controls the mouse and keyboard across Windows, macOS, and Linux, enabling GUI automation tasks like clicking, typing, and taking screenshots.
Yes, with conditions. PyAutoGUI is worth installing if you need cross-platform GUI automation and can manage its platform-specific dependencies (pyobjc on macOS, python3-xlib on Linux, Pillow everywhere). The package is stable, permissively licensed, and widely used, but it is dormant—last released in May 2023—so expect no active maintenance. It works reliably on the primary monitor only and is best suited for scripting and testing, not production services.
Install
pyautogui on PyPI
pip
pip install pyautoguiuv
uv add pyautoguipoetry
poetry add pyautoguiInstalling PyAutoGUI
Before you install
Installation friction is high due to platform-specific system dependencies: Windows requires no extras, macOS requires pyobjc-core and pyobjc, and Linux requires python3-xlib. Pillow is also required and may need additional system libraries for PNG/JPEG support on Linux. The package is dormant (last release 2023-05-24, last commit 2024-08-20) but remains widely used.
License in practice
BSD license is permissive, allowing commercial and private use with minimal restrictions. You may use, modify, and distribute this package freely provided you include the original license notice.
Quickstart
pip install pyautogui
import pyautogui
# Move mouse and click
pyautogui.moveTo(100, 150)
pyautogui.click()
# Type text
pyautogui.write('Hello world!')
# Take screenshot
im = pyautogui.screenshot()
im.save('screenshot.png')
Platform-specific dependencies required: pyobjc-core and pyobjc on macOS; python3-xlib on Linux. Pillow must be installed and may require system libraries for image support on Linux.
Verify before relying
- Whether multi-monitor support has improved since the documented limitation to primary monitor only
- Current stability and bug-fix status given dormant maintenance (last release over 2 years old)
Package facts
| License | BSD (permissive) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | dormant — 1,178 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,940,189/month — #2,815 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: PyAutoGUI-0.9.54.tar.gz
Keywords: gui, automation, test, testing, keyboard, mouse, cursor, click, press, keystroke, control
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
PyDirectInputAutomates mouse and keyboard input on Windows…
permissive · top 15,000 on PyPI
pywinautoAutomate Microsoft Windows GUI interactions by…
permissive · top 5,000 on PyPI
PyGetWindowPyGetWindow provides functions to query,…
permissive · top 5,000 on PyPI
PyAutoItPyAutoIt provides Python bindings to…
permissive · top 15,000 on PyPI
pynputPynput lets you programmatically control and…
copyleft · top 5,000 on PyPI
MouseInfoMouseInfo displays the XY coordinates and RGB…
copyleft · top 5,000 on PyPI
keyboardHook global keyboard events, register hotkeys,…
permissive · top 5,000 on PyPI
pwinputDisplays mask characters (like asterisks) as…
permissive · top 15,000 on PyPI
inputsProvides cross-platform Python access to…
permissive · top 15,000 on PyPI
pynput-robocorp-forkControls and monitors mouse and keyboard input…
copyleft · top 15,000 on PyPI