Skip to content

Commit fadaba9

Browse files
committed
添加相应项目代码
整个项目都在MyRobot文件夹里 下载到本地的话把这个文件夹导入Eclipse内就行
1 parent 7d52c73 commit fadaba9

File tree

9 files changed

+146
-0
lines changed

9 files changed

+146
-0
lines changed

MyRobot/.classpath

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
5+
<classpathentry kind="output" path="bin"/>
6+
</classpath>

MyRobot/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>MyRobot</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.8
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=1.8
1.78 KB
Binary file not shown.
837 Bytes
Binary file not shown.
619 Bytes
Binary file not shown.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package com.zjl.FirstOne;
2+
3+
import java.awt.AWTException;
4+
import java.awt.Robot;
5+
import java.awt.event.KeyEvent;
6+
import java.util.HashMap;
7+
import java.util.Map;
8+
9+
public class Demo2 {
10+
11+
public void dosomething() {
12+
//使用map 将控制键盘的常量存起来,好方便取用。
13+
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
14+
map.put(0, 0x30);//键盘的0
15+
map.put(1, 0x31);//键盘的1
16+
map.put(2, 0x32);
17+
map.put(3, 0x33);
18+
map.put(4, 0x34);
19+
map.put(5, 0x35);
20+
map.put(6, 0x36);
21+
map.put(7, 0x37);
22+
map.put(8, 0x38);
23+
map.put(9, 0x39);
24+
25+
try {
26+
Robot robot = new Robot();
27+
robot.delay(5000);//延迟5秒供你打开编辑器
28+
29+
//让机器从0数到999
30+
for (int i = 0; i < 1000; i++) {
31+
// 个位数的处理
32+
if (i <= 9) {
33+
robot.keyPress(map.get(i));
34+
robot.keyPress(KeyEvent.VK_ENTER);
35+
}
36+
// 两位数的处理
37+
if (i > 9 && i <= 99) {
38+
int a = i / 10;// 十位
39+
int b = i % 10;// 个位
40+
robot.keyPress(map.get(a));
41+
robot.keyPress(map.get(b));
42+
robot.keyPress(KeyEvent.VK_ENTER);
43+
}
44+
// 三位数的处理
45+
if (i > 99 && i <= 999) {
46+
int a = i / 100;// 百位
47+
int b = (i % 100) / 10;// 十位
48+
int c = i % 10;// 个位
49+
robot.keyPress(map.get(a));
50+
robot.keyPress(map.get(b));
51+
robot.keyPress(map.get(c));
52+
robot.keyPress(KeyEvent.VK_ENTER);
53+
}
54+
}
55+
} catch (AWTException e) {
56+
// TODO Auto-generated catch block
57+
e.printStackTrace();
58+
}
59+
60+
}
61+
62+
public static void main(String[] args) {
63+
Demo2 demo = new Demo2();
64+
demo.dosomething();
65+
66+
}
67+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.zjl.FirstOne;
2+
3+
import java.awt.AWTException;
4+
import java.awt.Robot;
5+
import java.awt.event.KeyEvent;
6+
7+
public class DemoOne {
8+
public static void main(String[] args){
9+
try {
10+
Robot robot = new Robot();
11+
// 定义5秒的延迟以便你打开编辑器
12+
// Robot 开始写
13+
robot.delay(5000);
14+
for(int i=0;i<10;i++){
15+
robot.keyPress(KeyEvent.VK_I);
16+
robot.keyPress(KeyEvent.VK_M);
17+
robot.keyPress(KeyEvent.VK_SPACE);
18+
robot.keyPress(KeyEvent.VK_R);
19+
robot.keyPress(KeyEvent.VK_O);
20+
robot.keyPress(KeyEvent.VK_B);
21+
robot.keyPress(KeyEvent.VK_O);
22+
robot.keyPress(KeyEvent.VK_T);
23+
robot.keyPress(KeyEvent.VK_SPACE);
24+
robot.keyPress(KeyEvent.VK_ENTER);
25+
}
26+
} catch (AWTException e) {
27+
e.printStackTrace();
28+
}
29+
}
30+
31+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.zjl.FirstOne;
2+
3+
public class Test {
4+
5+
public static void main(String[] args) {
6+
int i=12;
7+
int a=i/10;
8+
System.out.println(a);
9+
int b=9;
10+
int c=8;
11+
System.out.println(b&c);
12+
}
13+
14+
}

0 commit comments

Comments
 (0)