简体   繁体   English

键盘事件处理

[英]keyboard event handling

im doing the project on remote screen capturing and controlling.... i have done the screen capturing.... now i watn to make controlling....in it i want.... i have done the controlling through mouse events like mouseMove & mousePressed,mouseReleased... but the controlling by Keyboard is not done...so tell me how to do KeyBoard events on robot class and using it how to make controlling...?我在远程屏幕捕获和控制上做项目....我已经完成了屏幕捕获....现在我想进行控制....我想要......我已经通过鼠标事件完成了控制像 mouseMove 和 mousePressed,mouseReleased... 但是键盘控制还没有完成...所以请告诉我如何在机器人 class 上执行键盘事件并使用它如何进行控制...?

so suggest me the solution for how to make controlling by keyboard event.... thanks...所以建议我如何通过键盘事件进行控制的解决方案....谢谢...

TheRobot class has both keyPress and keyRelease method which can be used to cause key events on a machine. Robot class 具有keyPresskeyRelease方法,可用于在机器上引发按键事件。

The following is a little demonstration code that I tried out that launches Notepad in Windows, waits half a second and types hello into it:下面是我试过的一个小演示代码,它在 Windows 中启动记事本,等待半秒钟并在其中输入hello

Runtime.getRuntime().exec("notepad");

Robot r = new Robot();
r.setAutoDelay(100);
r.delay(500);
r.keyPress(KeyEvent.VK_H);
r.keyPress(KeyEvent.VK_E);
r.keyPress(KeyEvent.VK_L);
r.keyPress(KeyEvent.VK_L);
r.keyPress(KeyEvent.VK_O);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM