Skip to content

jrajan14/Mouse_recorder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

159 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

๐Ÿ–ฑ๏ธ Mouse Recorder & Player with UDP Streaming.

This project provides a Python-based mouse recorder and player that captures mouse events (movements, clicks, and scrolls), stores them in a JSON file, and streams real-time touch data over UDP. It is designed for UI testing, automation, and input replay systems.


๐Ÿ“ฆ Features

  • โœ… Mouse Event Recording (movement, click, scroll)
  • ๐Ÿ“ค UDP Touch Data Streaming (normalized coordinates)
  • โ–ถ๏ธ Playback with Timing Accuracy
  • ๐Ÿ Smooth Drag Prediction
  • โฑ๏ธ Adjustable Playback Speed
  • ๐Ÿ›‘ Emergency Stop Key Support
  • ๐Ÿ’พ JSON Output for Analysis/Replay

๐Ÿ“ Project Structure

.
├── recorder.py       # Record mouse events and send UDP data
├── player.py         # Replay recorded mouse events
├── mouse_track.json  # Output file from recorder
├── protocol.py       # Defines TouchData for UDP packet structure
├── protocol.py       # To receive UDP messages sent via protocol.py
└── README.md         # Project documentation

๐Ÿ–ฅ๏ธ Requirements

  • Python 3.7+
  • pyautogui
  • pynput
  • keyboard
  • numpy
pip install pyautogui pynput keyboard numpy

๐Ÿš€ Usage -๐ŸŽ™๏ธ Record Mouse Events

python recorder.py
  • Waits 3 seconds before starting.
  • Records movements, clicks, scrolls.
  • Sends live (x, y) over UDP if mouse is pressed.
  • Press Scroll Lock or Ctrl+C to stop.
  • Output saved to: mouse_track.json

๐ŸŽฌ Play Back Events python player.py

  • Replays all recorded events.
  • Uses original timing unless modified via SPEED_FACTOR.
  • Supports drag prediction for smoother paths.
  • Press Scroll Lock or Ctrl+C to stop at any time.

โš™๏ธ Configuration Options

  • You can customize in recorder.py and player.py:

Option Descriptions

  • RECORDING_DELAY Delay before starting recording
  • SPEED_FACTOR Playback speed multiplier (e.g., 2.0 = 2x)
  • STOP_KEY Hotkey to stop recording/playback
  • DRAG_PREDICTION Enable smoother drag motion
  • ADDRESS UDP target address and port
  • WIDTH/HEIGHT Screen resolution for coordinate scaling

๐Ÿ“ก UDP Streaming Format

  • The TouchData class in protocol.py is used to:
  • Normalize coordinates (0–1 range)
  • Package them into byte format
  • Send via UDP to a target listener

You can customize this class to match your target application's protocol.

๐Ÿงช Example Use Cases

  • Automated UI testing for desktop apps
  • Creating reproducible input demos
  • Remote control/input replay in custom environments
  • Input stream generation for touch emulation

๐Ÿ› ๏ธ Future Improvements

  • Add support for keyboard event capture
  • Include GUI for easier recording/playback
  • Cross-platform enhancements for hotkey handling

๐Ÿ™Œ Acknowledgments

  • Built using:
pyautogui
pynput
keyboard

About

A Python-based mouse recorder and player that captures movements, clicks, and scrolls, saves them to JSON, and streams touch data over UDP. Includes smooth drag playback, adjustable speed, and an emergency stop key. Useful for UI testing, automation, and input replay.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages