You might want to save this little code as “my_program.py” and schedule it with Windows so it takes screenshots of the computer at predefined intervals such as every hour or minute.
In that case, you will need the filename of the screenshot to be different each time.
One way to tackle this is using the exact time of the screenshot in the filename.
This can easily be done with time library: