1.安装PIL
pip install Pillow
2.python程序
import time,datetime from PIL import ImageGrab import os d1 = datetime.date.today() #获取当前时间 end_h = 16 #结束时间 end_m = 25 #结束分钟 base_dir = "G:/test/printScreen/picture" #图片保存地址 startTime = datetime.datetime(2022, int(d1.month), int(d1.day), end_h, end_m, int(d1.day)+1) #自动截图到16:25 print(startTime) i = 0 while datetime.datetime.now() < startTime: im =ImageGrab.grab() time.sleep(1) #0.5秒一截 img = ImageGrab.grab() if im != img : #界面发现变化了才保存图片 img.save(os.sep.join([base_dir,str(i)+'.png'])) print("ok:"+str(i)) i+=1 print('finish')
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/288598.html