[ Python ] 파이썬 pyautogui 이미지 영역 및 위치 찾기

[ Python ] 파이썬 pyautogui 이미지 영역 및 위치 찾기



1. 스크린샷 기능 설치 [Linux]

    - Linux에서 스크린샷 기능을 사용하려면 "scrot"이 설치되어 있어야 합니다.
    $ sudo apt-get install scrot


2. PIP 설치

    $ pip install pyautogui


3. 현재 화면에 찾고 싶은 이미지 캡쳐




4.  좌표 및 사이즈 불러오기

import pyautogui

GooglePhotos = pyautogui.locateOnScreen
                ('/home/heojungwook/VSCode
                    /GooglePhotos.png')

print(GooglePhotos)

    > Box(left=5, top=576, width=64, height=61)


5. 가운데 좌표 불러오기

import pyautogui

GooglePhotos = pyautogui.locateOnScreen
                ('/home/heojungwook/VSCode
                    /GooglePhotos.png')

Center = pyautogui.center(GooglePhotos)

print(Center)

    > Point(x=36, y=605)


6. 포인터 좌표를 이용해 클릭 하기

import pyautogui

GooglePhotos = pyautogui.locateOnScreen
                ('/home/heojungwook/VSCode
                    /GooglePhotos.png')

Center = pyautogui.center(GooglePhotos)

pyautogui.click(Center)



==========


댓글