Monday 3 October 2016

Python program to take screen shot

Basically we use "print screen" button in keyboard for many purposes.

Lets imagine a situation where we have to take a screen shot for every 10 mins or for a specific time and save the images. Then in order to do the task we need to do a repetitive work for every 10 mins or specific time.

In order to avoid this kind of situations we use a automation script to do this task.

In this post i will tell how to do this by using python scripting.

Before going further you need to be ready with following setup:

  • Python 2.7 version installation.
  • pip installation.


For doing this you can see my posts or you can watch them on my you tube channel:
https://www.youtube.com/playlist?list=PLLoBlNaX1gGMn3Xc24TcV56YQfwPSsh9U

Modules to be installed for this task:
pyscreenshot and pillow

These modules can be installed by using "pip".

Open command prompt and go to the path where pip is installed or recognised and run the following commands for installation and integration of them in the python,

pip install pyscreenshot
pip install pillow

Now open python IDLE in the start -> python 2.7 -> IDLE.

import pyscreenshot

check the functionalities of the module by using dir command on it,

dir(pyscreenshot)



now in order to capture the screen use the command,

a = pyscreenshot.grab()

Now in order to save this capture with respective name and format use the following command,

a.save("screenshot.png","png")

Now,
The screen shot is stored in current working directory.
Similarly you can use other formats for saving it.

Note:
Keep checking this site for further update of complete code. 

No comments:

Post a Comment