Class MouseRecorder
- java.lang.Object
-
- com.kraken.api.input.mouse.MouseRecorder
-
- All Implemented Interfaces:
net.runelite.client.input.MouseListener
@Singleton public class MouseRecorder extends java.lang.Object implements net.runelite.client.input.MouseListenerTheMouseRecorderclass is responsible for recording mouse gestures such as clicks, movements, and drags. It captures the sequence of mouse events, organizes them into gestures, and writes them to disk for later analysis.This class is designed as a singleton and interacts closely with the
MouseManagerto register and deregister itself as a listener for mouse events. The recorded gestures can be categorized using labels provided during the recording start, and the gestures are stored in JSON format in a designated directory.Some features of the
MouseRecorderinclude:- Categorizing gestures with user-defined labels
- Buffering gestures in memory and flushing them to disk in batches
- Asynchronous writing to avoid blocking event-handling threads
Thread-Safety
While most operations are single-threaded, writing gestures to the disk is executed asynchronously to ensure that mouse event processing is not blocked. Internal buffers for gesture storage are synchronized to ensure thread safety during flush operations.
-
-
Constructor Summary
Constructors Constructor Description MouseRecorder(net.runelite.client.input.MouseManager mouseManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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)voidstart(java.lang.String label)Starts recording mouse movements and gestures with the given label.voidstop()Stops the recording of mouse movements and gestures.
-
-
-
Method Detail
-
start
public void start(java.lang.String label)
Starts recording mouse movements and gestures with the given label.This method initializes buffers, sets the current label, and begins recording mouse events.
- Parameters:
label- The label to identify the recording session. Spaces in the label are replaced with underscores.
-
stop
public void stop()
Stops the recording of mouse movements and gestures.This method halts the recording session, flushes any pending gestures to disk, and unregisters the mouse listener to stop capturing events.
Steps performed:
- Checks if recording is active and proceeds only if it is.
- Flushes unsaved gestures to persistent storage.
- Unregisters the mouse listener to stop event monitoring.
- Logs the action completion with the associated label.
-
mousePressed
public java.awt.event.MouseEvent mousePressed(java.awt.event.MouseEvent e)
- Specified by:
mousePressedin interfacenet.runelite.client.input.MouseListener
-
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
-
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
-
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
-
-