PyAutoGUI is a cross-platform Python library for GUI automation, enabling programmatic control of the mouse and keyboard, and other GUI tasks like screenshots and image recognition. It simplifies complex operating system interactions into a straightforward API. Currently at version 0.9.54, the library is actively maintained with updates released periodically.
pip install pyautoguiVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates basic PyAutoGUI functions: getting screen dimensions, moving the mouse, clicking, typing text, and displaying a message box. The `duration` and `interval` parameters add human-like delays.
Be aware of this feature. To disable (NOT recommended), set `pyautogui.FAILSAFE = False`. Adjust the default 0.1-second delay between calls with `pyautogui.PAUSE = value`.
Manually install required OS packages (e.g., `pyobjc-core` and `pyobjc` on macOS; `python3-xlib`, `scrot`, `python3-tk`, `python3-dev` on Linux) using your system's package manager (`pip3` or `apt-get`).
For reliable text input with non-US layouts or complex strings, consider using an external library like `keyboard` (e.g., `keyboard.write(text)`) or copying text to the clipboard and then pasting it using `pyautogui.hotkey('ctrl', 'v')` or equivalent.Ensure proper VM setup for GUI automation. This often involves specific guest additions/tools installation and configuration to allow the VM to intercept and process host input correctly. Running PyAutoGUI in a VM may require additional troubleshooting specific to your VM software.
Design scripts to operate within the bounds of the primary monitor or run the automation on systems with a single display for consistent results.
Install the module using 'pip install pyautogui'.
Ensure 'pyautogui' is installed in the correct environment using 'pip install pyautogui'.
Ensure 'pyautogui' is installed in the correct environment using 'pip install pyautogui'.
Ensure 'pyautogui' is installed in the correct environment using 'pip install pyautogui'.
Ensure Pillow and opencv-python are installed and up-to-date: `pip install --upgrade Pillow opencv-python`.