METADATA 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. Metadata-Version: 2.4
  2. Name: PyAutoGUI
  3. Version: 0.9.54
  4. Summary: PyAutoGUI lets Python control the mouse and keyboard, and other GUI automation tasks. For Windows, macOS, and Linux, on Python 3 and 2.
  5. Home-page: https://github.com/asweigart/pyautogui
  6. Author: Al Sweigart
  7. Author-email: al@inventwithpython.com
  8. License: BSD
  9. Keywords: gui automation test testing keyboard mouse cursor click press keystroke control
  10. Classifier: Development Status :: 4 - Beta
  11. Classifier: Environment :: Win32 (MS Windows)
  12. Classifier: Environment :: X11 Applications
  13. Classifier: Environment :: MacOS X
  14. Classifier: Intended Audience :: Developers
  15. Classifier: License :: OSI Approved :: BSD License
  16. Classifier: Operating System :: OS Independent
  17. Classifier: Programming Language :: Python
  18. Classifier: Programming Language :: Python :: 3
  19. Classifier: Programming Language :: Python :: 3.1
  20. Classifier: Programming Language :: Python :: 3.2
  21. Classifier: Programming Language :: Python :: 3.3
  22. Classifier: Programming Language :: Python :: 3.4
  23. Classifier: Programming Language :: Python :: 3.5
  24. Classifier: Programming Language :: Python :: 3.6
  25. Classifier: Programming Language :: Python :: 3.7
  26. Classifier: Programming Language :: Python :: 3.8
  27. Classifier: Programming Language :: Python :: 3.9
  28. Classifier: Programming Language :: Python :: 3.10
  29. Classifier: Programming Language :: Python :: 3.11
  30. Description-Content-Type: text/markdown
  31. License-File: LICENSE.txt
  32. License-File: AUTHORS.txt
  33. Requires-Dist: pyobjc-core; platform_system == "Darwin"
  34. Requires-Dist: pyobjc-framework-quartz; platform_system == "Darwin"
  35. Requires-Dist: python3-Xlib; platform_system == "Linux" and python_version >= "3.0"
  36. Requires-Dist: python-xlib; platform_system == "Linux" and python_version < "3.0"
  37. Requires-Dist: pymsgbox
  38. Requires-Dist: pytweening>=1.0.4
  39. Requires-Dist: pyscreeze>=0.1.21
  40. Requires-Dist: pygetwindow>=0.0.5
  41. Requires-Dist: mouseinfo
  42. Dynamic: author
  43. Dynamic: author-email
  44. Dynamic: classifier
  45. Dynamic: description
  46. Dynamic: description-content-type
  47. Dynamic: home-page
  48. Dynamic: keywords
  49. Dynamic: license
  50. Dynamic: license-file
  51. Dynamic: requires-dist
  52. Dynamic: summary
  53. PyAutoGUI
  54. =========
  55. PyAutoGUI is a cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard.
  56. `pip install pyautogui`
  57. Full documentation available at https://pyautogui.readthedocs.org
  58. Simplified Chinese documentation available at https://github.com/asweigart/pyautogui/blob/master/docs/simplified-chinese.ipynb
  59. Source code available at https://github.com/asweigart/pyautogui
  60. If you need help installing Python, visit https://installpython3.com/
  61. Dependencies
  62. ============
  63. PyAutoGUI supports Python 2 and 3. If you are installing PyAutoGUI from PyPI using pip:
  64. Windows has no dependencies. The Win32 extensions do not need to be installed.
  65. macOS needs the pyobjc-core and pyobjc module installed (in that order).
  66. Linux needs the python3-xlib (or python-xlib for Python 2) module installed.
  67. Pillow needs to be installed, and on Linux you may need to install additional libraries to make sure Pillow's PNG/JPEG works correctly. See:
  68. https://stackoverflow.com/questions/7648200/pip-install-pil-e-tickets-1-no-jpeg-png-support
  69. http://ubuntuforums.org/showthread.php?t=1751455
  70. If you want to do development and contribute to PyAutoGUI, you will need to install these modules from PyPI:
  71. * pyscreeze
  72. * pymsgbox
  73. * pytweening
  74. Example Usage
  75. =============
  76. Keyboard and Mouse Control
  77. --------------------------
  78. The 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.
  79. Currently, 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).
  80. All keyboard presses done by PyAutoGUI are sent to the window that currently has focus, as if you had pressed the physical keyboard key.
  81. ```python
  82. >>> import pyautogui
  83. >>> screenWidth, screenHeight = pyautogui.size() # Returns two integers, the width and height of the screen. (The primary monitor, in multi-monitor setups.)
  84. >>> currentMouseX, currentMouseY = pyautogui.position() # Returns two integers, the x and y of the mouse cursor's current position.
  85. >>> pyautogui.moveTo(100, 150) # Move the mouse to the x, y coordinates 100, 150.
  86. >>> pyautogui.click() # Click the mouse at its current location.
  87. >>> pyautogui.click(200, 220) # Click the mouse at the x, y coordinates 200, 220.
  88. >>> pyautogui.move(None, 10) # Move mouse 10 pixels down, that is, move the mouse relative to its current position.
  89. >>> pyautogui.doubleClick() # Double click the mouse at the
  90. >>> pyautogui.moveTo(500, 500, duration=2, tween=pyautogui.easeInOutQuad) # Use tweening/easing function to move mouse over 2 seconds.
  91. >>> pyautogui.write('Hello world!', interval=0.25) # Type with quarter-second pause in between each key.
  92. >>> pyautogui.press('esc') # Simulate pressing the Escape key.
  93. >>> pyautogui.keyDown('shift')
  94. >>> pyautogui.write(['left', 'left', 'left', 'left', 'left', 'left'])
  95. >>> pyautogui.keyUp('shift')
  96. >>> pyautogui.hotkey('ctrl', 'c')
  97. ```
  98. Display Message Boxes
  99. ---------------------
  100. ```python
  101. >>> import pyautogui
  102. >>> pyautogui.alert('This is an alert box.')
  103. 'OK'
  104. >>> pyautogui.confirm('Shall I proceed?')
  105. 'Cancel'
  106. >>> pyautogui.confirm('Enter option.', buttons=['A', 'B', 'C'])
  107. 'B'
  108. >>> pyautogui.prompt('What is your name?')
  109. 'Al'
  110. >>> pyautogui.password('Enter password (text will be hidden)')
  111. 'swordfish'
  112. ```
  113. Screenshot Functions
  114. --------------------
  115. (PyAutoGUI uses Pillow for image-related features.)
  116. ```python
  117. >>> import pyautogui
  118. >>> im1 = pyautogui.screenshot()
  119. >>> im1.save('my_screenshot.png')
  120. >>> im2 = pyautogui.screenshot('my_screenshot2.png')
  121. ```
  122. You can also locate where an image is on the screen:
  123. ```python
  124. >>> import pyautogui
  125. >>> button7location = pyautogui.locateOnScreen('button.png') # returns (left, top, width, height) of matching region
  126. >>> button7location
  127. (1416, 562, 50, 41)
  128. >>> buttonx, buttony = pyautogui.center(button7location)
  129. >>> buttonx, buttony
  130. (1441, 582)
  131. >>> pyautogui.click(buttonx, buttony) # clicks the center of where the button was found
  132. ```
  133. The locateCenterOnScreen() function returns the center of this match region:
  134. ```python
  135. >>> import pyautogui
  136. >>> buttonx, buttony = pyautogui.locateCenterOnScreen('button.png') # returns (x, y) of matching region
  137. >>> buttonx, buttony
  138. (1441, 582)
  139. >>> pyautogui.click(buttonx, buttony) # clicks the center of where the button was found
  140. ```
  141. How Does PyAutoGUI Work?
  142. ========================
  143. The 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.
  144. * 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.
  145. * On macOS, PyAutoGUI uses the `rubicon-objc` module to access the Cocoa API.
  146. * On Linux, PyAutoGUI uses the `Xlib` module to access the X11 or X Window System.
  147. Support
  148. -------
  149. If you find this project helpful and would like to support its development, [consider donating to its creator on Patreon](https://www.patreon.com/AlSweigart).