-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrobo.java
More file actions
35 lines (35 loc) · 1.11 KB
/
Copy pathrobo.java
File metadata and controls
35 lines (35 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Java program to demonstrate working of Robot
// class. This program is for Windoes. It opens
// notepad and types a message.
import java.awt.*;
import java.io.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
public class robo
{
public static void main() throws IOException,
AWTException, InterruptedException
{
try {
Thread.sleep(5000);
}
catch (InterruptedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
Rectangle rec=new Rectangle(738,209,(22),(18));
Robot robot = new Robot();
String path="D://Shot1.jpg";
// Press keys using robot. A gap of
// of 500 mili seconds is added after
// every key press
BufferedImage img=robot.createScreenCapture(rec);
ImageIO.write(img, "jpg", new File(path));
System.out.println("Screenshot saved");
robot.mouseMove(1360,21);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
}