Class SikuliMouseController

java.lang.Object
io.github.jspinak.brobot.core.services.SikuliMouseController
All Implemented Interfaces:
MouseController

@Component("sikuliMouseController") @Primary public class SikuliMouseController extends Object implements MouseController
Sikuli-based implementation of the MouseController interface.

This implementation uses Sikuli's mouse control capabilities, which provide cross-platform mouse automation. It is completely independent of the Find action and other high-level Brobot components.

Key characteristics:

  • No dependencies on Find or Action classes
  • Thread-safe through synchronized operations
  • Cross-platform compatibility
  • Uses hover() instead of mouseMove() for stability
Since:
2.0.0
  • Constructor Details

  • Method Details

    • moveTo

      public boolean moveTo(int x, int y)
      Description copied from interface: MouseController
      Moves the mouse cursor to the specified coordinates.

      This method moves the mouse cursor to the absolute screen coordinates specified. The movement may be instantaneous or animated depending on the implementation.

      Specified by:
      moveTo in interface MouseController
      Parameters:
      x - X coordinate to move to
      y - Y coordinate to move to
      Returns:
      true if the movement was successful, false otherwise
    • click

      public boolean click(int x, int y, MouseController.MouseButton button)
      Description copied from interface: MouseController
      Performs a mouse click at the specified coordinates.

      This method moves the mouse to the specified location and performs a click with the specified button.

      Specified by:
      click in interface MouseController
      Parameters:
      x - X coordinate to click at
      y - Y coordinate to click at
      button - Which mouse button to click
      Returns:
      true if the click was successful, false otherwise
    • doubleClick

      public boolean doubleClick(int x, int y, MouseController.MouseButton button)
      Description copied from interface: MouseController
      Performs a double-click at the specified coordinates.

      This method performs two rapid clicks at the specified location with the specified button.

      Specified by:
      doubleClick in interface MouseController
      Parameters:
      x - X coordinate to double-click at
      y - Y coordinate to double-click at
      button - Which mouse button to click
      Returns:
      true if the double-click was successful, false otherwise
    • mouseDown

      public boolean mouseDown(MouseController.MouseButton button)
      Description copied from interface: MouseController
      Presses and holds the specified mouse button at the current location.

      This method presses the button without releasing it, useful for drag operations.

      Specified by:
      mouseDown in interface MouseController
      Parameters:
      button - Which mouse button to press
      Returns:
      true if the press was successful, false otherwise
    • mouseUp

      public boolean mouseUp(MouseController.MouseButton button)
      Description copied from interface: MouseController
      Releases the specified mouse button.

      This method releases a previously pressed button.

      Specified by:
      mouseUp in interface MouseController
      Parameters:
      button - Which mouse button to release
      Returns:
      true if the release was successful, false otherwise
    • drag

      public boolean drag(int startX, int startY, int endX, int endY, MouseController.MouseButton button)
      Description copied from interface: MouseController
      Performs a drag operation from one location to another.

      This method presses the button at the start location, moves to the end location, and releases the button.

      Specified by:
      drag in interface MouseController
      Parameters:
      startX - Starting X coordinate
      startY - Starting Y coordinate
      endX - Ending X coordinate
      endY - Ending Y coordinate
      button - Which mouse button to use for dragging
      Returns:
      true if the drag was successful, false otherwise
    • scroll

      public boolean scroll(int wheelAmt)
      Description copied from interface: MouseController
      Scrolls the mouse wheel.

      Positive values scroll up/forward, negative values scroll down/backward.

      Specified by:
      scroll in interface MouseController
      Parameters:
      wheelAmt - Amount to scroll (positive for up, negative for down)
      Returns:
      true if the scroll was successful, false otherwise
    • getPosition

      public int[] getPosition()
      Description copied from interface: MouseController
      Gets the current mouse cursor position.

      Returns the current screen coordinates of the mouse cursor.

      Specified by:
      getPosition in interface MouseController
      Returns:
      Array with [x, y] coordinates, or null if unavailable
    • isAvailable

      public boolean isAvailable()
      Description copied from interface: MouseController
      Checks if the mouse controller is available and functional.

      This method can be used to verify that mouse control is possible in the current environment.

      Specified by:
      isAvailable in interface MouseController
      Returns:
      true if mouse control is available, false otherwise
    • getImplementationName

      public String getImplementationName()
      Description copied from interface: MouseController
      Gets the name of this mouse controller implementation.

      Used for logging and debugging to identify which controller is being used.

      Specified by:
      getImplementationName in interface MouseController
      Returns:
      Implementation name (e.g., "AWT Robot", "Sikuli", "Mock")