Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何捕获窗口照片(缩略图)?_Python_Windows - Fatal编程技术网

Python 如何捕获窗口照片(缩略图)?

Python 如何捕获窗口照片(缩略图)?,python,windows,Python,Windows,我想获得一个窗口的照片(缩略图),我已经在windows操作系统中使用python获得了该窗口的句柄(hwnd)。从中,我可以获得一个示例,用于缩略图我的python解释器窗口 from PIL import ImageGrab, Image import win32gui hwnd = 2622054 # My python intepreter window thumbnailsize = 128, 128 # Set the current window to your window

我想获得一个窗口的照片(缩略图),我已经在windows操作系统中使用python获得了该窗口的句柄(hwnd)。

从中,我可以获得一个示例,用于缩略图我的python解释器窗口

from PIL import ImageGrab, Image
import win32gui

hwnd = 2622054 # My python intepreter window
thumbnailsize = 128, 128

# Set the current window to your window
win32gui.SetForegroundWindow(hwnd)
# Get the size of the window rect.
bbox = win32gui.GetWindowRect(hwnd)
# Grab the image using PIL and thumbnail.
img = ImageGrab.grab(bbox)
img.thumbnail(thumbnailsize, Image.ANTIALIAS)
# Save.
img.save('c:/test/test.png')

你看过吗?试着搜索一下。你可以从这里开始-@NickODell-OP想使用python。一旦你拥有了图像,你打算如何处理它?@Aesthete我知道。我不认为有一个python库来支持它——他必须调用WindowsAPI。