I have this section of Python code which works correctly
import mss
import mss.tools
import datetime
import time
with mss.mss() as sct:
monitor = sct.monitors[1]
timestr = time.strftime("%Y%m%d-%H%M%S")
sct.compression_level = -1
output = "d:/screen/work/" + (timestr) + ".png".format(**monitor)
sct_img = sct.grab(monitor)
mss.tools.to_png(sct_img.rgb, sct_img.size, output=output)
print(output)
I would add a no end cycle/loop with a 10 second delay between each loop, so I added a while in this way
import mss
import mss.tools
import datetime
import time
while count < 100000000:
with mss.mss() as sct:
monitor = sct.monitors[1]
timestr = time.strftime("%Y%m%d-%H%M%S")
sct.compression_level = -1
output = "d:/screen/work/" + (timestr) + ".png".format(**monitor)
sct_img = sct.grab(monitor)
mss.tools.to_png(sct_img.rgb, sct_img.size, output=output)
print(output)
time.sleep(10)
count += 1
but it returns this
IndentationError: unindent does not match any outer indentation level
How to add a loop in my code ?
with mss.mss() as sct:as well, so if this code is working you didn't post the actual code, and we can only guess (although a very good one) what is the problem.