Python 如何捕获窗口照片(缩略图)?
我想获得一个窗口的照片(缩略图),我已经在windows操作系统中使用python获得了该窗口的句柄(hwnd)。从中,我可以获得一个示例,用于缩略图我的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
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。