我想通过 python 脚本截取屏幕截图并不显眼地保存。
我只对 Linux 解决方案感兴趣,应该支持任何基于 X 的环境。
最佳答案
这无需使用 scrot 或 ImageMagick 即可工作。
import gtk.gdk
w = gtk.gdk.get_default_root_window()
sz = w.get_size()
print "The size of the window is %d x %d" % sz
pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,sz[0],sz[1])
pb = pb.get_from_drawable(w,w.get_colormap(),0,0,0,0,sz[0],sz[1])
if (pb != None):
pb.save("screenshot.png","png")
print "Screenshot saved to screenshot.png."
else:
print "Unable to get the screenshot."
借自 http://ubuntuforums.org/showpost.php?p=2681009&postcount=5
关于python - 在 Linux 上通过 Python 脚本截取屏幕截图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69645/