Question: Help with Java! Can someone check my code What I am trying to accomplish is the user inputs their workstation number and what the issue
Help with Java! Can someone check my code What I am trying to accomplish is the user inputs their workstation number and what the issue is. Then the code will execute a screen capture. This is what I have so far
import java.awt.*;
import java.awt.image.RenderedImage;
import java.io.File;
import java.util.Scanner;
import javax.imageio.ImageIO;
public class takeScreenCapture { public static void main() throws Exception { Scanner input = new Scanner(System.in);
System.out.print("Hello Enter Your Issue and Workstation Number: ");
String wsNumber = input.next();
Robot robot = new Robot();
// This should save the screen capture in the appropriate path//
String path = "C:\\Users\\Public\\Pictures\\Screenshots\\Workstation" + wsNumber + ".jpg"; /* Used to get ScreenSize and capture image */
Rectangle capture;
capture = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
BufferedImage Image = (BufferedImage) robot.createScreenCapture(capture); ImageIO.write((RenderedImage) Image, "jpg", new File(path));
System.out.println("Screenshot saved");
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
