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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started