Python Taking Screenshots
Did you know that you could take screenshots using Python?
Yes, you can by the following Code:
then,
import time
import pyscreenshot
time.sleep(10)
img = pyscreenshot.grab()
img.show()
img.save("Scr1.png")
import time so we need some to get to the file where we need to take the screenshot.
import pyscreenshot for taking screenshots and you can set the seconds for time. sleep(10)
to anything, I have kept here 10 seconds.
The line "img = pyscreenshot.grab()" takes a screenshot that's why the grab, it's grabbing
a pic and the "show()" are included, and it shows the pic. If you don't want to show the taken pic,
you can exclude it.
Then the pic is saved under the name given in img.save() in your default folder path. Here I have
given Scr1 and the png as Scr1.png.
You can enjoy making the screenshot code and happily taking screenshots.
Hope you enjoyed this episode and meet you in the next one. Until then, Bye!
By the Blog Author.
0 Comments