Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to get screen capture on windows using python 3.3.
I used a python code but output bmp image is very big size. I need small output python code.



I am use this code

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.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900