我想在Windows操作系统中使用Python获取一个窗口的照片(缩略图),我已经有了它的句柄(hwnd)。
最佳答案
来自link i posted in your question comments,我能够得到一个示例,它可以显示我的 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')
关于python - 如何捕获窗口照片(缩略图)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13944581/