# Screenshot and webcam picture at same time every 6 minutes

**URL:** <https://discourse.processing.org/t/screenshot-and-webcam-picture-at-same-time-every-6-minutes/27525>\
**Category:** Libraries\
**Created:** [February 1, 2021, 2:42pm UTC](https://discourse.processing.org/t/screenshot-and-webcam-picture-at-same-time-every-6-minutes/27525 "2021-02-01T14:42:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![saskia\_NL](https://avatars.discourse-cdn.com/v4/letter/s/8baadc/32.png) [@saskia\_NL](https://discourse.processing.org/u/saskia_NL)\
**Post date:** [February 1, 2021, 2:42pm UTC](https://discourse.processing.org/t/screenshot-and-webcam-picture-at-same-time-every-6-minutes/27525/1 "2021-02-01T14:42:54Z")

</div>

Hi,  
I’m looking for a way to take a screenshot of my desktop with all it’s open tabs while at the same time taking a picture with the build-in webcam. I would like to capture these 2 images automatically every 6 minutes.  
Can you help me achieve this or point me in the right direction?  
I am very new to processing, but looking forward to learning more!  
Thanks!

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [February 3, 2021, 11:56pm UTC](https://discourse.processing.org/t/screenshot-and-webcam-picture-at-same-time-every-6-minutes/27525/2 "2021-02-03T23:56:03Z")

</div>

Hi,

- To save a screenshot from Processing, there’s no built-in functions to do that. However you can use Java’s awt library as described in this forum post by @GoToLoop :

```auto
/**
 * Robot Screenshots (v2.23)
 * by Amnon (2014/Nov/11)
 * mod GoToLoop
 *
 * Forum.Processing.org/two/discussion/8025/
 * take-a-screen-shot-of-the-screen#Item_8
 */
 
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.AWTException;
 
PImage screenshot;
Rectangle dimension;
Robot robot;
 
void setup() {
  size(1280, 720);
 
  smooth(3);
  frameRate(.5);
 
  colorMode(RGB);
  imageMode(CORNER);
  background((color) random(#000000));
 
  screenshot = createImage(displayWidth, displayHeight, ARGB);
  dimension = new Rectangle(displayWidth, displayHeight);
 
  try {
    robot = new Robot();
  }
  catch (AWTException cause) {
    println(cause);
    exit();
  }
}
 
void draw() {
  image(grabScreenshot(screenshot, dimension, robot), 0, 0, width, height);
}
 
static final PImage grabScreenshot(PImage img, Rectangle dim, Robot bot) {
  //return new PImage(bot.createScreenCapture(dim));
 
  bot.createScreenCapture(dim).getRGB(0, 0
    , dim.width, dim.height
    , img.pixels, 0, dim.width);
 
  img.updatePixels();
  return img;
}

```

> **[Processing 2.x and 3.x Forum](https://forum.processing.org/two/discussion/8025/take-a-screen-shot-of-the-screen#Comment_30015)**
>
> Processing is an electronic sketchbook, a language and a worldwide community. This is its forum.

- To read an image from the webcam, you need to use the [video library](https://processing.org/reference/libraries/video/index.html). You can check out this example :

- Then to save an image on the disk, you need to call the [`PImage.save()`](https://processing.org/reference/PImage_save_.html) function on your image.

- Finally for the time, you can take a look at the [`millis()`](https://processing.org/reference/millis_.html) function that gives you the time in milliseconds since the beginning of the sketch.

Have fun!
