DEV Community

Max
Max

Posted on

6 3 2 3 1

How to take Screenshot using Python

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
Enter fullscreen mode Exit fullscreen mode

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")
Enter fullscreen mode Exit fullscreen mode

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")
Enter fullscreen mode Exit fullscreen mode

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (1)

Collapse
 
shadow_b profile image
Bhimashankar Patil

Simple and clean.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay