简体   繁体   English

Pyautogui-屏幕截图无法覆盖整个屏幕

[英]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. 我一直在尝试使用pyautogui的屏幕截图功能,每当我拍摄屏幕截图时,它只会捕获屏幕的左上角。 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 . 我在python-imaging-library-fails-to- grab- 整个屏幕和Github pyautogui问题#116: Windows上的缩放问题影响了屏幕截图#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))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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