-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaxwell.java
More file actions
63 lines (59 loc) · 1.94 KB
/
Copy pathMaxwell.java
File metadata and controls
63 lines (59 loc) · 1.94 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
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
import java.lang.Thread;
import java.awt.Robot;
import java.awt.event.InputEvent;
import java.awt.Color;
class Maxwell {
private static int x = 1138;
private static int y = 581;
private static int R = 130;
private static int P = 487;
public static void main(String[] args) {
Robot rob = null;
try {
rob = new Robot();
} catch (java.awt.AWTException awe) {
awe.printStackTrace();
}
rob.setAutoDelay(25);
releaseAtFourtyFive(rob);
}
private static void releaseAtFourtyFive(Robot rob) {
//Drag pendulum
rob.mouseMove(x,y);
rob.mousePress(InputEvent.BUTTON1_MASK);
rob.mouseRelease(InputEvent.BUTTON1_MASK);
rob.mousePress(InputEvent.BUTTON1_MASK);
Thread threader = new Thread() {
public void run() {
for (int i = 0; i < R; i++) {
x--;
y -= i%2;
rob.mouseMove(x,y);
}
}
};
threader.start();
try {
while(threader.isAlive()) { Thread.sleep(1000); }
} catch (InterruptedException ie) {
ie.printStackTrace();
}
rob.mouseRelease(InputEvent.BUTTON1_MASK);
System.out.println("Button released");
//Start timer
rob.mouseMove(924,563);
rob.mousePress(InputEvent.BUTTON1_MASK);
rob.mouseRelease(InputEvent.BUTTON1_MASK);
//Watch for period trail
Color color = new Color(255,255,255);
do {
color = rob.getPixelColor(1130,P);
} while (color.getRed() > 198 && color.getGreen() > 198);
//Stop timer
rob.mousePress(InputEvent.BUTTON1_MASK);
rob.mouseRelease(InputEvent.BUTTON1_MASK);
rob.mouseMove(1133,633);
rob.mousePress(InputEvent.BUTTON1_MASK);
rob.mouseRelease(InputEvent.BUTTON1_MASK);
}
}