在Linux上通过Python脚本拍摄屏幕截图

在Linux上通过Python脚本拍摄屏幕截图,第1张

在Linux上通过Python脚本拍摄屏幕截图

这无需使用scrot或ImageMagick即可工作。

import gtk.gdkw = gtk.gdk.get_default_root_window()sz = w.get_size()print "The size of the window is %d x %d" % szpb = 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借来



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5015000.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-15
下一篇 2022-11-14

发表评论

登录后才能评论

评论列表(0条)

保存