Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pyautogui screenshot. Where does it go? How to save and find later?

I am learning from Al Sweigart's you tube video for automating the boring stuff. I got to the part of taking screenshots. He didn't really explain in his video so I tested things out. I found that it takes screenshots of the whole desktop but I don't know where they go. I can only find it when do a whole computer search and I don't know how to put it into a folder from there.

Basically I am asking how I can store the images and find those images taken by the pyautogui.screenshot() function. I am not planning on using this for anything at the moment I just want to know how to do it. I went to the pyautogui website and I didn't find anything on where to find and how to save the screenshots. Thank you in advance for your time!

like image 900
Trevor Trinh Avatar asked Jun 06 '18 22:06

Trevor Trinh


1 Answers

Here's the link to the documentation on saving screenshots in pyautogui:

https://github.com/asweigart/pyautogui#user-content-screenshot-functions

The screenshot function returns a PIL.Image. You can save that to a file with it's save method.

import pyautogui
im1 = pyautogui.screenshot()
im1.save(r"c:\path\to\my\screenshot.png")

You can also pass the path where you'd like to save the file in the screenshot method call:

import pyautogui
pyautogui.screenshot(r"c:\path\to\my\screenshot1.png")
like image 77
clockwatcher Avatar answered Sep 20 '22 23:09

clockwatcher