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

2024/12/9 21:01:38

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!

Answer

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")
https://en.xdnf.cn/q/73199.html

Related Q&A

How to get pip to point to newer version of Python

I have two versions of Python installed on my centOS server. [ethan@demo ~]$ python2.6 --version Python 2.6.6 [ehtan@demo ~]$ python --version Python 2.7.3The older version (2.6) is required by some es…

Connect JS client with Python server

Im relatively new to JS and Python, so this is probably a beginners question. Im trying to send a string from a JS client to Python Server (and then send the string to another Python client).This is my…

Pip does not acknowledge Cython

I just installed pip and Python via home-brew on a fresh Mac OS installation.First of all, my pip is not installing dependencies at all - which forces me to re-run pip install tables 3 times and every …

Is it me or is pygame.key.get_pressed() not working?

okay, so I am making a basic space-ship game.I cant get rotation to work because it scrambles the bitmap, but thats for another question.Should I even use a gif? any other filetype suggestions?back t…

Find out if a python script is running in IDLE or terminal/command prompt

Is there a way to find out if the python script is running in the IDLE interpreter or the terminal?Works cross-platform if possible, or if needed a different way for each platform.Work with Python 2 a…

How to map coordinates in AxesImage to coordinates in saved image file?

I use matplotlib to display a matrix of numbers as an image, attach labels along the axes, and save the plot to a PNG file. For the purpose of creating an HTML image map, I need to know the pixel coor…

Why am I getting IOError: [Errno 13] Permission denied?

I am creating Log file for the code but I am getting the following error :[Tue Jun 11 17:22:59 2013] [error] [client 127.0.0.1] import mainLCF [Tue Jun 11 17:22:59 2013] [error] [client 127.0.0.1] …

Difference between bytearray and list

What is the difference between bytearray and for example, a list or tuple?As the name suggests, bytearray must be an array that carries byte objects. In python, it seems that bytes and str are treate…

python NameError: name anything is not defined (but it is!)

Note: Solved. It turned out that I was importing a previous version of the same module.It is easy to find similar topics on StackOverflow, where someone ran into a NameError. But most of the questions …

Python File Creation Date Rename - Request for Critique

Scenario: When I photograph an object, I take multiple images, from several angles. Multiplied by the number of objects I "shoot", I can generate a large number of images. Problem: Camera gen…