Class MouseRecorder

  • All Implemented Interfaces:
    net.runelite.client.input.MouseListener

    @Singleton
    public class MouseRecorder
    extends java.lang.Object
    implements net.runelite.client.input.MouseListener
    The MouseRecorder class 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 MouseManager to 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 MouseRecorder include:

    • 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.MouseEvent mouseClicked​(java.awt.event.MouseEvent e)  
      java.awt.event.MouseEvent mouseDragged​(java.awt.event.MouseEvent e)  
      java.awt.event.MouseEvent mouseEntered​(java.awt.event.MouseEvent e)  
      java.awt.event.MouseEvent mouseExited​(java.awt.event.MouseEvent e)  
      java.awt.event.MouseEvent mouseMoved​(java.awt.event.MouseEvent e)  
      java.awt.event.MouseEvent mousePressed​(java.awt.event.MouseEvent e)  
      java.awt.event.MouseEvent mouseReleased​(java.awt.event.MouseEvent e)  
      void start​(java.lang.String label)
      Starts recording mouse movements and gestures with the given label.
      void stop()
      Stops the recording of mouse movements and gestures.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MouseRecorder

        @Inject
        public MouseRecorder​(net.runelite.client.input.MouseManager mouseManager)
    • 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:
        mousePressed in interface net.runelite.client.input.MouseListener
      • mouseMoved

        public java.awt.event.MouseEvent mouseMoved​(java.awt.event.MouseEvent e)
        Specified by:
        mouseMoved in interface net.runelite.client.input.MouseListener
      • mouseDragged

        public java.awt.event.MouseEvent mouseDragged​(java.awt.event.MouseEvent e)
        Specified by:
        mouseDragged in interface net.runelite.client.input.MouseListener
      • mouseReleased

        public java.awt.event.MouseEvent mouseReleased​(java.awt.event.MouseEvent e)
        Specified by:
        mouseReleased in interface net.runelite.client.input.MouseListener
      • mouseClicked

        public java.awt.event.MouseEvent mouseClicked​(java.awt.event.MouseEvent e)
        Specified by:
        mouseClicked in interface net.runelite.client.input.MouseListener
      • mouseEntered

        public java.awt.event.MouseEvent mouseEntered​(java.awt.event.MouseEvent e)
        Specified by:
        mouseEntered in interface net.runelite.client.input.MouseListener
      • mouseExited

        public java.awt.event.MouseEvent mouseExited​(java.awt.event.MouseEvent e)
        Specified by:
        mouseExited in interface net.runelite.client.input.MouseListener