How do i take several screenshots from the same part of the display and work with these?

edited June 2015 in How To...

Hello guys

For my program it is necessary to take several screenshots (around 1 per second). With these screenshots i would like to continue working. Because i'm working with a Mac it also should be compatible with this.

When i have done my researchs i found this link which (the program, not the link) works pretty well .... on windows.

http://www.onformative.com/lab/screencapturer/

I think something in this direction would be great :)

Thanks ;)

Answers

  • you can use save (with a timer)

    or saveFrame (maybe with frameRate)

  • Thanks for this fast answer.

    I tried it out, but it doesn't show me the result i wanted. These examples take a screenshot out of the applications window. I would like to take a screenshot for example out of safari or another application except the one i generated with Processing.

    Do you know what I mean?

  • I see... can't help...

  • @Chrisir thanks for all

    maybe somebody else?

  • Answer ✓

    Perhaps this can be a starting point...

    import java.awt.Robot;
    import java.awt.Rectangle;
    import java.awt.AWTException;
    
    PImage screenshot;
    boolean smoothOn;
    int x, y;
    
    void setup() {
      size(int(displayWidth*0.85), int(displayHeight*0.85));
      frame.removeNotify();
      frame.setUndecorated(true);
    }
    
    void draw() {
      if (smoothOn) smooth();
      else noSmooth();
      screenshot();
      image(screenshot, 0, 0, width, height);
    }
    
    void screenshot() {
      try {
        Robot robot = new Robot();
        screenshot = new PImage(robot.createScreenCapture(new Rectangle(0, 0, displayWidth, displayHeight)));
      } 
      catch (AWTException e) {
      }
    }
    
    void mouseMoved() {
      x = int((float) mouseX/width * (displayWidth - width));
      y = int((float) mouseY/height * (displayHeight - height));
      x = int(x * 0.02 + frame.getLocation().x * 0.98);
      y = int(y * 0.02 + frame.getLocation().y * 0.98);
      frame.setLocation(x, y);
    }
    
    void mousePressed() {
      smoothOn = !smoothOn;
    }
    
  • Thank you very much :)

    here is the modified result:

          import java.awt.Robot;
          import java.awt.AWTException;
          import java.awt.Rectangle;
    
          PImage screenshot; 
    
          void setup() {
            size(int(displayWidth/2),int(displayHeight));
            noStroke();
            frame.removeNotify();
            frame.setUndecorated(true); 
          }
          void draw() {
            screenshot();
            image(screenshot,0,0,width,height);
          } 
    
          void screenshot() {
            try{
              Robot robot_Screenshot = new Robot();
              screenshot = new PImage(robot_Screenshot.createScreenCapture
              (new Rectangle(0,0,displayWidth/2,displayHeight)));
            }
            catch (AWTException e){ }
            frame.setLocation(displayWidth/2, 0);
          }
    
  • edited June 2015

    @amnon Is this possible to capture just the background not the processing window activity. What I mean by that is can we just focus on capturing all the activity in the background of processing window. I am asking this because when I made the application to capture and run in the full screen mode, it just capture the previously captured captured screen which is already drawn on the canvas so it feels like it is not capturing anything. Can we just capture the background activity ?

Sign In or Register to comment.