Skip to content

Screenshot() does not save any file in PyAutoGUI 0.9.54 #874

@jingcodeguy

Description

@jingcodeguy

Version: PyAutoGUI 0.9.54

The screenshot function with the filename parameter does not save any file. I have tried using both relative and absolute paths, but the result is the same—no file is saved. There are no warnings or errors indicating a failure to save the screenshot.

However, when using the returned Pillow image object, the image can be saved successfully. The current workaround is to manually save the image using the returned object.

Here is a code example demonstrating the issue:

import os
import pyautogui

print(os.getcwd())
try:
    im1 = pyautogui.screenshot('test.png')  # Does not save anything
    im1.save('test-from-pil.png')  # Successfully saves the file
    print("Screenshot saved successfully!")
except Exception as e:
    print(f"Error: {e}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions