import pyscreenshot as ImageGrab import os import sys import time import PIL from PIL import Image import time import matplotlib.pyplot as plt #This python program takes a screenshot every 10 seconds def downSizeScShot(): start = time.time() old = time.clock() new = old while (new < old + 10): #--------------------------------------------------------- #User Settings: SaveDirectory=r'sc' SaveDirectory_down=r'sc_down' #ImageEditorPath=r'C:\WINDOWS\system32\mspaint.exe' # fullscreen #img=ImageGrab.grab() #img.show() # part of the screen x_pad = 1 y_pad = 1 im=ImageGrab.grab(bbox=(x_pad+0,y_pad+0,x_pad+600,y_pad+600)) #im.show() basewidth = 300 wpercent = (basewidth/float(im.size[0])) hsize = int((float(im.size[1])*float(wpercent))) im2 = im.resize((basewidth,hsize), PIL.Image.ANTIALIAS) im2 = im2.convert("L") #saveas=os.path.join(SaveDirectory,'ScreenShot_' + str(time.time())+'.jpg') saveas1=os.path.join(SaveDirectory,'ScreenShot_down_' + str(time.time())+'.jpg') saveas2=os.path.join(SaveDirectory_down,'less_ScreenShot_down_' + str(time.time())+'.jpg') #img.save(saveas) im.save(saveas1) im2.save(saveas2) #editorstring='""%s" "%s"'% (ImageEditorPath,saveas) #Just for Windows right now? #Notice the first leading " above? This is the bug in python that no one will admit... #os.system(editorstring) print "New time is \n", start, new new = time.clock() def main(): downSizeScShot() if __name__ == "__main__": main() #-#