-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImpressGirl.java
113 lines (89 loc) · 2.9 KB
/
ImpressGirl.java
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.util.Scanner;
public class ImpressGirl {
Robot robot = new Robot();
Scanner scanner;
public static void main(String[] args) throws AWTException {
new ImpressGirl();
}
public ImpressGirl() throws AWTException {
scanner = new Scanner(System.in);
String get;
System.out.print("\nType 'notepad' to go ahead (System will crash if you will type something else) :- ");
get = scanner.next();
robot.setAutoDelay(50);
robot.setAutoWaitForIdle(true);
robot.delay(100);
robot.keyPress(KeyEvent.VK_WINDOWS);
robot.delay(500);
type("R");
robot.delay(500);
robot.keyRelease(KeyEvent.VK_WINDOWS);
robot.delay(500);
type(get);
robot.delay(1000);
type(KeyEvent.VK_ENTER);
robot.delay(5000);
type("Hello to everyone...!!");
type(KeyEvent.VK_ENTER);
robot.delay(50);
type(KeyEvent.VK_ENTER);
robot.delay(100);
type("I want to tell you something...");
type(KeyEvent.VK_ENTER);
type(KeyEvent.VK_ENTER);
robot.delay(100);
type("Express your love here....");
type(KeyEvent.VK_ENTER);
type(KeyEvent.VK_ENTER);
robot.delay(100);
type("I love you and I will be with you forever.");
type(KeyEvent.VK_ENTER);
type(KeyEvent.VK_ENTER);
robot.delay(100);
type("Will you be my valentine, Will you marry me");
robot.keyPress(KeyEvent.VK_SHIFT);
type(KeyEvent.VK_SLASH);
robot.keyRelease(KeyEvent.VK_SHIFT);
type(KeyEvent.VK_ENTER);
type(KeyEvent.VK_ENTER);
type("I will wait for you... Forever..");
robot.delay(500);
robot.keyPress(KeyEvent.VK_CONTROL);
type("s");
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.delay(1000);
type("pratik");
robot.delay(500);
type(KeyEvent.VK_ENTER);
robot.delay(1000);
type("y");
robot.delay(1000);
robot.delay(1000);
type(KeyEvent.VK_ALT);
robot.delay(1000);
type("f");
robot.delay(1000);
type("x");
type("n");
System.exit(0);
}
private void type(int i) {
robot.delay(50);
robot.keyPress(i);
robot.keyRelease(i);
}
private void type(String s) {
byte[] bytes = s.getBytes();
for (byte b: bytes) {
int code = b;
// key-code only handles [A-Z] (which is ASCII decimal [65-90])
if (code > 96 && code < 123) code = code - 32;
robot.delay(40);
robot.keyPress(code);
robot.keyRelease(code);
}
}
}