{"name":"PyAutoGUI: Cross-Platform GUI Automation with Python","description":"PyAutoGUI is an intuitive Python module designed for cross-platform GUI automation, enabling users to programmatically control the mouse and keyboard. It simplifies complex desktop interactions, allowing for tasks like clicking, typing, and taking screenshots across Windows, macOS, and Linux. This powerful library is ideal for automating repetitive tasks and creating bots.","github":"https://github.com/asweigart/pyautogui","url":"https://osrepos.com/repo/asweigart-pyautogui","source":"osrepos.com","sourceDescription":"This repository profile is provided by osrepos.com, an open source repository discovery platform.","repositoryProfile":"https://osrepos.com/repo/asweigart-pyautogui","generatedFor":"open source discovery and AI-assisted research","markdown":"https://osrepos.com/repo/asweigart-pyautogui.md","json":"https://osrepos.com/repo/asweigart-pyautogui.json","topics":["Python","GUI Automation","Desktop Automation","Scripting","Mouse Control","Keyboard Control","Screenshot Tool"],"keywords":["Python","GUI Automation","Desktop Automation","Scripting","Mouse Control","Keyboard Control","Screenshot Tool"],"stars":null,"summary":"PyAutoGUI is an intuitive Python module designed for cross-platform GUI automation, enabling users to programmatically control the mouse and keyboard. It simplifies complex desktop interactions, allowing for tasks like clicking, typing, and taking screenshots across Windows, macOS, and Linux. This powerful library is ideal for automating repetitive tasks and creating bots.","content":"## Introduction\n\nPyAutoGUI is a powerful, cross-platform Python module that simplifies GUI automation for human beings. It allows you to programmatically control the mouse and keyboard, making it an excellent tool for automating repetitive tasks, creating bots, or performing desktop interactions without direct human input. Whether you need to click buttons, type text, or capture screenshots, PyAutoGUI provides a straightforward API to achieve these actions across Windows, macOS, and Linux.\n\n## Installation\n\nInstalling PyAutoGUI is simple using pip. However, note that there are some operating system-specific dependencies.\n\nTo install PyAutoGUI:\n\nbash\npip install pyautogui\n\n\n**Dependencies:**\n*   **Windows:** No additional dependencies.\n*   **macOS:** Requires `pyobjc-core` and `pyobjc` modules.\n*   **Linux:** Needs `python3-xlib` (or `python-xlib` for Python 2).\n*   **All Platforms:** Pillow needs to be installed for image-related features. On Linux, additional libraries might be required for Pillow's PNG/JPEG support.\n\n## Examples\n\nPyAutoGUI offers a wide range of functions for controlling your GUI. Here are some common use cases:\n\n### Keyboard and Mouse Control\n\nControl mouse movement, clicks, and keyboard input. The origin (0,0) is the top-left corner of the screen.\n\npython\nimport pyautogui\n\nscreenWidth, screenHeight = pyautogui.size() # Returns two integers, the width and height of the screen.\ncurrentMouseX, currentMouseY = pyautogui.position() # Returns two integers, the x and y of the mouse cursor's current position.\npyautogui.moveTo(100, 150) # Move the mouse to the x, y coordinates 100, 150.\npyautogui.click() # Click the mouse at its current location.\npyautogui.click(200, 220) # Click the mouse at the x, y coordinates 200, 220.\npyautogui.move(None, 10)  # Move mouse 10 pixels down, relative to its current position.\npyautogui.doubleClick() # Double click the mouse at the current location.\npyautogui.moveTo(500, 500, duration=2, tween=pyautogui.easeInOutQuad) # Use tweening/easing function to move mouse over 2 seconds.\npyautogui.write('Hello world!', interval=0.25)  # Type with quarter-second pause in between each key.\npyautogui.press('esc') # Simulate pressing the Escape key.\npyautogui.keyDown('shift')\npyautogui.write(['left', 'left', 'left', 'left', 'left', 'left'])\npyautogui.keyUp('shift')\npyautogui.hotkey('ctrl', 'c')\n\n\n### Display Message Boxes\n\nPyAutoGUI can display various types of message boxes, useful for user interaction or debugging.\n\npython\nimport pyautogui\n\npyautogui.alert('This is an alert box.')\npyautogui.confirm('Shall I proceed?')\npyautogui.confirm('Enter option.', buttons=['A', 'B', 'C'])\npyautogui.prompt('What is your name?')\npyautogui.password('Enter password (text will be hidden)')\n\n\n### Screenshot Functions\n\nCapture screenshots and even locate images on the screen.\n\npython\nimport pyautogui\n\nim1 = pyautogui.screenshot()\nim1.save('my_screenshot.png')\nim2 = pyautogui.screenshot('my_screenshot2.png')\n\n# Locate an image on the screen\nbutton7location = pyautogui.locateOnScreen('button.png') # returns (left, top, width, height) of matching region\n# Example output: (1416, 562, 50, 41)\nbuttonx, buttony = pyautogui.center(button7location)\n# Example output: (1441, 582)\npyautogui.click(buttonx, buttony)  # clicks the center of where the button was found\n\n# Locate and click the center of an image directly\nbuttonx, buttony = pyautogui.locateCenterOnScreen('button.png') # returns (x, y) of matching region\n# Example output: (1441, 582)\npyautogui.click(buttonx, buttony)  # clicks the center of where the button was found\n\n\n## Why Use PyAutoGUI?\n\nPyAutoGUI excels at abstracting the complexities of operating system-specific GUI automation APIs. Instead of dealing with the intricate details of Windows API, macOS Cocoa API, or Linux X11, developers can use a single, consistent Python interface. This cross-platform compatibility and ease of use make PyAutoGUI an ideal choice for:\n\n*   **Automating repetitive tasks:** From filling out forms to navigating applications.\n*   **Testing GUI applications:** Creating automated test scripts for user interfaces.\n*   **Creating simple bots:** For games or other desktop applications.\n*   **Accessibility tools:** Assisting users with specific needs by automating interactions.\n\nIts design focuses on being \"for human beings,\" meaning its functions are intuitive and mimic natural user interactions.\n\n## Links\n\n*   **Full Documentation:** [https://pyautogui.readthedocs.org](https://pyautogui.readthedocs.org){:target=\"_blank\"}\n*   **Source Code (GitHub):** [https://github.com/asweigart/pyautogui](https://github.com/asweigart/pyautogui){:target=\"_blank\"}\n*   **Simplified Chinese Documentation:** [https://github.com/asweigart/pyautogui/blob/master/docs/simplified-chinese.ipynb](https://github.com/asweigart/pyautogui/blob/master/docs/simplified-chinese.ipynb){:target=\"_blank\"}\n\n## Support the Project\n\nIf you find PyAutoGUI helpful and wish to support its ongoing development, consider donating to its creator on Patreon: [https://www.patreon.com/AlSweigart](https://www.patreon.com/AlSweigart){:target=\"_blank\"}","metrics":{"detailViews":1,"githubClicks":0},"dates":{"published":null,"modified":"2026-08-04T13:00:03.000Z"}}