asweigart / pyautogui

A cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard.
BSD 3-Clause "New" or "Revised" License
10.22k stars 1.24k forks source link

Program crash when using pyautogui.screenshot with the args 'my_screenshot.png' sometimes #727

Open CocaNoIce opened 2 years ago

CocaNoIce commented 2 years ago

When I using pyautogui.screenshot('my_screenshot.png'), the program will crash sometimes with the errorn 22 Invalid argument or errorn 13 Permission denied. But this line can run successfully in most of the time, could you give me some idea?

Do I need to delete the previous 'my_screenshot.png' before screenshot('my_screenshot.png')? But during my using screenshot, I find screenshot() can save the latest picture even if the same name file exist.

Looking forward to your reply, thanks a lot.

Log_message