python screenshot

from PIL import Image, ImageGrab

def screenshot(imagefile):
     ''' Take a screenshot of the entire screen and save it to imagefile ''' 
    image = ImageGrab.grab()
     return image.save(imagefile)


def screenshot_by_size(imagefile,x1,y1,x2,y2):
     ''' Intercept the screen image within the coordinate range of x1,y1 to x2,y2 and save it to imagefile ''' 
    image = ImageGrab.grab((x1,y1,x2 ,y2))
     return image.save(imagefile)

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324740452&siteId=291194637