By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,379 Members | 3,035 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,379 IT Pros & Developers. It's quick & easy.

How to get small image screen capture

P: 1
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
Expand|Select|Wrap|Line Numbers
  1. import win32gui, win32ui, win32con, win32api
  2. hwin = win32gui.GetDesktopWindow()
  3. width = win32api.GetSystemMetrics(win32con.SM_CXVIRTUALSCREEN)
  4. height = win32api.GetSystemMetrics(win32con.SM_CYVIRTUALSCREEN)
  5. left = win32api.GetSystemMetrics(win32con.SM_XVIRTUALSCREEN)
  6. top = win32api.GetSystemMetrics(win32con.SM_YVIRTUALSCREEN)
  7. hwindc = win32gui.GetWindowDC(hwin)
  8. srcdc = win32ui.CreateDCFromHandle(hwindc)
  9. memdc = srcdc.CreateCompatibleDC()
  10. bmp = win32ui.CreateBitmap()
  11. bmp.CreateCompatibleBitmap(srcdc, width, height)
  12. memdc.SelectObject(bmp)
  13. memdc.BitBlt((0, 0), (width, height), srcdc, (left, top), win32con.SRCCOPY)
  14. bmp.SaveBitmapFile(memdc, 'screenshot.bmp')
Feb 9 '14 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.