Home > other >  trying to make a timer for python screenshots
trying to make a timer for python screenshots

Time:04-28

I am trying to make a script that will take a screenshot every 30 seconds.

This is what I have now:

def on_click(x, y, button, pressed):
    global path
    if pressed:
        takeScreenshoot(path)
        print('ScreenShoot Taken')

What I have tried to do.

import time
while True: # Change for a variable or a toggle
       time.sleep(30)
       takeScreenshoot(path)
       print('ScreenShoot Taken')

however now because of this the next part of my code is unreache able

CodePudding user response:

import time
while True: # Change for a variable or a toggle
       time.sleep(30)
       takeScreenshoot(path)
       print('ScreenShoot Taken')

This might be something you could do,

CodePudding user response:

Well it is simple

import time
while True:
    takeScreenshot(path)
    time.sleep(30)
    print('screenshot taken')

This simple while code that runs forever will work if you want to break it after sometime you can use an index variable instead.

  • Related