How to take screenshot using Python
Requirements
- pip install pyautogui
- time
Pyautogui
This module is used to take the screenshot , save the files and to locate the images within the screen.
Time
This module provides various time-related functions.We will use this module to provide the time in seconds after which the program can take the screenshot.
Screenshot() Function
This function returns the image object and we can pass the filename and path to it as a argument.
code
import pyautogui,time
#to take specify name of the screenshot
screenshot_name=input("enter the name")
#through this we can specify the time after which screenshot can be taken
time.sleep(1)
#screenshot will be taken and saved to the specified location
img=pyautogui.screenshot(r"E:\webtech\Screenshot"+"\\"+screenshot_name+".jpg")
#screenshot will be displayed
img.show()
Output
Comments
Post a Comment