Mar-15-2026, 02:14 PM
I have the following code from a video course that produces a screenshot image on the monitor and saves a file with a valid name and extension but when you go to Explorer in Windows 11 and click on the file it says the file has a bad format. Thoughts?
import time
import pyautogui
def screenshot():
name = int(round(time.time() * 1000))
name = 'C:/Users/jkres/AppData/Local/Programs/Python/Python312/Programs/test/{}.png'.format(name)
time.sleep(2)
img = pyautogui.screenshot(name)
img.show()
img.save(name)
screenshot()
