Notice
Recent Posts
Recent Comments
Link
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

이열매의 메모장

맥북 프로에서 PyAutoGui 위치 반환 에러 본문

잡지식

맥북 프로에서 PyAutoGui 위치 반환 에러

이열매 2020. 1. 10. 20:31

PyAutoGui 모듈의 locateCenterOnScreen 사용 시 위치가 제대로 잡히지 않았다. 검색해 본 결과 retina 디스플레이 사용 시엔 x, y 위치 좌표가 2배가 곱해진다고 한다.

 

즉, 다음과 같이 좌표 값을 다시 2로 나눠주는 작업이 필요하다.

 

import pyautogui

def get_location(img_path):
    location = pyayutogui.locateCenterOnScreen(img_path)
    x, y = location
    return x/2, y/2

 

 


References

https://medium.com/@tracy_blog/pyautogui-and-retina-displays-2d5c37a5aa5e

Comments