We will see how to take screenshot using python in desktop with the help of pyautogui package this package is used of GUI automation.
First lets install the package by running the command
pip install pyautogui
Take screenshot using python
To take screenshot using python in desktop, for this import the pyautogui module, this comes with many features, but in this will be using the screenshot method.
import pyautogui
screen = pyautogui.screenshot()
screen.save("my_image.png")
This will take a screenshot of the entire screen and save it to the current working directory, to save the image in different directory change the path in save function.
Saving screenshot to folder
import pyautogui
screen = pyautogui.screenshot()
screen.save("test/image/my_image.png")
Top comments (1)
Simple and clean.