|
Modifier and Type |
Method and Description |
|
createScreenCapture |
java.awt.image.BufferedImage createScreenCapture(Rectangle screenRect)
Creates an image containing pixels read from the screen.
public java.awt.image.BufferedImage createScreenCapture( Rectangle screenRect)
-
Creates an image containing pixels read from the screen. This image does
not include the mouse cursor.
- Parameters:
screenRect - Rect to capture in screen coordinates
- Returns:
- The captured image
- Throws:
java.lang.IllegalArgumentException - if screenRect width and height are not greater than zero
java.lang.SecurityException - if readDisplayPixels permission is not granted- See Also:
SecurityManager.checkPermission(java.security.Permission) ,
AWTPermission
|
|
delay |
void delay(int ms)
Sleeps for the specified time.
public void delay(int ms)
-
Sleeps for the specified time.
To catch any InterruptedException s that occur,
Thread.sleep() may be used instead.
- Parameters:
ms - time to sleep in milliseconds
- Throws:
java.lang.IllegalArgumentException - if ms is not between 0 and 60,000 milliseconds inclusive- See Also:
Thread.sleep(long)
|
|
getAutoDelay |
int getAutoDelay()
Returns the number of milliseconds this Robot sleeps after generating an event.
public int getAutoDelay()
-
Returns the number of milliseconds this Robot sleeps after generating an event.
|
|
getPixelColor |
Color getPixelColor(int x,
int y)
Returns the color of a pixel at the given screen coordinates.
public Color getPixelColor(int x,
int y)
-
Returns the color of a pixel at the given screen coordinates.
- Parameters:
x - X position of pixely - Y position of pixel
- Returns:
- Color of the pixel
|
|
isAutoWaitForIdle |
boolean isAutoWaitForIdle()
Returns whether this Robot automatically invokes waitForIdle
after generating an event.
public boolean isAutoWaitForIdle()
-
Returns whether this Robot automatically invokes waitForIdle
after generating an event.
- Returns:
- Whether
waitForIdle is automatically called
|
|
keyPress |
void keyPress(int keycode)
Presses a given key.
public void keyPress(int keycode)
-
Presses a given key. The key should be released using the
keyRelease method.
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.
- Parameters:
keycode - Key to press (e.g. KeyEvent.VK_A )
- Throws:
java.lang.IllegalArgumentException - if keycode is not
a valid key- See Also:
keyRelease(int) ,
KeyEvent
|
|
keyRelease |
void keyRelease(int keycode)
Releases a given key.
public void keyRelease(int keycode)
-
Releases a given key.
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.
- Parameters:
keycode - Key to release (e.g. KeyEvent.VK_A )
- Throws:
java.lang.IllegalArgumentException - if keycode is not a
valid key- See Also:
keyPress(int) ,
KeyEvent
|
|
mouseMove |
void mouseMove(int x,
int y)
Moves mouse pointer to given screen coordinates.
public void mouseMove(int x,
int y)
-
Moves mouse pointer to given screen coordinates.
- Parameters:
x - X positiony - Y position
|
|
mousePress |
void mousePress(int buttons)
Presses one or more mouse buttons.
public void mousePress(int buttons)
-
Presses one or more mouse buttons. The mouse buttons should
be released using the mouseRelease(int) method.
- Parameters:
buttons - the Button mask; a combination of one or more
mouse button masks.
It is allowed to use only a combination of valid values as a buttons parameter.
A valid combination consists of InputEvent.BUTTON1_DOWN_MASK ,
InputEvent.BUTTON2_DOWN_MASK , InputEvent.BUTTON3_DOWN_MASK
and values returned by the
InputEvent.getMaskForButton(button) method.
The valid combination also depends on a
Toolkit.areExtraMouseButtonsEnabled() value as follows:
- If support for extended mouse buttons is
disabled by Java
then it is allowed to use only the following standard button masks:
InputEvent.BUTTON1_DOWN_MASK , InputEvent.BUTTON2_DOWN_MASK ,
InputEvent.BUTTON3_DOWN_MASK .
- If support for extended mouse buttons is
enabled by Java
then it is allowed to use the standard button masks
and masks for existing extended mouse buttons, if the mouse has more then three buttons.
In that way, it is allowed to use the button masks corresponding to the buttons
in the range from 1 to MouseInfo.getNumberOfButtons() .
It is recommended to use the InputEvent.getMaskForButton(button)
method to obtain the mask for any mouse button by its number.
The following standard button masks are also accepted:
InputEvent.BUTTON1_MASK
InputEvent.BUTTON2_MASK
InputEvent.BUTTON3_MASK
However, it is recommended to use InputEvent.BUTTON1_DOWN_MASK ,
InputEvent.BUTTON2_DOWN_MASK , InputEvent.BUTTON3_DOWN_MASK instead.
Either extended _DOWN_MASK or old _MASK values
should be used, but both those models should not be mixed.
- Throws:
java.lang.IllegalArgumentException - if the buttons mask contains the mask for extra mouse button
and support for extended mouse buttons is disabled by Java
java.lang.IllegalArgumentException - if the buttons mask contains the mask for extra mouse button
that does not exist on the mouse and support for extended mouse buttons is enabled by Java- See Also:
mouseRelease(int) ,
InputEvent.getMaskForButton(int) ,
Toolkit.areExtraMouseButtonsEnabled() ,
MouseInfo.getNumberOfButtons() ,
MouseEvent
|
|
mouseRelease |
void mouseRelease(int buttons)
Releases one or more mouse buttons.
public void mouseRelease(int buttons)
-
Releases one or more mouse buttons.
- Parameters:
buttons - the Button mask; a combination of one or more
mouse button masks.
It is allowed to use only a combination of valid values as a buttons parameter.
A valid combination consists of InputEvent.BUTTON1_DOWN_MASK ,
InputEvent.BUTTON2_DOWN_MASK , InputEvent.BUTTON3_DOWN_MASK
and values returned by the
InputEvent.getMaskForButton(button) method.
The valid combination also depends on a
Toolkit.areExtraMouseButtonsEnabled() value as follows:
- If the support for extended mouse buttons is
disabled by Java
then it is allowed to use only the following standard button masks:
InputEvent.BUTTON1_DOWN_MASK , InputEvent.BUTTON2_DOWN_MASK ,
InputEvent.BUTTON3_DOWN_MASK .
- If the support for extended mouse buttons is
enabled by Java
then it is allowed to use the standard button masks
and masks for existing extended mouse buttons, if the mouse has more then three buttons.
In that way, it is allowed to use the button masks corresponding to the buttons
in the range from 1 to MouseInfo.getNumberOfButtons() .
It is recommended to use the InputEvent.getMaskForButton(button)
method to obtain the mask for any mouse button by its number.
The following standard button masks are also accepted:
InputEvent.BUTTON1_MASK
InputEvent.BUTTON2_MASK
InputEvent.BUTTON3_MASK
However, it is recommended to use InputEvent.BUTTON1_DOWN_MASK ,
InputEvent.BUTTON2_DOWN_MASK , InputEvent.BUTTON3_DOWN_MASK instead.
Either extended _DOWN_MASK or old _MASK values
should be used, but both those models should not be mixed.
- Throws:
java.lang.IllegalArgumentException - if the buttons mask contains the mask for extra mouse button
and support for extended mouse buttons is disabled by Java
java.lang.IllegalArgumentException - if the buttons mask contains the mask for extra mouse button
that does not exist on the mouse and support for extended mouse buttons is enabled by Java- See Also:
mousePress(int) ,
InputEvent.getMaskForButton(int) ,
Toolkit.areExtraMouseButtonsEnabled() ,
MouseInfo.getNumberOfButtons() ,
MouseEvent
|
|
mouseWheel |
void mouseWheel(int wheelAmt)
Rotates the scroll wheel on wheel-equipped mice.
public void mouseWheel(int wheelAmt)
-
Rotates the scroll wheel on wheel-equipped mice.
- Parameters:
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.- Since:
- 1.4
|
|
setAutoDelay |
void setAutoDelay(int ms)
Sets the number of milliseconds this Robot sleeps after generating an event.
public void setAutoDelay(int ms)
-
Sets the number of milliseconds this Robot sleeps after generating an event.
- Throws:
java.lang.IllegalArgumentException - If ms is not between 0 and 60,000 milliseconds inclusive
|
|
setAutoWaitForIdle |
void setAutoWaitForIdle(boolean isOn)
Sets whether this Robot automatically invokes waitForIdle
after generating an event.
public void setAutoWaitForIdle(boolean isOn)
-
Sets whether this Robot automatically invokes waitForIdle
after generating an event.
- Parameters:
isOn - Whether waitForIdle is automatically invoked
|
|
toString |
java.lang.String toString()
Returns a string representation of this Robot.
public java.lang.String toString()
-
Returns a string representation of this Robot.
- Overrides:
toString in class java.lang.Object
- Returns:
- the string representation.
|
|
waitForIdle |
void waitForIdle()
Waits until all events currently on the event queue have been processed.
public void waitForIdle()
-
Waits until all events currently on the event queue have been processed.
- Throws:
java.lang.IllegalThreadStateException - if called on the AWT event dispatching thread
|