Class Mouse

java.lang.Object
net.storm.sdk.input.Mouse

public class Mouse extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    static final Supplier<Point>
    Supplier that provides a random click point in a safe screen area.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    click(int x, int y, boolean left)
    Performs a mouse click at the specified coordinates.
    static void
    click(Point point, boolean left)
    Performs a mouse click at the specified point.
    static void
    clicked(int x, int y, Canvas canvas, long time)
    Dispatches a mouse clicked event to the canvas with default button.
    static void
    clicked(int x, int y, Canvas canvas, long time, int button)
    Dispatches a mouse clicked event to the canvas with a specific button.
    static void
    clickRandom(boolean left)
    Performs a mouse click at a random position provided by CLICK_POINT_SUPPLIER.
    static void
    entered(int x, int y, Canvas canvas, long time)
    Dispatches a mouse entered event to the canvas.
    static void
    exited(int x, int y, Canvas canvas, long time)
    Dispatches a mouse exited event to the canvas.
    static void
    moved(int x, int y, Canvas canvas, long time)
    Dispatches a mouse moved event to the canvas.
    static void
    pressed(int x, int y, Canvas canvas, long time, int button)
    Dispatches a mouse pressed event to the canvas.
    static void
    released(int x, int y, Canvas canvas, long time)
    Dispatches a mouse released event to the canvas with default button.
    static void
    released(int x, int y, Canvas canvas, long time, int button)
    Dispatches a mouse released event to the canvas with a specific button.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • CLICK_POINT_SUPPLIER

      public static final Supplier<Point> 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 click
      y - the y coordinate to click
      left - true for left click, false for right click
    • click

      public static void click(Point point, boolean left)
      Performs a mouse click at the specified point.
      Parameters:
      point - the Point to click at
      left - true for left click, false for right click
    • clickRandom

      public static void clickRandom(boolean left)
      Performs a mouse click at a random position provided by CLICK_POINT_SUPPLIER. Useful for anti-pattern behavior or dismissing interfaces.
      Parameters:
      left - true for left click, false for right click
    • pressed

      public static void pressed(int x, int y, Canvas canvas, long time, int button)
      Dispatches a mouse pressed event to the canvas. This method is synchronized to ensure thread safety.
      Parameters:
      x - the x coordinate
      y - the y coordinate
      canvas - the game Canvas
      time - the event timestamp
      button - the mouse button (e.g., MouseEvent.BUTTON1 for left, MouseEvent.BUTTON3 for right)
    • released

      public static void released(int x, int y, Canvas canvas, long time, int button)
      Dispatches a mouse released event to the canvas with a specific button. This method is synchronized to ensure thread safety.
      Parameters:
      x - the x coordinate
      y - the y coordinate
      canvas - the game Canvas
      time - the event timestamp
      button - the mouse button
    • clicked

      public static void clicked(int x, int y, Canvas canvas, long time, int button)
      Dispatches a mouse clicked event to the canvas with a specific button. This method is synchronized to ensure thread safety.
      Parameters:
      x - the x coordinate
      y - the y coordinate
      canvas - the game Canvas
      time - the event timestamp
      button - the mouse button
    • released

      public static void released(int x, int y, Canvas canvas, long time)
      Dispatches a mouse released event to the canvas with default button. This method is synchronized to ensure thread safety.
      Parameters:
      x - the x coordinate
      y - the y coordinate
      canvas - the game Canvas
      time - the event timestamp
    • clicked

      public static void clicked(int x, int y, Canvas canvas, long time)
      Dispatches a mouse clicked event to the canvas with default button. This method is synchronized to ensure thread safety.
      Parameters:
      x - the x coordinate
      y - the y coordinate
      canvas - the game Canvas
      time - the event timestamp
    • exited

      public static void exited(int x, int y, Canvas canvas, long time)
      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 coordinate
      y - the y coordinate
      canvas - the game Canvas
      time - the event timestamp
    • entered

      public static void entered(int x, int y, Canvas canvas, long time)
      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 coordinate
      y - the y coordinate
      canvas - the game Canvas
      time - the event timestamp
    • moved

      public static void moved(int x, int y, Canvas canvas, long time)
      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 coordinate
      y - the y coordinate
      canvas - the game Canvas
      time - the event timestamp