Package org.dreambot.api.input
Class Mouse
- java.lang.Object
-
- org.dreambot.api.input.Mouse
-
public class Mouse extends java.lang.Object
Please note: In general you do not have to concern yourself with these methods.
The methods here will be called from interact methods by the API (such as the interact method inRectangleDestination
)
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static boolean
click()
Triggers a left clickstatic boolean
click(boolean right)
Triggers a left clickstatic boolean
click(java.awt.Point destination)
Moves mouse to point, and preforms left click.static boolean
click(java.awt.Point destination, boolean right)
Moves mouse to point, and preforms desired type of click, as determines by arguments.static boolean
click(java.awt.Rectangle destination)
Moves mouse to rectangle, and preforms left click.static boolean
click(java.awt.Rectangle destination, boolean right)
Moves mouse to rectangle, and preforms desired type of click, as determines by arguments.static boolean
click(ClickMode mode)
Triggers a click as determined by theClickMode
static boolean
click(AbstractMouseDestination destination)
Moves mouse to destination, and preforms left click.static boolean
click(AbstractMouseDestination destination, boolean right)
Moves mouse to destination, and preforms desired type of click, as determines by arguments.static boolean
click(AbstractMouseDestination destination, ClickMode type)
Triggers a click based fromClickMode
, and at desired destination.static boolean
click(Entity destination)
Moves mouse to entity, and preforms left click.static boolean
click(Entity destination, boolean right)
Moves mouse to entity, and preforms desired type of click, as determines by arguments.static boolean
drag(java.awt.Point point)
Drags the mouse from current point to the given pointstatic boolean
drag(java.awt.Rectangle rectangle)
Drags the mouse from current position to the given Rectanglestatic boolean
drag(AbstractMouseDestination destination)
Drags the mouse to the given AbstractMouseDestinationstatic boolean
drag(Tile tile)
Drags the mouse from the current point to the given Tilestatic boolean
drag(Entity entity)
Drags the mouse from the current position to the given Entitystatic int
getCrosshairColorID()
Gets the current crosshair color of the mouse.static CrosshairState
getCrosshairState()
Gets the current crosshair color of the mouse.static java.util.List<Entity>
getEntitiesOnCursor()
Gets a list of the entities that the cursor is hovering overstatic int
getIdleTime()
Gets idle time.static java.awt.Point
getLastClicked()
Gets last clicked position by the clientstatic long
getLastClickedTime()
Returns the last click time in milliseconds.static int
getLastClickedX()
Gets last clicked x position by the clientstatic int
getLastClickedY()
Gets last clicked y position by the clientstatic int
getLastCrosshairColorID()
Gets the crosshair color from the last click.static double
getLastMouseDirection()
static double
getLastMouseMagnitude()
static long
getLastMouseMoveTime()
static long
getMouseMoveResetTimeMillis()
static MouseSettings
getMouseSettings()
Grabs the MouseSettingsstatic long[]
getOnCursorUIDs()
static java.awt.Point
getPointOutsideScreen()
static java.awt.Point
getPosition()
Gets the current mouse position on the game canvas if the canvas contains the mouse.static long[]
getRawOnCursorUIDs()
static int
getRSLastClickedX()
static int
getRSLastClickedY()
static int
getUIDCount()
static int
getX()
Gets the current mouse X coordinate of the mouse if inside the canvas.static int
getY()
Gets the current mouse Y coordinate of the mouse if inside the canvas.static boolean
hop(int x, int y)
Method to 'hop' the mouse position, instantly.static boolean
hop(java.awt.Point destination)
Method to 'hop' the mouse position, instantly.static boolean
isAlwaysHop()
static boolean
isMouseHeldDown()
static boolean
isMouseInScreen()
Method to determine if the mouse cursor is in the screen.static boolean
loseFocus(int sleepBeforeLoseFocus)
Moves mouse outside of screen, sleeps for the given amount in ms, then calls a focus lost event Does not run if client already doesn't have focus If Mouse is already outside of screen, it will not re-move it outside of screenstatic void
mouseDownUntil(int timeout, Condition c)
Hold mouse down until condition is true, with specified timeoutstatic boolean
move()
Moves the mouse to random gaussian distributed destination near the location of your current position if the mouse is on screen, otherwise will base position from center of canvas.static boolean
move(java.awt.Point point)
Moves the mouse to a specified pointstatic boolean
move(java.awt.Rectangle rectangle)
Moves the mouse to a specified rectanglestatic boolean
move(AbstractMouseDestination destination)
Moves the mouse to a destinationstatic boolean
move(Tile tile)
static boolean
move(Entity entity)
Moves the mouse to a destinationstatic boolean
moveMouseOutsideScreen()
Deprecated.static boolean
moveOutsideScreen()
Moves the mouse outside the screen and sends a focus lost event to the canvas SeemoveOutsideScreen(boolean)
with param truestatic boolean
moveOutsideScreen(boolean loseFocus)
Moves mouse outside the screen, losing focus based on loseFocus parameter Does not run if mouse is not in screen If loseFocus is true seeloseFocus(int)
with a default time of random(100,3000)static void
scrollDownUntil(int timeout, Condition c)
Scrolls mouse wheel down until Condition is true or timeout is metstatic void
scrollUntil(boolean up, int timeout, Condition c)
Scrolls mouse until the condition is true, with specified timeoutstatic void
scrollUpUntil(int timeout, Condition c)
Scrolls mouse wheel up until Condition is true or timeout is metstatic void
setAlwaysHop(boolean alwaysHop)
static void
setLastClickPosition(java.awt.Point lastClickPosition2)
static void
setLastMouseDirection(double lastMouseDirection2)
static void
setLastMouseMagnitude(double lastMouseMagnitude2)
static void
setLastMouseMoveTime(long lastMouseMoveTime2)
static void
setPosition(int x, int y)
-
-
-
Method Detail
-
isMouseHeldDown
public static boolean isMouseHeldDown()
-
setPosition
public static void setPosition(int x, int y)
-
getUIDCount
public static int getUIDCount()
-
getRawOnCursorUIDs
public static long[] getRawOnCursorUIDs()
-
getOnCursorUIDs
public static long[] getOnCursorUIDs()
-
getIdleTime
public static int getIdleTime()
Gets idle time.- Returns:
- the idle time.
-
getLastClicked
public static java.awt.Point getLastClicked()
Gets last clicked position by the client- Returns:
- the position of the last mouse click the client performed
-
getLastClickedTime
public static long getLastClickedTime()
Returns the last click time in milliseconds. If there haven't been any clicks it will return 0. This method only counts clicks sent by the client itself, manual mouse clicks won't be reflected by this.- Returns:
- Last click time in milliseconds, or 0 if there haven't been any clicks since client start
-
getLastClickedX
public static int getLastClickedX()
Gets last clicked x position by the client- Returns:
- the x position of the last mouse click the client performed
-
getLastClickedY
public static int getLastClickedY()
Gets last clicked y position by the client- Returns:
- the y position of the last mouse click the client performed
-
getX
public static int getX()
Gets the current mouse X coordinate of the mouse if inside the canvas.- Returns:
- X coordinate of the mouse if currently inside the canvas, otherwise -1;
-
getY
public static int getY()
Gets the current mouse Y coordinate of the mouse if inside the canvas.- Returns:
- Y coordinate of the mouse if currently inside the canvas, otherwise -1;
-
getPosition
public static java.awt.Point getPosition()
Gets the current mouse position on the game canvas if the canvas contains the mouse.- Returns:
Point
of the position of the mouse if on canvas, otherwise returns -1 for both X and Y coordinates.
-
getMouseSettings
public static MouseSettings getMouseSettings()
Grabs the MouseSettings
-
getCrosshairColorID
public static int getCrosshairColorID()
Gets the current crosshair color of the mouse.- Returns:
- 0, 1, 2
-
getCrosshairState
public static CrosshairState getCrosshairState()
Gets the current crosshair color of the mouse.- Returns:
- Crosshair state
-
getLastCrosshairColorID
public static int getLastCrosshairColorID()
Gets the crosshair color from the last click.- Returns:
- 0, 1, 2
-
getEntitiesOnCursor
public static java.util.List<Entity> getEntitiesOnCursor()
Gets a list of the entities that the cursor is hovering over- Returns:
- list of entities
-
click
public static boolean click(java.awt.Rectangle destination)
Moves mouse to rectangle, and preforms left click.- Parameters:
destination
- The rectangle destination you wish click.- Returns:
- true if clicked successfully.
-
click
public static boolean click(java.awt.Rectangle destination, boolean right)
Moves mouse to rectangle, and preforms desired type of click, as determines by arguments.- Parameters:
destination
- The rectangle destination you wish click.right
- The type of click you wish to preform, right click if true, otherwise left click.- Returns:
- true if clicked successfully.
-
click
public static boolean click(java.awt.Point destination)
Moves mouse to point, and preforms left click.- Parameters:
destination
- The point destination you wish click.- Returns:
- true if clicked successfully.
-
click
public static boolean click(java.awt.Point destination, boolean right)
Moves mouse to point, and preforms desired type of click, as determines by arguments.- Parameters:
destination
- The point destination you wish click.right
- The type of click you wish to preform, right click if true, otherwise left click.- Returns:
- true if clicked successfully.
-
click
public static boolean click(Entity destination)
Moves mouse to entity, and preforms left click.- Parameters:
destination
- TheEntity
destination you wish click.- Returns:
- true if clicked successfully.
-
click
public static boolean click(Entity destination, boolean right)
Moves mouse to entity, and preforms desired type of click, as determines by arguments.- Parameters:
destination
- TheEntity
destination you wish click.right
- The type of click you wish to preform, right click if true, otherwise left click.- Returns:
- true if clicked successfully.
-
click
public static boolean click(AbstractMouseDestination destination, boolean right)
Moves mouse to destination, and preforms desired type of click, as determines by arguments.- Parameters:
destination
- The destination you wish click.right
- The type of click you wish to preform, right click if true, otherwise left click.- Returns:
- true if clicked successfully.
-
click
public static boolean click()
Triggers a left click- Returns:
- true if clicked successfully
-
click
public static boolean click(boolean right)
Triggers a left click- Returns:
- true if clicked successfully
-
click
public static boolean click(ClickMode mode)
Triggers a click as determined by theClickMode
- Returns:
- true if clicked successfully
-
click
public static boolean click(AbstractMouseDestination destination)
Moves mouse to destination, and preforms left click.- Parameters:
destination
- The destination you wish click.- Returns:
- true if clicked successfully.
-
click
public static boolean click(AbstractMouseDestination destination, ClickMode type)
Triggers a click based fromClickMode
, and at desired destination.- Parameters:
destination
- theAbstractMouseDestination
you wish to click.type
- theClickMode
used to determine type of click tp preform.- Returns:
- true if clicked successfully
-
mouseDownUntil
public static void mouseDownUntil(int timeout, Condition c)
Hold mouse down until condition is true, with specified timeout- Parameters:
timeout
- timeout in millisecondsc
- condition to check
-
scrollUntil
public static void scrollUntil(boolean up, int timeout, Condition c)
Scrolls mouse until the condition is true, with specified timeout- Parameters:
up
- true to scroll uptimeout
- timeout in millisecondsc
- condition to check
-
scrollDownUntil
public static void scrollDownUntil(int timeout, Condition c)
Scrolls mouse wheel down until Condition is true or timeout is met- Parameters:
timeout
- timeout in millisecondsc
- Condition to check
-
scrollUpUntil
public static void scrollUpUntil(int timeout, Condition c)
Scrolls mouse wheel up until Condition is true or timeout is met- Parameters:
timeout
- timeout in millisecondsc
- Condition to check
-
move
public static boolean move(java.awt.Rectangle rectangle)
Moves the mouse to a specified rectangle- Parameters:
rectangle
- The rectangle to move the mouse to.- Returns:
- true if mouse moved successfully
-
move
public static boolean move(Entity entity)
Moves the mouse to a destination- Parameters:
entity
- theEntity
which to move the mouse to.- Returns:
- true if mouse moved successfully, otherwise false.
-
move
public static boolean move(java.awt.Point point)
Moves the mouse to a specified point- Parameters:
point
- The point to move the mouse to.- Returns:
- true if mouse moved successfully
-
move
public static boolean move(Tile tile)
-
move
public static boolean move(AbstractMouseDestination destination)
Moves the mouse to a destination- Parameters:
destination
- Destination to move the mouse to.- Returns:
- true if mouse moved successfully
-
move
public static boolean move()
Moves the mouse to random gaussian distributed destination near the location of your current position if the mouse is on screen, otherwise will base position from center of canvas.- Returns:
- true if mouse moved successfully, otherwise false.
-
drag
public static boolean drag(java.awt.Point point)
Drags the mouse from current point to the given point- Parameters:
point
- Point to drag mouse to- Returns:
- True if successfully dragged, else false
-
drag
public static boolean drag(Tile tile)
Drags the mouse from the current point to the given Tile- Parameters:
tile
- Tile to drag mouse to- Returns:
- True if successfully dragged, else false
-
drag
public static boolean drag(Entity entity)
Drags the mouse from the current position to the given Entity- Parameters:
entity
- Entity to drag mouse to- Returns:
- True if successfully dragged, else false
-
drag
public static boolean drag(java.awt.Rectangle rectangle)
Drags the mouse from current position to the given Rectangle- Parameters:
rectangle
- The rectangle to drag the mouse to.- Returns:
- True if successfully dragged, else false
-
drag
public static boolean drag(AbstractMouseDestination destination)
Drags the mouse to the given AbstractMouseDestination- Parameters:
destination
- AbstractMouseDestination to drag mouse to- Returns:
- True if successfully dragged, else false
-
moveMouseOutsideScreen
@Deprecated public static boolean moveMouseOutsideScreen()
Deprecated.
-
moveOutsideScreen
public static boolean moveOutsideScreen()
Moves the mouse outside the screen and sends a focus lost event to the canvas SeemoveOutsideScreen(boolean)
with param true
-
moveOutsideScreen
public static boolean moveOutsideScreen(boolean loseFocus)
Moves mouse outside the screen, losing focus based on loseFocus parameter Does not run if mouse is not in screen If loseFocus is true seeloseFocus(int)
with a default time of random(100,3000)- Parameters:
loseFocus
- Boolean whether to lose focus or not- Returns:
- True if mouse already not in screen, or if successfully moves out of screen and if required loses focus
-
loseFocus
public static boolean loseFocus(int sleepBeforeLoseFocus)
Moves mouse outside of screen, sleeps for the given amount in ms, then calls a focus lost event Does not run if client already doesn't have focus If Mouse is already outside of screen, it will not re-move it outside of screen- Parameters:
sleepBeforeLoseFocus
- MS to sleep before calling focus lost- Returns:
- True if client already is not focused or if mouse successfully moves outside of screen and focus is lost
-
isMouseInScreen
public static boolean isMouseInScreen()
Method to determine if the mouse cursor is in the screen.- Returns:
- True if mouse is in the screen
-
hop
public static boolean hop(java.awt.Point destination)
Method to 'hop' the mouse position, instantly.- Parameters:
destination
- Point to jump to- Returns:
- True if succeeded.
-
hop
public static boolean hop(int x, int y)
Method to 'hop' the mouse position, instantly.- Parameters:
x
- X-coordinatey
- Y-coordinate- Returns:
- True if succeeded.
-
getPointOutsideScreen
public static java.awt.Point getPointOutsideScreen()
-
setLastClickPosition
public static void setLastClickPosition(java.awt.Point lastClickPosition2)
-
getLastMouseMagnitude
public static double getLastMouseMagnitude()
-
setLastMouseMagnitude
public static void setLastMouseMagnitude(double lastMouseMagnitude2)
-
getLastMouseDirection
public static double getLastMouseDirection()
-
setLastMouseDirection
public static void setLastMouseDirection(double lastMouseDirection2)
-
getLastMouseMoveTime
public static long getLastMouseMoveTime()
-
setLastMouseMoveTime
public static void setLastMouseMoveTime(long lastMouseMoveTime2)
-
getMouseMoveResetTimeMillis
public static long getMouseMoveResetTimeMillis()
-
isAlwaysHop
public static boolean isAlwaysHop()
-
setAlwaysHop
public static void setAlwaysHop(boolean alwaysHop)
-
getRSLastClickedX
public static int getRSLastClickedX()
-
getRSLastClickedY
public static int getRSLastClickedY()
-
-