Write a Python script to automate filling out a repetitive desktop form by moving the mouse, clicking fields, and typing text.
Use screenshot matching to find and click a button wherever it appears on screen, even in apps with no scripting API.
Automate a multi-step sequence of keyboard shortcuts across different desktop applications without manual input.
Add a script-driven pop-up dialog to a Python automation so it can ask the user a question before continuing.
Windows works with pip install alone, Linux and macOS require a couple of extra system packages. Unreliable on multi-monitor setups.
PyAutoGUI is a Python library that lets you control your computer's mouse and keyboard through code. Instead of clicking around manually, you can write a script that moves the mouse to a specific position, clicks buttons, types text, or presses keyboard shortcuts, all without touching the actual input devices. This is useful for automating repetitive tasks on your desktop, like filling out forms, copying data between applications, or running the same sequence of actions over and over. The library works on Windows, macOS, and Linux. On each platform it speaks to the operating system using that platform's native programming interfaces, but it hides those technical details behind a simple set of Python functions. To move the mouse and click, you call moveTo() followed by click(). To type text, you call write() with the text as input. Keyboard shortcuts like Ctrl+C can be sent with a single hotkey() call. Beyond controlling the mouse and keyboard, PyAutoGUI can take screenshots and search the screen for a specific image. You can save a small screenshot of a button, then have the library scan your screen and click wherever that button appears. This makes it possible to automate interactions with applications that don't provide their own scripting support. The library also includes simple pop-up dialog boxes, so scripts can ask the user a question or display an alert and wait for a response before continuing. One limitation noted in the README: PyAutoGUI only works reliably with your primary monitor. Multi-monitor setups may produce unpredictable results depending on the operating system. Installation requires a single pip command. Linux and macOS users need to install a couple of additional packages manually, while Windows users can get started without any extra steps.
← asweigart on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.