Saving screen (or Fbo) every x seconds?

Hi! I know how to save an image using key press.

However, I would need it to happen every 1 or 2 minutes without keyboard interaction. The following if statement does not save anything. Any suggestions? Warm thanks!

if (ofGetElapsedTimeMillis() % 60000 == 0){ //
      //  savedImage.save("screenshot.png");
        
        ofPixels pix;
        fbo3d.readToPixels(pix);
        ofSaveImage(pix, ofToString(ofGetFrameNum()) + ".png", OF_IMAGE_QUALITY_BEST);
    }

in header

int currTime;

in startup

currTime = ofGetElapsedTimeMillis();

in update

int delay = 60000;

if (ofGetElapsedTimeMillis() > currTime + delay){ //
      //  savedImage.save("screenshot.png");
        ofPixels pix;
        fbo3d.readToPixels(pix);
        ofSaveImage(pix, ofToString(ofGetFrameNum()) + ".png", OF_IMAGE_QUALITY_BEST);
       currTime = ofGetElapsedTimeMillis(); // update currenttime;
    }

This did the trick immediately! Thank you so much!

1 Like