DEV Community

MrRobot
MrRobot

Posted on

PyAutoGUI - Cross-Platform GUI Automation

PyAutoGUI is a Python library for automating mouse and keyboard actions. It allows developers to control the mouse pointer, simulate clicks, type text, take screenshots, and even locate images on the screen. PyAutoGUI is widely used for automating repetitive tasks, testing applications, and creating simple bots. Since it works across Windows, macOS, and Linux, it provides a convenient way to script user interactions with the operating system.


Installation:

pip install pyautogui
Enter fullscreen mode Exit fullscreen mode

Example usage:

import pyautogui

# Move the mouse to coordinates (100, 100)
pyautogui.moveTo(100, 100, duration=1)

# Type a message
pyautogui.write("Hello, world!", interval=0.1)

# Take a screenshot
screenshot = pyautogui.screenshot()
screenshot.save("screen.png")
Enter fullscreen mode Exit fullscreen mode

PyPI page: https://pypi.org/project/PyAutoGUI/
GitHub page: https://github.com/asweigart/pyautogui


3 Project Ideas:

  1. Build a bot that automatically fills out forms on websites.
  2. Create a simple game-playing bot that clicks and moves automatically.
  3. Develop a screenshot and monitoring tool for tracking desktop activity.

Top comments (0)