PyAutoGUI lets your Python scripts control the mouse and keyboard to automate interactions with other applications. The API
is designed to be simple. PyAutoGUI works on Windows, macOS, and Linux, and runs on Python 2 and 3. To install with pip, run The source code is available on: https://github.com/asweigart/pyautogui PyAutoGUI has several features: Here’s a YouTube video of a bot
automatically playing the game Sushi Go Round. The bot watches the game’s application window and searches for images of sushi orders. When it finds one, it clicks the ingredient buttons to make the sushi. It also clicks the phone in the game to order more ingredients as needed. The bot is completely autonomous and can finish all seven days of the game. This is the kind of automation that PyAutoGUI is capable of. This example drags the mouse in a square spiral shape in MS Paint (or any graphics drawing program): >>> distance = 200 >>> while distance > 0: pyautogui.drag(distance, 0, duration=0.5) # move right distance -= 5 pyautogui.drag(0, distance, duration=0.5) # move down pyautogui.drag(-distance, 0, duration=0.5) # move left distance -= 5 pyautogui.drag(0, -distance, duration=0.5) # move up The benefit of using PyAutoGUI, as opposed to a script that directly generates the image file, is that you can use the brush tools that MS Paint provides. FAQ: Frequently Asked Questions¶Send questions to al@inventwithpython.com Q: Can PyAutoGUI work on Android, iOS, or tablet/smartphone apps. A: Unfortunately no. PyAutoGUI only runs on Windows, macOS, and Linux. Q: Does PyAutoGUI work on multi-monitor setups. A: No, right now PyAutoGUI only handles the primary monitor. Q: Does PyAutoGUI do OCR? A: No, but this is a feature that’s on the roadmap. Q: Can PyAutoGUI do keylogging, or detect if a key is currently pressed down? A: No, PyAutoGUI cannot do this currently. |