import pyautogui
pyautogui.mouseInfo()
import pyautogui
mouseX, mouseY = pyautogui.position()
import pyautogui
screen_width, screen_height = pyautogui.size()
import pyautogui
pyautogui.moveTo(500, 500)
import pyautogui
# 마우스 클릭
pyautogui.click()
# 마우스 왼쪽 버튼 더블클릭
pyautogui.doubleClick()
pyautogui.click(clicks=2)
# 마우스 오른쪽 버튼 클릭
pyautogui.click(button='right')
pyautogui.rightClick()
# 마우스 휠 클릭
pyautogui.middleClick()
# 마우스 버튼다운
pyautogui.mouseDown()
# 마우스 버튼업
pyautogui.mouseUp()
# 마우스로 특정좌표 클릭
pyautogui.click(x=500, y=500)
# 1초 안에 더블 클릭 1회
pyautogui.click(clicks=2, interval=1)
#마우스 왼쪽 버튼 10회 클릭
pyautogui.click(clicks=10)
import pyautogui
# 마우스 드래그
pyautogui.mouseDown(x=100, y=100)
pyautogui.mouseUp(x=200, y=200)
# 마우스 드래그
# 마우스 현재 위치에서 x=100, y=100로 드래그
pyautogui.dragTo(x=100, y=100)
# 2초안에 마우스 현재 위치에서 x=100, y=100로 드래그
pyautogui.dragTo(x=100, y=100, duration=2)
# 2초안에 마우스 현재위치에서 -100, -100위치로 드래그
pyautogui.dragRel(-100, -100, duration=2)
# 마우스 스크롤 (위로)
pyautogui.scroll(-100)
# 마우스 스크롤 (아래로)
pyautogui.scroll(100)
# 특정 위치로 이동(x=100, y=100) 후 스크롤
pyautogui.scroll(100, x=100, y=100)
import pyautogui
#전체화면 스크린샷
img = pyautogui.screenshot()
img.save('screenshot.png')
#화면의 일부영역 스크린샷
img2 = pyautogui.screenshot('region.png', region=(0,0,500,500))
import pyautogui
# 특정 위치(x,y) 좌표의 색상값 비교
p = pyautogui.pixel(1000,100)
print(p)
if pyautogui.pixelMatchesColor(1000, 100, p):
print('일치')
else:
print('불일치')
import pyautogui
# 엔터키 누르기
pyautogui.press('enter')
# 여러 키 연속으로 입력하기
pyautogui.press(['enter','enter','enter','enter'])
# 키보드의 쉬프트를 누르고 유지
# pyautogui.keyDown('shift')
# 쉬프트키 누름 해제
# pyautogui.keyUp('shift')
# 복사 붙이기
pyautogui.hotkey('ctrl', 'c')
pyautogui.hotkey('ctrl', 'v')
# enter 키를 2초에 한번씩 5번 입력합니다.
pyautogui.press('enter', presses=5, interval=2)
import pyautogui
# 텍스트 입력
pyautogui.write('Hello python')
pyautogui.typewrite('Hello python')
import pyautogui
# 마우스 제어의 오동작으로부터 벗어날 수 있도록 True로 설정
pyautogui.FAILSAFE = True
#마우스 제어시 오류 발생시에도 실행을 멈추지않고 유지
pyautogui.FAILSAFE = False
import pyautogui
img_capture = pyautogui.locateOnScreen("test_icon.png")
print(img_capture)
# Box(left=x 좌표, top=y 좌표, width = 이미지 너비, height=이미지 높이) 형태로 반환
import pyautogui
# 여러개 이미지를 순회하며 클릭
for i in pyautogui.locateOnScreen("test_icon.png"):
pyautogui.click(i, duration=0.25)
import pyautogui
img_capture = pyautogui.locateOnScreen("test_icon.png", region=(1800, 0, 1920, 100))
import pyautogui
import opencv-python
# 일치율 70% 설정
img_capture = pyautogui.locateOnScreen("test_icon.png", confidence=0.7)
댓글남기기