Screen Capture Using Python

Nowadays, screen capturing is one of the common tasks which most of us are doing in our day-to-day routine and there are instances when we need to automate this task. In this article, I’ll explain about how we can automate screen capturing using Python.

To get started, first of all we need to grab all the required packages and install them.

Required packages

To automate screenshot capturing, we need to install a package named pyautogui and this can be installed using pip as shown below:

pip install pyautogui

Import packages

Once the required packages are installed, we need to import them into our code. Here we need to import two packages — one for screenshot capturing and another one is for timer as we need to capture our screen after certain seconds of our application launch. Here is the code:

import pyautogui
import time


Now we have all the packages imported, we can go ahead and make a call to required function. We will start by calling a function screenshot() and then we will save that screenshot as shown below:

image = pyautogui.screenshot()“Img.jpg”)

As per the above code, screen capturing process will start after 10 seconds. Here is the sample output:

Hope you enjoyed reading this article. If you want to haev a look at teh recording of this artcile, do check out my YouTube video here.

Similar Articles