关于Java中生成输入的Robot类用法总结
来源:互联网 发布:淘宝质检报告处罚 编辑:程序博客网 时间:2024/05/02 04:59
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.
Constructor Summary
Robot()
Constructs a Robot object in the coordinate system of the primary screen.
Robot(GraphicsDevice screen)
Creates a Robot for the given screen device.
Method Summary
(传说中的截屏,保存在BufferedImage里,如果了解过AWT里的画图对BufferedImage一定不陌生) (类似于画图里面的采色器) (移动鼠标到指定位置) (鼠标按键按下的事件,参数是鼠标上的哪一个键,有左键右键和滑轮) (同上,不解释) (滚动滑轮,参数的正负代表向上还是向下,参数的值代表滑槽转了几下) BufferedImage
createScreenCapture(Rectangle screenRect)
Creates an image containing pixels read from the screen. void
delay(int ms)
Sleeps for the specified time.(和线程里面的睡眠效果一样,只不过现在对象变成了输入端的机器人) int
getAutoDelay()
Returns the number of milliseconds this Robot sleeps after generating an event. Color
getPixelColor(int x, int y)
Returns the color of a pixel at the given screen coordinates. boolean
isAutoWaitForIdle()
Returns whether this Robot automatically invokes waitForIdle
after generating an event. void
keyPress(int keycode)
Presses a given key.(产生一个类似于你按了一个键的效果) void
keyRelease(int keycode)
Releases a given key.(同上,只不过这回变成了释放) void
mouseMove(int x, int y)
Moves mouse pointer to given screen coordinates. void
mousePress(int buttons)
Presses one or more mouse buttons. void
mouseRelease(int buttons)
Releases one or more mouse buttons. void
mouseWheel(int wheelAmt)
Rotates the scroll wheel on wheel-equipped mice. void
setAutoDelay(int ms)
Sets the number of milliseconds this Robot sleeps after generating an event. void
setAutoWaitForIdle(boolean isOn)
Sets whether this Robot automatically invokes waitForIdle
after generating an event. String
toString()
Returns a string representation of this Robot. void
waitForIdle()
Waits until all events currently on the event queue have been processed.
04:41:39
- 关于Java中生成输入的Robot类用法总结
- Java中输入的用法
- 总结java.awt.Robot类
- Robot Framework用法总结
- 关于Java中final关键字的用法总结
- 关于Java中static和final关键字的用法总结
- 算法4中关于输入的总结
- Java中Arrays类用法的总结
- 总结一下Meta的用法及robot.txt的讲解
- c++中关于return的用法总结
- c++中关于return的用法总结
- c++中关于return的用法总结
- 关于Matlab中括号用法的总结
- IOS中关于Block的用法总结
- Java关于Properties用法的总结(一)
- C/C++中输入带空格的字符串用法总结
- C/C++中输入带空格的字符串用法总结
- 如何在Java中使用Robot类
- PHP学习建议
- PHP学习建议
- C语言中返回字符串函数的四种实现方法
- 程序员面试题精选100题(07)-翻转句子中单词的顺序
- Javascript浏览器内核感知,非userAgent,准确率极高;
- 关于Java中生成输入的Robot类用法总结
- Signal
- 12/29/2010 geek日志@Android
- php之samrty模板配置
- Flex视频聊天踢人问题
- 【读书笔记】人生使用说明书
- csdn的mySQL数据库出了点问题
- web编程之html篇(框架)
- /LGC物理引擎/彻底解放CPU的物理卡深入剖析