简体   繁体   中英

Pyautogui - Screenshot Doesn't Cover Entire Screen

I've been trying to use the screenshot feature of pyautogui, and whenever I take a screenshot it only captures the top left corner of the screen. Even when I manually enter a larger region to screenshot, it just makes the rest black.

Example:

正在创建图像的示例

What could I do to fix this?

Code that made this image:

import pyautogui
import time
import sys

im = pyautogui.screenshot('board.png',region=(0,0, 2000, 1000))

I found a work around from python-imaging-library-fails-to-grab-whole-screen , and at Github pyautogui Issues #116: Scaling issue on Windows affecting screenshots #116 . You still have to manually set the region as the default doesn't capture the whole screen.

import pyautogui
from ctypes import windll
user32 = windll.user32
user32.SetProcessDPIAware()
pyautogui.screenshot('my_screenshot.png', region=(0,0,1920,1080))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM