当前位置:首页 » 编程语言 » 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

热点内容
crm客户管理系统源码 发布:2024-11-27 07:59:26 浏览:363
匠辰app安卓在哪里下载 发布:2024-11-27 07:47:12 浏览:731
sql表操作 发布:2024-11-27 07:46:31 浏览:813
云顶之脚本 发布:2024-11-27 07:45:37 浏览:658
编程箴言pdf 发布:2024-11-27 07:43:59 浏览:369
传奇脚本经验卷 发布:2024-11-27 07:43:16 浏览:679
我的世界手机版国际服怎么创建自己的服务器 发布:2024-11-27 07:38:19 浏览:693
java中立方 发布:2024-11-27 07:07:05 浏览:484
编程Q1 发布:2024-11-27 06:52:29 浏览:459
版本编译验证 发布:2024-11-27 06:46:43 浏览:938