java.lang.Object | +--java.awt.Robot
Unsafe:
Robot()
Robot(GraphicsDevice screen)
java.awt.image.BufferedImage
createScreenCapture(Rectangle screenRect)
int
getAutoDelay()
Color
getPixelColor(int x,
int y)
boolean
isAutoWaitForIdle()
waitForIdle
after generating an event.
void
setAutoDelay(int ms)
void
setAutoWaitForIdle(boolean isOn)
waitForIdle
after generating an event.
void
waitForIdle()
private static final int MAX_DELAY
private java.awt.peer.RobotPeer peer
private boolean isAutoWaitForIdle
private int autoDelay
private static AWTPermission readDisplayPixelsPermission
private static AWTPermission createRobotPermission
private static final int LEGAL_BUTTON_MASK
private java.awt.image.DirectColorModel screenCapCM
public Robot() throws AWTException
AWTException - if the platform configuration does not allow
low-level input control. This exception is always thrown when
GraphicsEnvironment.isHeadless() returns true
SecurityException - if createRobot permission is not grantedjava.awt.GraphicsEnvironment#isHeadless,
SecurityManager.checkPermission(java.security.Permission),
AWTPermissionpublic Robot(GraphicsDevice screen) throws AWTException
If screen devices are reconfigured such that the coordinate system is affected, the behavior of existing Robot objects is undefined.
screen - A screen GraphicsDevice indicating the coordinate
system the Robot will operate in.
AWTException - if the platform configuration does not allow
low-level input control. This exception is always thrown when
GraphicsEnvironment.isHeadless() returns true.
IllegalArgumentException - if screen is not a screen
GraphicsDevice.
SecurityException - if createRobot permission is not grantedjava.awt.GraphicsEnvironment#isHeadless,
GraphicsDevice,
SecurityManager.checkPermission(java.security.Permission),
AWTPermissionprivate void init(GraphicsDevice screen) throws AWTException
private void checkRobotAllowed()
private void checkIsScreenDevice(GraphicsDevice device)
public void mouseMove(int x, int y)
x - X positiony - Y positionpublic void mousePress(int buttons)
buttons - the Button mask; a combination of one or more
of these flags:
InputEvent.BUTTON1_MASK
InputEvent.BUTTON2_MASK
InputEvent.BUTTON3_MASK
IllegalArgumentException - if the button mask is not a
valid combinationpublic void mouseRelease(int buttons)
buttons - the Button mask; a combination of one or more
of these flags:
InputEvent.BUTTON1_MASK
InputEvent.BUTTON2_MASK
InputEvent.BUTTON3_MASK
IllegalArgumentException - if the button mask is not a valid
combinationprivate void checkButtonsArgument(int buttons)
public void mouseWheel(int wheelAmt)
wheelAmt - number of "notches" to move the mouse wheel
Negative values indicate movement up/away from the user,
positive values indicate movement down/towards the user.public void keyPress(int keycode)
Key codes that have more than one physical key associated with them
(e.g. KeyEvent.VK_SHIFT could mean either the
left or right shift key) will map to the left key.
IllegalArgumentException - if keycode is not a valid keyjava.awt.event.KeyEventpublic void keyRelease(int keycode)
Key codes that have more than one physical key associated with them
(e.g. KeyEvent.VK_SHIFT could mean either the
left or right shift key) will map to the left key.
IllegalArgumentException - if keycode is not a valid keyjava.awt.event.KeyEventprivate void checkKeycodeArgument(int keycode)
public Color getPixelColor(int x, int y)
x - X position of pixely - Y position of pixel
public java.awt.image.BufferedImage createScreenCapture(Rectangle screenRect)
screenRect - Rect to capture in screen coordinates
IllegalArgumentException - if screenRect width and height are not greater than zero
SecurityException - if readDisplayPixels permission is not grantedSecurityManager.checkPermission(java.security.Permission),
AWTPermissionprivate static void checkValidRect(Rectangle rect)
private static void checkScreenCaptureAllowed()
private void afterEvent()
public boolean isAutoWaitForIdle()
waitForIdle
after generating an event.
waitForIdle is automatically calledpublic void setAutoWaitForIdle(boolean isOn)
waitForIdle
after generating an event.
isOn - Whether waitForIdle is automatically invokedprivate void autoWaitForIdle()
public int getAutoDelay()
public void setAutoDelay(int ms)
IllegalArgumentException - If ms is not between 0 and 60,000 milliseconds inclusiveprivate void autoDelay()
public void delay(int ms)
InterruptedExceptions that occur,
Thread.sleep() may be used instead.
ms - time to sleep in milliseconds
IllegalArgumentException - if ms is not between 0 and 60,000 milliseconds inclusivejava.lang.Thread#sleepprivate void checkDelayArgument(int ms)
public void waitForIdle()
IllegalThreadStateException - if called on the AWT event dispatching threadprivate void checkNotDispatchThread()
public String toString()