https://nbviewer.jupyter.org/gist/FinanceData/8b14a20e080797d2278d1f2e6a9cf13f
import pyautogui
import cv2
# 화면 저장
capture = pyautogui.screenshot()
capture.save('img_screenshot.png')
screenshot = cv2.imread('img_screenshot.png', cv2.IMREAD_COLOR)
template = cv2.imread('template.png', cv2.IMREAD_COLOR)
# 같은 그림 좌표
def match_center_loc(screen, template):
res = cv2.matchTemplate(screen, template, cv2.TM_CCOEFF_NORMED)
min_val,max_val,min_loc, max_loc = cv2.minMaxLoc(res)
top_left = max_loc
h,w = template.shape[:2]
x, y = int(top_left[0] + w/2), int(top_left[1] + h/2)
return x,y
match_pos = match_center_loc(screenshot, template)
pyautogui.moveTo(match_pos)
pyautogui.click()
'컴퓨터 > Python' 카테고리의 다른 글
bs4 (0) | 2019.06.23 |
---|---|
네이버 카페 서브페이지 웹크롤링 (0) | 2019.06.23 |
pyinstaller 파이썬 exe 파일만들기 (0) | 2019.06.13 |
Python: Openpyxl Iterate Column Wise or Row Wise (0) | 2019.06.12 |
win32com 수식을 값으로 붙여넣기 (0) | 2019.06.12 |