标签:屏幕截图 pad com 保存 resources rcc eth source notepad
import win32gui import win32ui import win32con name = "test.txt - Notepad" hwnd = win32gui.FindWindow(None, name) left, top, right, bot = win32gui.GetWindowRect(hwnd) w = right - left h = bot - top print(w,h) wDC = win32gui.GetWindowDC(hwnd) dcObj=win32ui.CreateDCFromHandle(wDC) cDC=dcObj.CreateCompatibleDC() dataBitMap = win32ui.CreateBitmap() dataBitMap.CreateCompatibleBitmap(dcObj, w, h) cDC.SelectObject(dataBitMap) cDC.BitBlt((0,0),(w, h) , dcObj, (0,0), win32con.SRCCOPY) dataBitMap.SaveBitmapFile(cDC, "1.bmp") # Free Resources dcObj.DeleteDC() cDC.DeleteDC() win32gui.ReleaseDC(hwnd, wDC) win32gui.DeleteObject(dataBitMap.GetHandle())
主要是利用win32库
标签:屏幕截图 pad com 保存 resources rcc eth source notepad
原文地址:https://www.cnblogs.com/strive-sun/p/12696898.html