Class SikuliMouseController
- All Implemented Interfaces:
MouseController
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
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.github.jspinak.brobot.core.services.MouseController
MouseController.MouseButton
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
click
(int x, int y, MouseController.MouseButton button) Performs a mouse click at the specified coordinates.boolean
doubleClick
(int x, int y, MouseController.MouseButton button) Performs a double-click at the specified coordinates.boolean
drag
(int startX, int startY, int endX, int endY, MouseController.MouseButton button) Performs a drag operation from one location to another.Gets the name of this mouse controller implementation.int[]
Gets the current mouse cursor position.boolean
Checks if the mouse controller is available and functional.boolean
mouseDown
(MouseController.MouseButton button) Presses and holds the specified mouse button at the current location.boolean
mouseUp
(MouseController.MouseButton button) Releases the specified mouse button.boolean
moveTo
(int x, int y) Moves the mouse cursor to the specified coordinates.boolean
scroll
(int wheelAmt) Scrolls the mouse wheel.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.github.jspinak.brobot.core.services.MouseController
click, doubleClick, drag, rightClick
-
Constructor Details
-
SikuliMouseController
@Autowired public SikuliMouseController(@Autowired(required=false) CoordinateScaler coordinateScaler)
-
-
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 interfaceMouseController
- Parameters:
x
- X coordinate to move toy
- Y coordinate to move to- Returns:
- true if the movement was successful, false otherwise
-
click
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 interfaceMouseController
- Parameters:
x
- X coordinate to click aty
- Y coordinate to click atbutton
- Which mouse button to click- Returns:
- true if the click was successful, false otherwise
-
doubleClick
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 interfaceMouseController
- Parameters:
x
- X coordinate to double-click aty
- Y coordinate to double-click atbutton
- Which mouse button to click- Returns:
- true if the double-click was successful, false otherwise
-
mouseDown
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 interfaceMouseController
- Parameters:
button
- Which mouse button to press- Returns:
- true if the press was successful, false otherwise
-
mouseUp
Description copied from interface:MouseController
Releases the specified mouse button.This method releases a previously pressed button.
- Specified by:
mouseUp
in interfaceMouseController
- Parameters:
button
- Which mouse button to release- Returns:
- true if the release was successful, false otherwise
-
drag
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 interfaceMouseController
- Parameters:
startX
- Starting X coordinatestartY
- Starting Y coordinateendX
- Ending X coordinateendY
- Ending Y coordinatebutton
- 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 interfaceMouseController
- 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 interfaceMouseController
- 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 interfaceMouseController
- Returns:
- true if mouse control is available, false otherwise
-
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 interfaceMouseController
- Returns:
- Implementation name (e.g., "AWT Robot", "Sikuli", "Mock")
-