`
忧里修斯
  • 浏览: 426432 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论

Python截屏程序

阅读更多
说明:必须安装PIL库

# -*- coding:UTF-8 -*-
'''
Created on 2010-5-6

@author: shiyong
'''
import os
from PIL import ImageGrab
import time

class 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()
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics