仅QtDesigner窗口的屏幕截图

问题描述:

是否可以获取某个窗口的屏幕截图而不是整个计算机屏幕?仅QtDesigner窗口的屏幕截图

我的窗口是用QtDesigner使用主窗口模板编写的。该窗口用于显示计算结果。我怎样才能截取一个窗口? pyscreenshot能够做到这一点吗?

据我所知,我可以使用bbox做屏幕的一部分,但如果用户移动窗口,它不会正确地截取屏幕截图。

我目前使用pyscreenshot,它需要整个屏幕的屏幕截图。

+0

是什么操作系统你? – Keeper

+0

我正在使用windows – dre

+1

然后看看像这样的平台特定的解决方案:https://stackoverflow.com/questions/891345/get-a-shotshot-of-a-specific-application – Keeper

我发现了一个基于其他职位的解决方案。

发现:Python Screenshot of inactive window PrintWindow + win32gui

若要导入模块解决问题,我下载pywin32 Python和使用这些作为我的进口

import win32gui 
import win32ui 
from ctypes import windll 
from PIL import Image