{"id":13448255,"url":"https://github.com/asweigart/pyautogui","last_synced_at":"2025-05-14T08:05:11.271Z","repository":{"id":18749066,"uuid":"21961171","full_name":"asweigart/pyautogui","owner":"asweigart","description":"A cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse \u0026 keyboard.","archived":false,"fork":false,"pushed_at":"2024-08-20T18:34:57.000Z","size":2346,"stargazers_count":11400,"open_issues_count":563,"forks_count":1326,"subscribers_count":192,"default_branch":"master","last_synced_at":"2025-05-14T08:03:36.832Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asweigart.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.txt","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":"docs/roadmap.rst","authors":"AUTHORS.txt","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-07-17T23:30:38.000Z","updated_at":"2025-05-14T06:46:58.000Z","dependencies_parsed_at":"2023-02-19T08:31:25.159Z","dependency_job_id":"b50beb1d-3060-427d-86b1-cf9ede8ce055","html_url":"https://github.com/asweigart/pyautogui","commit_stats":{"total_commits":318,"total_committers":53,"mean_commits":6.0,"dds":"0.30817610062893086","last_synced_commit":"b4255d0be42c377154c7d92337d7f8515fc63234"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asweigart%2Fpyautogui","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asweigart%2Fpyautogui/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asweigart%2Fpyautogui/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asweigart%2Fpyautogui/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asweigart","download_url":"https://codeload.github.com/asweigart/pyautogui/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254101588,"owners_count":22014907,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T05:01:40.162Z","updated_at":"2025-05-14T08:05:11.253Z","avatar_url":"https://github.com/asweigart.png","language":"Python","funding_links":["https://www.patreon.com/AlSweigart"],"categories":["Python","Testing","资源列表","GUI Automation","Programming","RPA(Robotic Process Automation)","测试","Projects","HarmonyOS","Testing Tools","Testing [🔝](#readme)","📚 فهرست","Awesome Python","UI Testing","GUI \u0026 Computer Control AI Agents","Desktop Automation Libraries","Desktop App Testing"],"sub_categories":["测试","Snippets Manager","Python  \u003cimg src=\"https://raw.github.com/pcgeek86/awesome-trevor/main/assets/Python.svg?sanitize=true\" height=18\u003e","Automation","Windows Manager","اتوماسیون","Testing","Desktop Automation","AutoIt"],"readme":"PyAutoGUI\n=========\n\nPyAutoGUI is a  cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse \u0026 keyboard.\n\n`pip install pyautogui`\n\nFull documentation available at https://pyautogui.readthedocs.org\n\nSimplified Chinese documentation available at https://github.com/asweigart/pyautogui/blob/master/docs/simplified-chinese.ipynb\n\nSource code available at https://github.com/asweigart/pyautogui\n\nIf you need help installing Python, visit https://installpython3.com/\n\nDependencies\n============\n\nPyAutoGUI supports Python 2 and 3. If you are installing PyAutoGUI from PyPI using pip:\n\nWindows has no dependencies. The Win32 extensions do not need to be installed.\n\nmacOS needs the pyobjc-core and pyobjc module installed (in that order).\n\nLinux needs the python3-xlib (or python-xlib for Python 2) module installed.\n\nPillow needs to be installed, and on Linux you may need to install additional libraries to make sure Pillow's PNG/JPEG works correctly. See:\n\n    https://stackoverflow.com/questions/7648200/pip-install-pil-e-tickets-1-no-jpeg-png-support\n\n    http://ubuntuforums.org/showthread.php?t=1751455\n\nIf you want to do development and contribute to PyAutoGUI, you will need to install these modules from PyPI:\n\n* pyscreeze\n* pymsgbox\n* pytweening\n\nExample Usage\n=============\n\nKeyboard and Mouse Control\n--------------------------\n\nThe x, y coordinates used by PyAutoGUI has the 0, 0 origin coordinates in the top left corner of the screen. The x coordinates increase going to the right (just as in mathematics) but the y coordinates increase going down (the opposite of mathematics). On a screen that is 1920 x 1080 pixels in size, coordinates 0, 0 are for the top left while 1919, 1079 is for the bottom right.\n\nCurrently, PyAutoGUI only works on the primary monitor. PyAutoGUI isn't reliable for the screen of a second monitor (the mouse functions may or may not work on multi-monitor setups depending on your operating system and version).\n\nAll keyboard presses done by PyAutoGUI are sent to the window that currently has focus, as if you had pressed the physical keyboard key.\n\n```python\n    \u003e\u003e\u003e import pyautogui\n    \u003e\u003e\u003e screenWidth, screenHeight = pyautogui.size() # Returns two integers, the width and height of the screen. (The primary monitor, in multi-monitor setups.)\n    \u003e\u003e\u003e currentMouseX, currentMouseY = pyautogui.position() # Returns two integers, the x and y of the mouse cursor's current position.\n    \u003e\u003e\u003e pyautogui.moveTo(100, 150) # Move the mouse to the x, y coordinates 100, 150.\n    \u003e\u003e\u003e pyautogui.click() # Click the mouse at its current location.\n    \u003e\u003e\u003e pyautogui.click(200, 220) # Click the mouse at the x, y coordinates 200, 220.\n    \u003e\u003e\u003e pyautogui.move(None, 10)  # Move mouse 10 pixels down, that is, move the mouse relative to its current position.\n    \u003e\u003e\u003e pyautogui.doubleClick() # Double click the mouse at the\n    \u003e\u003e\u003e pyautogui.moveTo(500, 500, duration=2, tween=pyautogui.easeInOutQuad) # Use tweening/easing function to move mouse over 2 seconds.\n    \u003e\u003e\u003e pyautogui.write('Hello world!', interval=0.25)  # Type with quarter-second pause in between each key.\n    \u003e\u003e\u003e pyautogui.press('esc') # Simulate pressing the Escape key.\n    \u003e\u003e\u003e pyautogui.keyDown('shift')\n    \u003e\u003e\u003e pyautogui.write(['left', 'left', 'left', 'left', 'left', 'left'])\n    \u003e\u003e\u003e pyautogui.keyUp('shift')\n    \u003e\u003e\u003e pyautogui.hotkey('ctrl', 'c')\n```\n\nDisplay Message Boxes\n---------------------\n```python\n    \u003e\u003e\u003e import pyautogui\n    \u003e\u003e\u003e pyautogui.alert('This is an alert box.')\n    'OK'\n    \u003e\u003e\u003e pyautogui.confirm('Shall I proceed?')\n    'Cancel'\n    \u003e\u003e\u003e pyautogui.confirm('Enter option.', buttons=['A', 'B', 'C'])\n    'B'\n    \u003e\u003e\u003e pyautogui.prompt('What is your name?')\n    'Al'\n    \u003e\u003e\u003e pyautogui.password('Enter password (text will be hidden)')\n    'swordfish'\n```\n\nScreenshot Functions\n--------------------\n\n(PyAutoGUI uses Pillow for image-related features.)\n```python\n    \u003e\u003e\u003e import pyautogui\n    \u003e\u003e\u003e im1 = pyautogui.screenshot()\n    \u003e\u003e\u003e im1.save('my_screenshot.png')\n    \u003e\u003e\u003e im2 = pyautogui.screenshot('my_screenshot2.png')\n```\nYou can also locate where an image is on the screen:\n```python\n    \u003e\u003e\u003e import pyautogui\n    \u003e\u003e\u003e button7location = pyautogui.locateOnScreen('button.png') # returns (left, top, width, height) of matching region\n    \u003e\u003e\u003e button7location\n    (1416, 562, 50, 41)\n    \u003e\u003e\u003e buttonx, buttony = pyautogui.center(button7location)\n    \u003e\u003e\u003e buttonx, buttony\n    (1441, 582)\n    \u003e\u003e\u003e pyautogui.click(buttonx, buttony)  # clicks the center of where the button was found\n```\nThe locateCenterOnScreen() function returns the center of this match region:\n```python\n    \u003e\u003e\u003e import pyautogui\n    \u003e\u003e\u003e buttonx, buttony = pyautogui.locateCenterOnScreen('button.png') # returns (x, y) of matching region\n    \u003e\u003e\u003e buttonx, buttony\n    (1441, 582)\n    \u003e\u003e\u003e pyautogui.click(buttonx, buttony)  # clicks the center of where the button was found\n```\n\nHow Does PyAutoGUI Work?\n========================\n\nThe three major operating systems (Windows, macOS, and Linux) each have different ways to programmatically control the mouse and keyboard. This can often involve confusing, obscure, and deeply technical details. The job of PyAutoGUI is to hide all of this complexity behind a simple API.\n\n* On Windows, PyAutoGUI accesses the Windows API (also called the WinAPI or win32 API) through the built-in `ctypes` module. The `nicewin` module at https://github.com/asweigart/nicewin provides a demonstration for how Windows API calls can be made through Python.\n\n* On macOS, PyAutoGUI uses the `rubicon-objc` module to access the Cocoa API.\n\n* On Linux, PyAutoGUI uses the `Xlib` module to access the X11 or X Window System.\n\n\nSupport\n-------\n\nIf you find this project helpful and would like to support its development, [consider donating to its creator on Patreon](https://www.patreon.com/AlSweigart).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasweigart%2Fpyautogui","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasweigart%2Fpyautogui","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasweigart%2Fpyautogui/lists"}