Python offers multiple libraries to ease our work. Here we will learn how to take a screenshot using Python. Python provides a module called pyscreenshot for this task. It is only a pure Python wrapper, a thin layer over existing backends. Performance and interactivity are not important for this library.
Install the package pyscreenshot using the below command in your command prompt.
pip install pyscreenshot
Capturing Full Screen
Here we will learn the simplest way of taking a screenshot using pyscreenshot module. Here we will use the function show() to view the screenshot.
Capturing part of the screen
Here is the simple Python program to capture the part of the screen. Here we need to provide the pixel positions in the grab() function. We need to pass the coordinates in the form of a tuple.
- We need to install pillow (PIL) package before installing pyscreenshot package.
- Here show() function works as print i.e. It displays the captured screenshot.
- We need to pass the coordinates in tuple.
- We can save the screenshot to a file or PIL image memory.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- How to take screenshots using python?
- Taking input in Python
- Taking multiple inputs from user in Python
- Python VLC MediaPlayer – Taking Screenshot
- Taking input from console in Python
- Python | Create video using multiple images using OpenCV
- Python | Create a stopwatch using clock object in kivy using .kv file
- Image resizing using Seam carving using OpenCV in Python
- Visualizing Tiff File Using Matplotlib and GDAL using Python
- Python | Visualizing O(n) using Python
- Python - Read blob object in python using wand library
- Creating and updating PowerPoint Presentations in Python using python - pptx
- Circular (Oval like) button using canvas in kivy (using .kv file)
- Send mail from your Gmail account using Python
- Using Iterations in Python Effectively
- Whatsapp using Python!
- Mouse and keyboard automation using Python
- GET and POST requests using Python
- Real-Time Edge Detection using OpenCV in Python | Canny edge detection method
- Twitter Sentiment Analysis using Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.