I wrote the script below that takes part of my computer screen and shows a smaller version of it in a tiny window in the corner. I found a helpful thread that helped me remove the toolbar from the top of the window but I can’t figure out how to remove the gray border from it. Bonus points if you can tell me if there is a way to put a red square around the area of the screen I am taking from.
import processing.video.*;
import processing.serial.*;
import java.awt.Rectangle;
import java.awt.Frame;
import processing.awt.PSurfaceAWT;
import processing.awt.PSurfaceAWT.SmoothCanvas;
// https://github.com/onformative/ScreenCapturer/issues/2
import java.awt.Robot;
import java.awt.Rectangle;
import java.awt.AWTException;
Robot robot;
int errorCount=0;
PImage img;
String[] strLines;
//void settings() {
// fullScreen();
//}
void setup() {
strLines = loadStrings("C:/Users/Jesse's PC/Desktop/coordinate_writer/positions.txt");
if (errorCount > 0) exit();
//size(89, 78); // create the window
surface.setSize(89,78);
surface.setLocation(1775, 875);
try {
robot = new Robot();
}
catch (AWTException e) {
println(e);
}
}
PSurface initSurface() {
PSurface pSurface = super.initSurface();
PSurfaceAWT awtSurface = (PSurfaceAWT) surface;
SmoothCanvas smoothCanvas = (SmoothCanvas) awtSurface.getNative();
Frame frame = smoothCanvas.getFrame();
frame.setUndecorated(true);
frame.setLayout(null);
return pSurface;
}
// runs for each new frame of movie data
void movieEvent() {
// read the movie's next frame
img = new PImage(robot.createScreenCapture(new Rectangle(100, 200, 720, 640)));
}
// draw runs every time the screen is redrawn - show the movie...
void draw() {
//background(100);
movieEvent();
loadPixels();
for (int i = 1; i < (strLines.length); i++) {
pixels[i] = img.pixels[int(strLines[i])];
}
updatePixels();
}