728x90

import pyautogui as pag

pag.screenshot('test.png',region=(h_width + 535, h_height-201, 80, 80))

region 의 범위를 test.png 이름으로 떨궈줌.

https://pyautogui.readthedocs.io/en/latest/screenshot.html

Calling screenshot() will return an Image object (see the Pillow or PIL module documentation for details). Passing a string of a filename will save the screenshot to a file as well as return it as an Image object.

>>> import pyautogui
>>> im1 = pyautogui.screenshot()
>>> im2 = pyautogui.screenshot('my_screenshot.png')

On a 1920 x 1080 screen, the screenshot() function takes roughly 100 milliseconds - it’s not fast but it’s not slow.

There is also an optional region keyword argument, if you do not want a screenshot of the entire screen. You can pass a four-integer tuple of the left, top, width, and height of the region to capture:

>>> import pyautogui
>>> im = pyautogui.screenshot(region=(0,0, 300, 400))
728x90

+ Recent posts