| Posted in JAVA技术 @ 2007/09/24 11:55 by 博爱老头
     java里面,经常看api的人不难发现,在java.awt包下,有个非常有意思也有用的类Robot!它可以模拟键盘和鼠标的一切动作,看看huachitypying
     原api
     public class Robot
                 extends Object

      This class is used to generate native system input events for the purposes of test automation, self-running demos, and other applications where control of the mouse and keyboard is needed. The primary purpose of Robot is to facilitate automated testing of Java platform implementations.

      Using the class to generate input events differs from posting events to the AWT event queue or AWT components in that the events are generated in the platform's native input queue. For example, Robot.mouseMove will actually move the mouse cursor instead of just generating mouse move events.

      Note that some platforms require special privileges or extensions to access low-level input control. If the current platform configuration does not allow input control, an AWTException will be thrown when trying to construct Robot objects. For example, X-Window systems will throw the exception if the XTEST 2.2 standard extension is not supported (or not enabled) by the X server.

      Applications that use Robot for purposes other than self-testing should handle these error conditions gracefully.

      下面是写的一个DEMO:


哈哈。。。慢慢研究吧。。。zansmoke

作者:博爱老头@博爱老头的草屋
地址:http://www.icnote.com/post/73/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!


最新日志 随机日志 综合排行
  • 钻石壁纸+一首经典老歌
  • 国内3G牌照正式发放 扫盲...
  • 用java将本地化语言转换...
  • ThrottleLock ...
  • 新年快乐
  • [music] Sisse...
  • 可口的三文鱼 你不知道的故...
  • [music] 听歌时间-...
  • 平安夜 杂记
  • DOPOD S900 官方...
  • [music]好冷。。音乐...
  • 再度强化!《星际争霸2》坦...
  • 最新《星际争霸2》对战视频
  • 美军B-2隐形轰炸机在关岛...
  • 纽约艺术博览会之"...
  • 防空警报把我吵醒了
  • 测试显示微软Office ...
  • 3Com撤回安全评估申请,...
  • 神七进入待发射状态 附轨道...
  • 谈谈看奥运
  • java  msn机器人
  • JSTL详解
  • 终于在fc6下把TL-WN...
  • eXtremeTable的...
  • DES加密、解密字符串算法...
  • IDC sees $49 ...
  • eclipse 安装pyt...
  • 放假早起,听到熟悉经典的音...
  • 测试Issue管理利器JI...
  • Waiting for f...
  • 文章来自: 本站原创
    Tags: ,
    发表评论
    昵称
    密码 [ 游客无需密码 ]
    电邮
    网址
    打开HTML 打开UBB 打开表情 隐藏 记住我