忧里修斯 发表于 2013-1-15 02:34:17

Python截屏程序

说明:必须安装PIL库

# -*- coding:UTF-8 -*-'''Created on 2010-5-6@author: shiyong'''import osfrom PIL import ImageGrabimport timeclass Capturer(object):      '''截屏程序'''      def capture(self,path='C:\\images'):      '''                  截屏并保存图片至path目录下      '''      if not os.path.isdir(path) or not os.path.exists(path):            os.makedirs(path)      cutime = time.strftime('%Y%m%d%H%M%S',time.localtime(time.time()))      filename = path+'\\'+cutime+'.gif'      im = ImageGrab.grab()      im.save(filename)if __name__ == '__main__':      cer = Capturer()    while True:      time.sleep(2)      cer.capture()
页: [1]
查看完整版本: Python截屏程序