当前位置:首页 » 编程语言 » javarobot

javarobot

发布时间: 2024-06-02 21:02:09

① 濡备綍鐢↗ava Robot𨱒ュ疄鐜版坠链烘带鍒剁数鑴戯纻

java涓鐢≧obot绫绘带鍒堕紶镙囧拰阌鐩樼殑鏂规硶
http://www.c114.net ( 2007/8/17 00:00 )

Java.awt.Robot 绫荤敤浜庢带鍒堕紶镙囧拰阌鐩樸备竴镞︿綘寰楀埌杩欑嶆带鍒讹纴浣犺兘澶熼氲繃浣犵殑Java浠g爜锅氢笌榧犳爣鍜岄敭鐩树换浣旷被鍨嬬殑镎崭綔銆傝繖涓绫婚氩父鐢ㄤ簬镊锷ㄥ寲娴嬭瘯銆备笅闱㈢殑浠g爜镙蜂緥灏嗗悜鎭ㄥ𪾢绀篟obot绫诲备綍澶勭悊阌鐩树簨浠躲傚傛灉浣犺繍琛屾や唬镰侊纴骞舵墦寮notepad锛屾偍灏嗗湪notepad涓鐪嫔埌HI CAOER.璧跺揩璇曚竴璇曞惂銆

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
public class RobotExp {
public static void main(String[] args) {
try {
Robot robot = new Robot();
//瀹氢箟5绉掔殑寤惰繜浠ヤ究浣犳墦寮notepad
// Robot 寮濮嫔啓
robot.delay(5000);
robot.keyPress(KeyEvent.VK_H);
robot.keyPress(KeyEvent.VK_I);
robot.keyPress(KeyEvent.VK_SPACE);
robot.keyPress(KeyEvent.VK_C);
robot.keyPress(KeyEvent.VK_A);
robot.keyPress(KeyEvent.VK_O);
robot.keyPress(KeyEvent.VK_E);
robot.keyPress(KeyEvent.VK_R);
} catch (AWTException e) {
e.printStackTrace();
}
}
}

缃戝弸瀹屽杽浜嗕互涓娄唬镰侊细

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.io.IOException;

public class RobotExp {
public static void pressKey(Robot robot, int keyvalue) {
robot.keyPress(keyvalue);
robot.keyRelease(keyvalue);
}
public static void pressKeyWithShift(Robot robot, int keyvalue) {
robot.keyPress(KeyEvent.VK_SHIFT);
robot.keyPress(keyvalue);
robot.keyRelease(keyvalue);
robot.keyRelease(KeyEvent.VK_SHIFT);
}
public static void closeApplication(Robot robot) {
// pressKey(robot, KeyEvent.VK_ALT);
// pressKey(robot, KeyEvent.VK_F4);
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_F4);
robot.keyRelease(KeyEvent.VK_ALT);
robot.keyRelease(KeyEvent.VK_F4);
//for linux.
// robot.keyPress(KeyEvent.VK_ALT);
// robot.keyPress(KeyEvent.VK_W);
// robot.keyRelease(KeyEvent.VK_ALT);
// robot.keyRelease(KeyEvent.VK_W);
robot.keyPress(KeyEvent.VK_N);
robot.keyRelease(KeyEvent.VK_N);
}
public static void main(String[] args) throws IOException {
try {
Robot robot = new Robot();
Runtime.getRuntime().exec("notepad");
// For linux.
//Runtime.getRuntime().exec("gedit");
//瀹氢箟5绉掔殑寤惰繜浠ヤ究浣犳墦寮notepad 鍝埚搱
// Robot 寮濮嫔啓
robot.delay(3000);
for (int i = 0; i < 100; i++) {
pressKeyWithShift(robot, KeyEvent.VK_H);
pressKey(robot, KeyEvent.VK_I);
pressKey(robot, KeyEvent.VK_SPACE);
//pressKeyWithShift(robot, KeyEvent.VK_H);
pressKeyWithShift(robot, KeyEvent.VK_I);
pressKey(robot, KeyEvent.VK_SPACE);
pressKey(robot, KeyEvent.VK_A);
pressKey(robot, KeyEvent.VK_M);
pressKey(robot, KeyEvent.VK_SPACE);
pressKey(robot, KeyEvent.VK_T);
pressKey(robot, KeyEvent.VK_H);
pressKey(robot, KeyEvent.VK_E);
pressKey(robot, KeyEvent.VK_SPACE);
pressKey(robot, KeyEvent.VK_J);
pressKey(robot, KeyEvent.VK_A);
pressKey(robot, KeyEvent.VK_V);
pressKey(robot, KeyEvent.VK_A);
pressKey(robot, KeyEvent.VK_SPACE);
pressKey(robot, KeyEvent.VK_R);
pressKey(robot, KeyEvent.VK_O);
pressKey(robot, KeyEvent.VK_B);
pressKey(robot, KeyEvent.VK_O);
pressKey(robot, KeyEvent.VK_T);
// VK_ENTER
pressKey(robot, KeyEvent.VK_ENTER);
//pressKey(robot, KeyEvent.);
}
closeApplication(robot);
//robot.keyPress(KeyEvent.VK_SPACE);
} catch (AWTException e) {
e.printStackTrace();
}
}
}

𨱒ユ簮锛氲禌杩缃戞妧链绀惧尯 浣滆咃细dxaw
浣滆咃细 𨱒ユ簮锛 0

热点内容
入门反编译 发布:2025-01-18 13:13:07 浏览:845
蒙皮算法 发布:2025-01-18 12:57:53 浏览:549
常用的r语言编译器 发布:2025-01-18 12:55:05 浏览:199
同人志解压密码 发布:2025-01-18 12:55:05 浏览:876
qq密码不记得怎么办 发布:2025-01-18 12:48:22 浏览:448
安卓系统停用怎么办 发布:2025-01-18 12:35:49 浏览:260
五菱宏光星辰哪个配置最值得买 发布:2025-01-18 12:29:43 浏览:595
鸿蒙系统为什么完美兼容安卓应用 发布:2025-01-18 12:16:02 浏览:856
数分转算法 发布:2025-01-18 12:08:31 浏览:612
iphone硬件为什么比安卓更好 发布:2025-01-18 12:08:29 浏览:822