我们正在为残疾人制作模拟器。在这个应用程序中有一个桌面区域,我们目前正在进行测试。如何以编程方式生成1次鼠标单击,并在鼠标单击1次之后立即生成鼠标单击?点击之间的时间是100 ms。
编辑
这是你建议的代码。
import java.awt.Robot;
import java.io.Console;
import javax.swing.Timer;
public class Start {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Timer timer = new Timer(100, new ActionListener() {
private final Robot robot = new Robot();
public void actionPerformed(ActionEvent evt) {
robot.mousePress(1);
robot.mouseRelease(1);
robot.keyPress(KeyEvent.VK_A);
robot.mouseMove(55, 145);
}
});
}
}快照中显示了5个错误。

发布于 2011-10-20 09:18:44
看看Robot类,它可以以编程方式生成鼠标单击和键盘笔画。您可以将此与Swing Timer类结合使用,以定期生成这些事件。
Timer timer = new Timer(100, new ActionListener() {
private final Robot robot = new Robot();
public void actionPerformed(ActionEvent evt) {
robot.mousePress(1);
robot.mouseRelease(1);
robot.keyPress(KeyEvent.VK_A);
}
});发布于 2011-10-20 09:19:07
看看机器人类。
https://stackoverflow.com/questions/7833670
复制相似问题