相关文章推荐
强健的企鹅  ·  rsa.importkey rsa key ...·  2 年前    · 
卖萌的红金鱼  ·  前端 - 解决Element UI ...·  2 年前    · 
import win32gui, win32ui, win32con, win32api
hwin = win32gui.GetDesktopWindow()
width = win32api.GetSystemMetrics(win32con.SM_CXVIRTUALSCR EEN)
height = win32api.GetSystemMetrics(win32con.SM_CYVIRTUALSCR EEN)
left = win32api.GetSystemMetrics(win32con.SM_XVIRTUALSCRE EN)
top = win32api.GetSystemMetrics(win32con.SM_YVIRTUALSCRE EN)
hwindc = win32gui.GetWindowDC(hwin)
srcdc = win32ui.CreateDCFromHandle(hwindc)
memdc = srcdc.CreateCompatibleDC()
bmp = win32ui.CreateBitmap()
bmp.CreateCompatibleBitmap(srcdc, width, height)
memdc.SelectObject(bmp)
memdc.BitBlt((0, 0), (width, height), srcdc, (left, top), win32con.SRCCOPY)
bmp.SaveBitmapFile(memdc, 'screenshot.bmp')
This code output bmp file size 4mb. I need 100 kb file.
  • Read the question carefully.
  • Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  • If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  • Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question. Let's work to help developers, not make them feel stupid.
  •