• <bdo id='kvCPK'></bdo><ul id='kvCPK'></ul>

      <i id='kvCPK'><tr id='kvCPK'><dt id='kvCPK'><q id='kvCPK'><span id='kvCPK'><b id='kvCPK'><form id='kvCPK'><ins id='kvCPK'></ins><ul id='kvCPK'></ul><sub id='kvCPK'></sub></form><legend id='kvCPK'></legend><bdo id='kvCPK'><pre id='kvCPK'><center id='kvCPK'></center></pre></bdo></b><th id='kvCPK'></th></span></q></dt></tr></i><div id='kvCPK'><tfoot id='kvCPK'></tfoot><dl id='kvCPK'><fieldset id='kvCPK'></fieldset></dl></div>
      <legend id='kvCPK'><style id='kvCPK'><dir id='kvCPK'><q id='kvCPK'></q></dir></style></legend>
      1. <small id='kvCPK'></small><noframes id='kvCPK'>

        <tfoot id='kvCPK'></tfoot>

      2. 没有 PIL 的 Python windows 7 屏幕截图

        时间:2023-07-23

        1. <i id='tjIIL'><tr id='tjIIL'><dt id='tjIIL'><q id='tjIIL'><span id='tjIIL'><b id='tjIIL'><form id='tjIIL'><ins id='tjIIL'></ins><ul id='tjIIL'></ul><sub id='tjIIL'></sub></form><legend id='tjIIL'></legend><bdo id='tjIIL'><pre id='tjIIL'><center id='tjIIL'></center></pre></bdo></b><th id='tjIIL'></th></span></q></dt></tr></i><div id='tjIIL'><tfoot id='tjIIL'></tfoot><dl id='tjIIL'><fieldset id='tjIIL'></fieldset></dl></div>

          <legend id='tjIIL'><style id='tjIIL'><dir id='tjIIL'><q id='tjIIL'></q></dir></style></legend>

            <tbody id='tjIIL'></tbody>
            <bdo id='tjIIL'></bdo><ul id='tjIIL'></ul>
                  <tfoot id='tjIIL'></tfoot>

                  <small id='tjIIL'></small><noframes id='tjIIL'>

                  本文介绍了没有 PIL 的 Python windows 7 屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想用python截图.

                  I want to take a screenshot using python.

                  我曾尝试使用 PIL,但由于我使用的是 64 位 Windows 并且 python PIL 不起作用(我只能找到 32 位 PIL 版本).顺便说一句,我使用的是 python 2.7.1.

                  I have tried using PIL, but since I am using 64bit windows and python PIL does not work (I could only find 32bit PIL versions). I am using python 2.7.1 by the way.

                  我要截个图,怎么做都无所谓,只要能达到每秒1个以上的速度即可.最好它还应该能够裁剪截取屏幕截图的区域,但这并不是最重要的.

                  I want to take a screenshot, it doesn't really matter how, as long as it can take more than 1 per second in speed. Preferably it should also be able to crop the area it takes a screenshot of, but that's not of the utmost importance.

                  主要问题似乎是我在 64 位上运行,而且很多事情似乎与此不兼容.如果可能的话,我真的不想回到 32 位.是否有任何程序或模块可以做到这一点?

                  The main problem seems to be I'm running on 64bit and a lot of things seem incompatible with that. I don't really want to move back to 32bit though if at all possible. Are there any programs or modules that can do this?

                  推荐答案

                  在 http://www.lfd.uci.edu/~gohlke/pythonlibs/#pil.

                  from PIL import ImageGrab
                  im = ImageGrab.grab()
                  im.save('screenshot.png')
                  

                  更新:改用 pywin32 (http://sourceforge.net/projects/pywin32/)PIL 对多个虚拟屏幕进行截图:

                  Update: use pywin32 (http://sourceforge.net/projects/pywin32/) instead of PIL to take screenshots of multiple virtual screens:

                  import win32gui, win32ui, win32con, win32api
                  hwin = win32gui.GetDesktopWindow()
                  width = win32api.GetSystemMetrics(win32con.SM_CXVIRTUALSCREEN)
                  height = win32api.GetSystemMetrics(win32con.SM_CYVIRTUALSCREEN)
                  left = win32api.GetSystemMetrics(win32con.SM_XVIRTUALSCREEN)
                  top = win32api.GetSystemMetrics(win32con.SM_YVIRTUALSCREEN)
                  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')
                  

                  这篇关于没有 PIL 的 Python windows 7 屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:没有大量库依赖的 Python 消息框 下一篇:Python.IOError:[Errno 13] 权限被拒绝:当我复制文件时

                  相关文章

                  <i id='ztMEc'><tr id='ztMEc'><dt id='ztMEc'><q id='ztMEc'><span id='ztMEc'><b id='ztMEc'><form id='ztMEc'><ins id='ztMEc'></ins><ul id='ztMEc'></ul><sub id='ztMEc'></sub></form><legend id='ztMEc'></legend><bdo id='ztMEc'><pre id='ztMEc'><center id='ztMEc'></center></pre></bdo></b><th id='ztMEc'></th></span></q></dt></tr></i><div id='ztMEc'><tfoot id='ztMEc'></tfoot><dl id='ztMEc'><fieldset id='ztMEc'></fieldset></dl></div>
                    <bdo id='ztMEc'></bdo><ul id='ztMEc'></ul>

                      <small id='ztMEc'></small><noframes id='ztMEc'>

                      <tfoot id='ztMEc'></tfoot>
                    1. <legend id='ztMEc'><style id='ztMEc'><dir id='ztMEc'><q id='ztMEc'></q></dir></style></legend>