Class Mouse
- java.lang.Object
-
- net.eternalclient.api.wrappers.input.Mouse
-
public class Mouse extends java.lang.Object
This class provides methods for simulating mouse actions.
-
-
Constructor Summary
Constructors Constructor Description Mouse()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
click(java.awt.Point point)
Simulates a mouse click event at the specified point on the screen.static void
click(java.awt.Point point, int sleep)
Simulates a mouse click at the specified point with the specified sleep delay.static void
clickUntil(java.awt.Point point, java.util.function.Supplier<java.lang.Boolean> until, int timeout)
Clicks repeatedly at the specified point until the provided condition is met within the given timeout.static java.awt.Point
getMousePosition()
Retrieves the current position of the mouse on the canvas.static int
getX()
Retrieves the x-coordinate of the mouse position on the canvas.static int
getY()
Returns the Y coordinate of the current mouse position on the client.static void
hop(java.awt.Point point)
Moves the mouse to the specifiedpoint
and triggers a mouse moved event.static void
internalClick(java.awt.Point point, int button)
Simulates a mouse click at the specified point with the given button.static void
internalExit()
Resets the mouse state by setting idle cycles to 0, mouse coordinates to (-1,-1), and updates the last moved time.static void
internalMovement(java.awt.Point point)
Moves the mouse to the specified point on the screen and resets idle cycles and last move time.static void
internalPress(java.awt.Point point, int button)
Presses the mouse at the given point with the specified button, updating the necessary mouse handler properties.static void
internalRelease()
Resets the mouse state by setting the idle cycles to zero and clearing the current button pressed.static void
middleClick(java.awt.Point point)
Simulates a middle click at the given point on the screen.static void
middleClick(java.awt.Point point, int sleep)
Simulates a middle mouse button click at the specified point with the given sleep duration.static void
middleClickUntil(java.awt.Point point, java.util.function.Supplier<java.lang.Boolean> until, int timeout)
Performs a middle mouse button click at the specified point until the provided condition is met, with a timeout duration.static void
mouseEntered()
Triggers the mouseEntered event and determines the current mouse position.static void
mouseEntered(java.awt.Point point)
Simulates a mouse entering a specific point on the screen.static void
mouseExited()
Triggers the mouseExited event and provides the current mouse position.static void
mouseExited(java.awt.Point point)
Simulates the event of the mouse exiting a specified point on the screen.static void
move(java.awt.Point point)
Moves the mouse to the specified point on the screen.static void
rightClick(java.awt.Point point)
Simulates a right click at the specified point on the screen.static void
rightClick(java.awt.Point point, int sleep)
Simulates a right-click at the specified point on the screen, with a specified sleep duration.static void
rightClickUntil(java.awt.Point point, java.util.function.Supplier<java.lang.Boolean> until, int timeout)
Right clicks repeatedly on the specified point until the provided condition is met, with a timeout.static void
scroll(int scrollAmount, int amount)
Scrolls the mouse wheel by a specified amount and sends a corresponding mouse event.
-
-
-
Method Detail
-
scroll
public static void scroll(int scrollAmount, int amount)
Scrolls the mouse wheel by a specified amount and sends a corresponding mouse event.- Parameters:
scrollAmount
- the amount to scroll the mouse wheel byamount
- the number of scrolls to perform
-
click
public static void click(java.awt.Point point)
Simulates a mouse click event at the specified point on the screen.- Parameters:
point
- the coordinates of the point to click
-
click
public static void click(java.awt.Point point, int sleep)
Simulates a mouse click at the specified point with the specified sleep delay.- Parameters:
point
- the coordinates of the clicksleep
- the delay in milliseconds before performing the click
-
clickUntil
public static void clickUntil(java.awt.Point point, java.util.function.Supplier<java.lang.Boolean> until, int timeout)
Clicks repeatedly at the specified point until the provided condition is met within the given timeout.- Parameters:
point
- the coordinates of the point to clickuntil
- the condition to be met for the clicking to stoptimeout
- the maximum duration to wait for the condition to be met in milliseconds
-
rightClick
public static void rightClick(java.awt.Point point)
Simulates a right click at the specified point on the screen.- Parameters:
point
- the coordinates of the point to right click
-
rightClick
public static void rightClick(java.awt.Point point, int sleep)
Simulates a right-click at the specified point on the screen, with a specified sleep duration.- Parameters:
point
- the coordinates of the point to right-clicksleep
- the duration in milliseconds to sleep after the right-click
-
rightClickUntil
public static void rightClickUntil(java.awt.Point point, java.util.function.Supplier<java.lang.Boolean> until, int timeout)
Right clicks repeatedly on the specified point until the provided condition is met, with a timeout.- Parameters:
point
- the target point to right click onuntil
- the condition that must be met for the method to stop executingtimeout
- the maximum time to wait for the condition to be met, in milliseconds
-
middleClick
public static void middleClick(java.awt.Point point)
Simulates a middle click at the given point on the screen.- Parameters:
point
- the coordinates of the point where the middle click will occur
-
middleClick
public static void middleClick(java.awt.Point point, int sleep)
Simulates a middle mouse button click at the specified point with the given sleep duration.- Parameters:
point
- the position on the screen to clicksleep
- the duration to sleep after pressing the middle mouse button
-
middleClickUntil
public static void middleClickUntil(java.awt.Point point, java.util.function.Supplier<java.lang.Boolean> until, int timeout)
Performs a middle mouse button click at the specified point until the provided condition is met, with a timeout duration.- Parameters:
point
- the point at which the middle mouse button click will be performeduntil
- the condition that needs to be met for the method to stop executingtimeout
- the maximum duration to wait for the condition to be met (in milliseconds)
-
mouseEntered
public static void mouseEntered(java.awt.Point point)
Simulates a mouse entering a specific point on the screen.- Parameters:
point
- The coordinates of the point where the mouse enters.
-
mouseEntered
public static void mouseEntered()
Triggers the mouseEntered event and determines the current mouse position.
-
mouseExited
public static void mouseExited(java.awt.Point point)
Simulates the event of the mouse exiting a specified point on the screen.- Parameters:
point
- the point where the mouse exited
-
mouseExited
public static void mouseExited()
Triggers the mouseExited event and provides the current mouse position.
-
hop
public static void hop(java.awt.Point point)
Moves the mouse to the specifiedpoint
and triggers a mouse moved event.- Parameters:
point
- the destination point to move the mouse to
-
internalClick
public static void internalClick(java.awt.Point point, int button)
Simulates a mouse click at the specified point with the given button.- Parameters:
point
- the point where the click will occurbutton
- the button to be clicked (e.g. MouseEvent.BUTTON1)
-
internalPress
public static void internalPress(java.awt.Point point, int button)
Presses the mouse at the given point with the specified button, updating the necessary mouse handler properties.- Parameters:
point
- the point where the mouse will be pressedbutton
- the button to be pressed
-
internalRelease
public static void internalRelease()
Resets the mouse state by setting the idle cycles to zero and clearing the current button pressed.
-
internalExit
public static void internalExit()
Resets the mouse state by setting idle cycles to 0, mouse coordinates to (-1,-1), and updates the last moved time.
-
internalMovement
public static void internalMovement(java.awt.Point point)
Moves the mouse to the specified point on the screen and resets idle cycles and last move time.- Parameters:
point
- the target point to move the mouse to
-
getMousePosition
public static java.awt.Point getMousePosition()
Retrieves the current position of the mouse on the canvas.- Returns:
- the coordinates of the mouse position as a Point object.
-
getX
public static int getX()
Retrieves the x-coordinate of the mouse position on the canvas.- Returns:
- the x-coordinate of the mouse position
-
getY
public static int getY()
Returns the Y coordinate of the current mouse position on the client.- Returns:
- the Y coordinate of the mouse
-
move
public static void move(java.awt.Point point)
Moves the mouse to the specified point on the screen.- Parameters:
point
- The point to move the mouse to.
-
-