import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.RandomAccessFile;
import java.util.RandomAccess;
import javax.imageio.ImageIO;
public class Start implements Runnable{
/**
* @param args
*/
public static void main(String[] args)
{
System.out.println("Start");
Start start = new Start();
Thread thread = new Thread(start);
thread.start();
}
public void run()
{
try {
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension screenSize = toolkit.getScreenSize();
Rectangle rectangle = new Rectangle(0, 0,
screenSize.width,
screenSize.height);
Robot robot = new Robot();
while(1==1)
{
byte[] tmp = new byte[50000];
byte[] tmp2 = new byte[50000];
BufferedImage buffimg = robot.createScreenCapture(rectangle);
ImageIO.write(buffimg, "jpg", new File("d:\\data\\bild.jpg"));
Thread.sleep(100);
ImageIO.write(buffimg, "jpg", new File("d:\\data\\bild2.jpg"));
RandomAccessFile rafile = new RandomAccessFile(new File("d:\\bild.jpg"),"r");
RandomAccessFile rafile2 = new RandomAccessFile(new File("d:\\bild2.jpg"),"r");
rafile.readFully(tmp);
rafile2.readFully(tmp2);
if(new String(tmp).equals(new String(tmp2)))
System.out.println("gleich");
else
System.out.println("geändert");
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}