Class VirtualMouse
- java.lang.Object
-
- com.kraken.api.input.mouse.VirtualMouse
-
- All Implemented Interfaces:
net.runelite.client.input.MouseListener
public class VirtualMouse extends java.lang.Object implements net.runelite.client.input.MouseListener
-
-
Constructor Summary
Constructors Constructor Description VirtualMouse(net.runelite.client.input.MouseManager mouseManager, net.runelite.api.Client client)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description VirtualMouseclick()Clicks the mouse at the current position.static java.util.List<java.lang.String>findLibraries()Scans a specified directory for JSON files and returns a list of library names derived from the filenames.static voidloadLibrary(java.lang.String libraryName)Loads a replay library for the REPLAY mouse movement strategy.java.awt.event.MouseEventmouseClicked(java.awt.event.MouseEvent e)java.awt.event.MouseEventmouseDragged(java.awt.event.MouseEvent e)java.awt.event.MouseEventmouseEntered(java.awt.event.MouseEvent e)java.awt.event.MouseEventmouseExited(java.awt.event.MouseEvent e)java.awt.event.MouseEventmouseMoved(java.awt.event.MouseEvent e)java.awt.event.MouseEventmousePressed(java.awt.event.MouseEvent e)java.awt.event.MouseEventmouseReleased(java.awt.event.MouseEvent e)VirtualMousemove(ContainerItem item)Moves the mouse to the specified ContainerItem.VirtualMousemove(ContainerItem item, MouseMovementStrategy mouseMovementStrategy)Moves the mouse to the specified ContainerItem using the provided movement strategy.VirtualMousemove(java.awt.Polygon polygon)Moves the mouse to the center of the specified polygon.VirtualMousemove(java.awt.Rectangle rect)Moves the mouse to the center of the specified rectangle.VirtualMousemove(net.runelite.api.Actor actor)Moves the mouse to the specified Actor.VirtualMousemove(net.runelite.api.Actor actor, MouseMovementStrategy mouseMovementStrategy)Moves the mouse to the specified Actor using the provided movement strategy.VirtualMousemove(net.runelite.api.coords.LocalPoint localPoint)Moves the mouse to the specified LocalPoint.VirtualMousemove(net.runelite.api.coords.LocalPoint localPoint, int plane)Moves the mouse to the specified LocalPoint at a specific plane.VirtualMousemove(net.runelite.api.coords.LocalPoint localPoint, int plane, MouseMovementStrategy mouseMovementStrategy)Moves the mouse to the specified LocalPoint at a specific plane using the provided movement strategy.VirtualMousemove(net.runelite.api.coords.LocalPoint localPoint, MouseMovementStrategy mouseMovementStrategy)Moves the mouse to the specified LocalPoint using the provided movement strategy.VirtualMousemove(net.runelite.api.coords.WorldPoint worldPoint)Moves the mouse to the specified WorldPoint.VirtualMousemove(net.runelite.api.coords.WorldPoint worldPoint, MouseMovementStrategy mouseMovementStrategy)Moves the mouse to the specified WorldPoint using the provided movement strategy.VirtualMousemove(net.runelite.api.Point target)Moves the mouse to the specified target position using the default mouse movement strategy.VirtualMousemove(net.runelite.api.Point target, MouseMovementStrategy strategy)Moves the mouse to the specified target position using the provided movement strategy.VirtualMousemove(net.runelite.api.Tile tile)Moves the mouse to the specified Tile.VirtualMousemove(net.runelite.api.TileObject tileObject)Moves the mouse to the specified TileObject.VirtualMousemove(net.runelite.api.TileObject tileObject, MouseMovementStrategy mouseMovementStrategy)Moves the mouse to the specified TileObject using the provided movement strategy.VirtualMousemove(net.runelite.api.Tile tile, MouseMovementStrategy mouseMovementStrategy)Moves the mouse to the specified Tile using the provided movement strategy.VirtualMousemove(net.runelite.api.widgets.Widget widget)Moves the mouse to the specified Widget.VirtualMousemove(net.runelite.api.widgets.Widget widget, MouseMovementStrategy mouseMovementStrategy)Moves the mouse to the specified Widget using the provided movement strategy.static voidsetMouseMovementStrategy(MouseMovementStrategy strategy)Sets the strategy to be used for mouse movement in the system.
-
-
-
Method Detail
-
mouseMoved
public java.awt.event.MouseEvent mouseMoved(java.awt.event.MouseEvent e)
- Specified by:
mouseMovedin interfacenet.runelite.client.input.MouseListener
-
mouseDragged
public java.awt.event.MouseEvent mouseDragged(java.awt.event.MouseEvent e)
- Specified by:
mouseDraggedin interfacenet.runelite.client.input.MouseListener
-
mouseEntered
public java.awt.event.MouseEvent mouseEntered(java.awt.event.MouseEvent e)
- Specified by:
mouseEnteredin interfacenet.runelite.client.input.MouseListener
-
mouseExited
public java.awt.event.MouseEvent mouseExited(java.awt.event.MouseEvent e)
- Specified by:
mouseExitedin interfacenet.runelite.client.input.MouseListener
-
mousePressed
public java.awt.event.MouseEvent mousePressed(java.awt.event.MouseEvent e)
- Specified by:
mousePressedin interfacenet.runelite.client.input.MouseListener
-
mouseReleased
public java.awt.event.MouseEvent mouseReleased(java.awt.event.MouseEvent e)
- Specified by:
mouseReleasedin interfacenet.runelite.client.input.MouseListener
-
mouseClicked
public java.awt.event.MouseEvent mouseClicked(java.awt.event.MouseEvent e)
- Specified by:
mouseClickedin interfacenet.runelite.client.input.MouseListener
-
loadLibrary
public static void loadLibrary(java.lang.String libraryName)
Loads a replay library for the REPLAY mouse movement strategy. Any other strategy will be ignored.- Parameters:
libraryName- The name of the library to load.
-
setMouseMovementStrategy
public static void setMouseMovementStrategy(MouseMovementStrategy strategy)
Sets the strategy to be used for mouse movement in the system.This method updates the default mouse movement behavior by replacing it with the provided @MouseMovementStrategy implementation. The new strategy will dictate how mouse movements are handled globally.
Note: It is the caller's responsibility to ensure that the provided strategy implementation is valid and behaves as expected. Passing a
nullvalue may lead to unexpected behavior.- Parameters:
strategy- The @MouseMovementStrategy to be set as the default mouse movement strategy. Must not benull.
-
findLibraries
public static java.util.List<java.lang.String> findLibraries()
Scans a specified directory for JSON files and returns a list of library names derived from the filenames.This method attempts to list all files in a predefined directory, extract the filenames, and remove the ".json" extension to identify the libraries.
In the event of an error during file scanning or processing, it logs the error and returns an empty list.
- Returns:
- A List<String> containing the names of the libraries (filenames without the ".json" extension), or an empty list if an error occurs or no libraries are found.
-
move
public VirtualMouse move(net.runelite.api.Point target, MouseMovementStrategy strategy)
Moves the mouse to the specified target position using the provided movement strategy.This method uses the given
MouseMovementStrategyto dictate how the mouse moves to the specifiedPointtarget. The movement behavior varies depending on the selected strategy (e.g., linear, bezier, instant, etc.).- If the movement strategy is not properly initialized, unexpected behavior may occur.
- The mouse's final position will be the given
Pointafter the strategy completes.
- Parameters:
target- The target position represented as aPointto which the mouse will be moved.strategy- TheMouseMovementStrategydefining how the mouse moves to the target point.- Returns:
- The
VirtualMouseinstance for method chaining.
-
move
public VirtualMouse move(net.runelite.api.Point target)
Moves the mouse to the specified target position using the default mouse movement strategy.This method leverages the default
MouseMovementStrategyto determine how the mouse moves. The behavior of the movement may include various strategies (e.g., linear, curved, instant, etc.) depending on the configuration of the default strategy.- If the default mouse movement strategy is not initialized, the behavior may be undefined.
- The mouse's final position will be the specified target after the strategy completes its execution.
- Parameters:
target- The target position represented as aPointto which the mouse will move.- Returns:
- The
VirtualMouseinstance for method chaining.
-
move
public VirtualMouse move(net.runelite.api.Actor actor)
Moves the mouse to the specified Actor.- Parameters:
actor- The actor to move to.- Returns:
- The VirtualMouse instance for chaining.
-
move
public VirtualMouse move(net.runelite.api.Actor actor, MouseMovementStrategy mouseMovementStrategy)
Moves the mouse to the specified Actor using the provided movement strategy.- Parameters:
actor- The actor to move to.mouseMovementStrategy- The movement strategy to use.- Returns:
- The VirtualMouse instance for chaining.
-
move
public VirtualMouse move(ContainerItem item)
Moves the mouse to the specified ContainerItem.- Parameters:
item- The container item to move to.- Returns:
- The VirtualMouse instance for chaining.
-
move
public VirtualMouse move(ContainerItem item, MouseMovementStrategy mouseMovementStrategy)
Moves the mouse to the specified ContainerItem using the provided movement strategy.- Parameters:
item- The container item to move to.mouseMovementStrategy- The movement strategy to use.- Returns:
- The VirtualMouse instance for chaining.
-
move
public VirtualMouse move(net.runelite.api.TileObject tileObject)
Moves the mouse to the specified TileObject.- Parameters:
tileObject- The tile object to move to.- Returns:
- The VirtualMouse instance for chaining.
-
move
public VirtualMouse move(net.runelite.api.TileObject tileObject, MouseMovementStrategy mouseMovementStrategy)
Moves the mouse to the specified TileObject using the provided movement strategy.- Parameters:
tileObject- The tile object to move to.mouseMovementStrategy- The movement strategy to use.- Returns:
- The VirtualMouse instance for chaining.
-
move
public VirtualMouse move(net.runelite.api.Tile tile)
Moves the mouse to the specified Tile.- Parameters:
tile- The tile to move to.- Returns:
- The VirtualMouse instance for chaining.
-
move
public VirtualMouse move(net.runelite.api.Tile tile, MouseMovementStrategy mouseMovementStrategy)
Moves the mouse to the specified Tile using the provided movement strategy.- Parameters:
tile- The tile to move to.mouseMovementStrategy- The movement strategy to use.- Returns:
- The VirtualMouse instance for chaining.
-
move
public VirtualMouse move(net.runelite.api.widgets.Widget widget)
Moves the mouse to the specified Widget.- Parameters:
widget- The widget to move to.- Returns:
- The VirtualMouse instance for chaining.
-
move
public VirtualMouse move(net.runelite.api.widgets.Widget widget, MouseMovementStrategy mouseMovementStrategy)
Moves the mouse to the specified Widget using the provided movement strategy.- Parameters:
widget- The widget to move to.mouseMovementStrategy- The movement strategy to use.- Returns:
- The VirtualMouse instance for chaining.
-
move
public VirtualMouse move(net.runelite.api.coords.WorldPoint worldPoint)
Moves the mouse to the specified WorldPoint.- Parameters:
worldPoint- The world point to move to.- Returns:
- The VirtualMouse instance for chaining.
-
move
public VirtualMouse move(net.runelite.api.coords.WorldPoint worldPoint, MouseMovementStrategy mouseMovementStrategy)
Moves the mouse to the specified WorldPoint using the provided movement strategy.- Parameters:
worldPoint- The world point to move to.mouseMovementStrategy- The movement strategy to use.- Returns:
- The VirtualMouse instance for chaining.
-
move
public VirtualMouse move(net.runelite.api.coords.LocalPoint localPoint)
Moves the mouse to the specified LocalPoint.- Parameters:
localPoint- The local point to move to.- Returns:
- The VirtualMouse instance for chaining.
-
move
public VirtualMouse move(net.runelite.api.coords.LocalPoint localPoint, MouseMovementStrategy mouseMovementStrategy)
Moves the mouse to the specified LocalPoint using the provided movement strategy.- Parameters:
localPoint- The local point to move to.mouseMovementStrategy- The movement strategy to use.- Returns:
- The VirtualMouse instance for chaining.
-
move
public VirtualMouse move(net.runelite.api.coords.LocalPoint localPoint, int plane)
Moves the mouse to the specified LocalPoint at a specific plane.- Parameters:
localPoint- The local point to move to.plane- The plane to move to.- Returns:
- The VirtualMouse instance for chaining.
-
move
public VirtualMouse move(net.runelite.api.coords.LocalPoint localPoint, int plane, MouseMovementStrategy mouseMovementStrategy)
Moves the mouse to the specified LocalPoint at a specific plane using the provided movement strategy.- Parameters:
localPoint- The local point to move to.plane- The plane to move to.mouseMovementStrategy- The movement strategy to use.- Returns:
- The VirtualMouse instance for chaining.
-
move
public VirtualMouse move(java.awt.Rectangle rect)
Moves the mouse to the center of the specified rectangle.- Parameters:
rect- The rectangle to move to.- Returns:
- The VirtualMouse instance for chaining.
-
move
public VirtualMouse move(java.awt.Polygon polygon)
Moves the mouse to the center of the specified polygon.- Parameters:
polygon- The polygon to move to.- Returns:
- The VirtualMouse instance for chaining.
-
click
public VirtualMouse click()
Clicks the mouse at the current position.- Returns:
- The VirtualMouse instance for chaining.
-
-