Package net.storm.sdk.input
Class Mouse
java.lang.Object
net.storm.sdk.input.Mouse
Provides static utility methods for simulating mouse input to the game client.
This class allows sending mouse clicks, movements, and other mouse events to the game canvas.
Mouse events are handled with realistic timing and optional randomization.
The class uses a dedicated executor for click handling when called from the client thread to avoid blocking. Mouse events include proper sequencing of move, press, release, and click events.
Example usage:
// Left click at specific coordinates
Mouse.click(100, 200, true);
// Right click at specific coordinates
Mouse.click(100, 200, false);
// Click at a Point
Point p = new Point(150, 250);
Mouse.click(p, true);
// Click at a random position (useful for anti-pattern)
Mouse.clickRandom(true);
// Low-level mouse events for custom behavior
Canvas canvas = Client.getCanvas();
long time = System.currentTimeMillis();
Mouse.moved(100, 200, canvas, time);
Mouse.pressed(100, 200, canvas, time, MouseEvent.BUTTON1);
Mouse.released(100, 200, canvas, time, MouseEvent.BUTTON1);
Mouse.clicked(100, 200, canvas, time, MouseEvent.BUTTON1);
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionSupplier that provides a random click point in a safe screen area. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclick(int x, int y, boolean left) Performs a mouse click at the specified coordinates.static voidPerforms a mouse click at the specified point.static voidDispatches a mouse clicked event to the canvas with default button.static voidDispatches a mouse clicked event to the canvas with a specific button.static voidclickRandom(boolean left) Performs a mouse click at a random position provided byCLICK_POINT_SUPPLIER.static voidDispatches a mouse entered event to the canvas.static voidDispatches a mouse exited event to the canvas.static voidDispatches a mouse moved event to the canvas.static voidDispatches a mouse pressed event to the canvas.static voidDispatches a mouse released event to the canvas with default button.static voidDispatches a mouse released event to the canvas with a specific button.
-
Field Details
-
CLICK_POINT_SUPPLIER
Supplier that provides a random click point in a safe screen area. The generated points fall within a small region typically used for anti-pattern clicks.
-
-
Constructor Details
-
Mouse
public Mouse()
-
-
Method Details
-
click
public static void click(int x, int y, boolean left) Performs a mouse click at the specified coordinates. This method handles the full click sequence including move, press, release, and click events. If called from the client thread, the click is executed asynchronously to avoid blocking.- Parameters:
x- the x coordinate to clicky- the y coordinate to clickleft-truefor left click,falsefor right click
-
click
Performs a mouse click at the specified point.- Parameters:
point- thePointto click atleft-truefor left click,falsefor right click
-
clickRandom
public static void clickRandom(boolean left) Performs a mouse click at a random position provided byCLICK_POINT_SUPPLIER. Useful for anti-pattern behavior or dismissing interfaces.- Parameters:
left-truefor left click,falsefor right click
-
pressed
Dispatches a mouse pressed event to the canvas. This method is synchronized to ensure thread safety.- Parameters:
x- the x coordinatey- the y coordinatecanvas- the gameCanvastime- the event timestampbutton- the mouse button (e.g.,MouseEvent.BUTTON1for left,MouseEvent.BUTTON3for right)
-
released
Dispatches a mouse released event to the canvas with a specific button. This method is synchronized to ensure thread safety.- Parameters:
x- the x coordinatey- the y coordinatecanvas- the gameCanvastime- the event timestampbutton- the mouse button
-
clicked
Dispatches a mouse clicked event to the canvas with a specific button. This method is synchronized to ensure thread safety.- Parameters:
x- the x coordinatey- the y coordinatecanvas- the gameCanvastime- the event timestampbutton- the mouse button
-
released
Dispatches a mouse released event to the canvas with default button. This method is synchronized to ensure thread safety.- Parameters:
x- the x coordinatey- the y coordinatecanvas- the gameCanvastime- the event timestamp
-
clicked
Dispatches a mouse clicked event to the canvas with default button. This method is synchronized to ensure thread safety.- Parameters:
x- the x coordinatey- the y coordinatecanvas- the gameCanvastime- the event timestamp
-
exited
Dispatches a mouse exited event to the canvas. This simulates the mouse cursor leaving the canvas area. This method is synchronized to ensure thread safety.- Parameters:
x- the x coordinatey- the y coordinatecanvas- the gameCanvastime- the event timestamp
-
entered
Dispatches a mouse entered event to the canvas. This simulates the mouse cursor entering the canvas area. This method is synchronized to ensure thread safety.- Parameters:
x- the x coordinatey- the y coordinatecanvas- the gameCanvastime- the event timestamp
-
moved
Dispatches a mouse moved event to the canvas. This simulates the mouse cursor moving to a new position. This method is synchronized to ensure thread safety.- Parameters:
x- the x coordinatey- the y coordinatecanvas- the gameCanvastime- the event timestamp
-