问题描述
我需要截取屏幕截图并通过邮寄方式将其发送到网络服务.我认为对于帖子部分,我将使用 liburl.
I need to take a screenshot and send it via post to a web service. I think for the post part i will use liburl.
这是否可以完全跨平台完成,而无需最终用户安装额外的库/软件?
Can this be accomplished completely cross platform and without having the need for the final user to install additional libraries/software?
推荐答案
标准库中没有任何东西可以为您做到这一点.从理论上讲,您可以通过使用 ctypes 进行依赖于操作系统的系统调用来自己完成,但这对我来说似乎是很多不必要的工作.这是一个使用 wxPython 制作屏幕截图的工作脚本:
There is not anything in the standard library that can do this for you. Theoretically, you might do it yourself by making os-dependent system calls with ctypes but that seems like a lot of unnecessary work to me. Here is a working script to make a screenshot using wxPython:
import wx
app = wx.App(False)
s = wx.ScreenDC()
w, h = s.Size.Get()
b = wx.EmptyBitmap(w, h)
m = wx.MemoryDCFromDC(s)
m.SelectObject(b)
m.Blit(0, 0, w, h, s, 0, 0)
m.SelectObject(wx.NullBitmap)
b.SaveFile("screenshot.png", wx.BITMAP_TYPE_PNG)
这篇关于在 Python 中截取屏幕截图 -- 跨平台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!