pip install pyautogui
pip show pyautogui
Name: PyAutoGUI
Version: 0.9.48
Summary: PyAutoGUI lets Python control the mouse and keyboard, and other GUI automation tasks. For Windows, macOS, and Linux, on Python 3 and 2.
Home-page: https://github.com/asweigart/pyautogui
Author: Al Sweigart
Author-email: al@inventwithpython.com
License: BSD
Location: /Users/frhyme/anaconda3/lib/python3.6/site-packages
Requires: pymsgbox, mouseinfo, pygetwindow, PyTweening, pyobjc, pyscreeze, pyobjc-core
Required-by:
import pyautogui
import time
"""
- 그냥 pyautogui를 이용해서 mouse를 현재 마우스에서 1초마다 조금씩 왼쪽, 위로 옮기는 코드.
- 왼쪽 위가 (0, 0)
"""
print("--" * 30)
# Get the size of the primary monitor.
screenWidth, screenHeight = pyautogui.size()
print(f"screenWidth, screenHeight")
print(screenWidth, screenHeight)
print("--"*30)
# Get the XY position of the mouse.
currentMouseX, currentMouseY = pyautogui.position()
print(f"currentMouseX, currentMouseY")
print(currentMouseX, currentMouseY)
print("--" * 30)
for i in range(0, 20):
time.sleep(1) # Delay a second.
currentMouseX -= 100
currentMouseY -= 100
pyautogui.moveTo(currentMouseX, currentMouseY)
print("--" * 30)
------------------------------------------------------------
screenWidth, screenHeight
1440 900
------------------------------------------------------------
currentMouseX, currentMouseY
990 343
------------------------------------------------------------
Traceback (most recent call last):
File "!pyautogui_1.py", line 26, in <module>
pyautogui.moveTo(currentMouseX, currentMouseY)
File "/Users/frhyme/anaconda3/lib/python3.6/site-packages/pyautogui/__init__.py", line 831, in moveTo
failSafeCheck()
File "/Users/frhyme/anaconda3/lib/python3.6/site-packages/pyautogui/__init__.py", line 1257, in failSafeCheck
raise FailSafeException('PyAutoGUI fail-safe triggered from mouse moving to a corner of the screen. To disable this fail-safe, set pyautogui.FAILSAFE to False. DISABLING FAIL-SAFE IS NOT RECOMMENDED.')
pyautogui.FailSafeException: PyAutoGUI fail-safe triggered from mouse moving to a corner of the screen. To disable this fail-safe, set pyautogui.FAILSAFE to False. DISABLING FAIL-SAFE IS NOT RECOMMENDED.
댓글남기기