A modern Python WebSocket server that transforms your computer into a remotely controllable device. The server automatically registers itself on the local network using mDNS, making it easy for mobile apps to discover and connect without manual IP configuration.
- Mouse Control: Move, click (left/right), scroll with precision
- Touchpad Support: Drag movement and tap-to-click functionality
- Keyboard Control: Type text, send special keys, key combinations
- Special Keys: Backspace, Enter, Tab, Escape, Function keys (F1-F12), Arrow keys
- Key Combinations: Ctrl+C, Alt+Tab, Ctrl+Alt+Delete, and more
- Real-time Response: Immediate execution of commands
- mDNS Registration: Automatically registers as
remote-control.local
- Zero Configuration: No manual IP setup required
- Cross-Platform: Works on Windows, macOS, and Linux
- Local Network: Secure local network communication
- Multiple Clients: Support for multiple connected devices
- Connection Resilience: Automatic reconnection handling
- Status Monitoring: Real-time connection status
- Graceful Shutdown: Clean disconnection handling
- Failsafe Mode: Move mouse to corner to stop (pyautogui safety)
- Coordinate Bounds: Prevents mouse from going off-screen
- Input Validation: Validates all incoming commands
- Error Handling: Comprehensive error logging and recovery
βββββββββββββββββββ WebSocket βββββββββββββββββββ
β Mobile App β βββββββββββββββΊ β Tomas Control β
β (Client) β β Server β
βββββββββββββββββββ βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ
β mDNS Service β
β (Discovery) β
βββββββββββββββββββ
- Python 3.8+
- Windows/macOS/Linux
pip install -r requirements.txt
websockets
: WebSocket server implementationpyautogui
: Mouse and keyboard controlzeroconf
: mDNS service registrationasyncio
: Asynchronous operations
cd server
python run.py
=== run.py script started ===
Starting Remote Control Server...
Configuration loaded: ServerConfig(...)
Server instance created successfully
Starting server...
Starting WebSocket server on 0.0.0.0:8765
WebSocket server started successfully
Starting mDNS service...
Service registered: remote-control.local:8765
Remote Control Server is now running and ready for connections
- Install "Tomas Control" app on your phone
- App will automatically discover the server
- Connect and start controlling your PC!
@dataclass
class ServerConfig:
host: str = "0.0.0.0" # Listen on all interfaces
port: int = 8765 # WebSocket port
service_name: str = "remote-control" # mDNS service name
service_type: str = "_remote-control._tcp.local." # mDNS type
from config import ServerConfig
from remote_control_server import RemoteControlServer
# Custom configuration
config = ServerConfig(
host="192.168.1.100",
port=9000,
service_name="my-remote"
)
# Start server
server = RemoteControlServer(config)
await server.start()
// Move mouse
{
"type": "mouse_move",
"x": 100,
"y": 200,
"relative": false
}
// Click mouse
{
"type": "mouse_click",
"button": "left",
"clicks": 1,
"interval": 0.0
}
// Scroll mouse
{
"type": "mouse_scroll",
"clicks": 3,
"x": 0,
"y": 0
}
// Type text
{
"type": "key_type",
"text": "Hello World!",
"interval": 0.01
}
// Press special key
{
"type": "key_press",
"key": "backspace"
}
// Key combination
{
"type": "key_press",
"key": "ctrl+c"
}
// Hold key
{
"type": "key_press",
"key": "shift",
"hold": true
}
// Ping server
{
"type": "ping",
"timestamp": 1640995200.0
}
- Navigation:
backspace
,delete
,enter
,tab
,escape
,space
- Arrow Keys:
up
,down
,left
,right
- Function Keys:
f1
throughf12
- Page Navigation:
home
,end
,pageup
,pagedown
- Modifier Keys:
ctrl
,alt
,shift
,win
,cmd
server/
βββ run.py # Main entry point
βββ remote_control_server.py # Server orchestration
βββ websocket_handler.py # WebSocket connection handling
βββ remote_control.py # Mouse/keyboard control logic
βββ mdns_service.py # mDNS registration and discovery
βββ config.py # Configuration management
βββ test_client.py # Test client for development
βββ requirements.txt # Python dependencies
# Test client for development
python test_client.py --demo
# Interactive test client
python test_client.py
The server uses structured logging with different levels:
INFO
: Connection events, command executionDEBUG
: Detailed command informationERROR
: Connection failures, command errors
- Local Network Only: Server only accepts local connections
- No Authentication: Designed for trusted local networks
- mDNS Discovery: Automatic service discovery within network
- Command Validation: All commands are validated before execution
- Coordinate Bounds: Mouse coordinates are bounded to screen
- Failsafe Mode: Move mouse to corner to stop execution
# Check if port is in use
netstat -an | findstr 8765
# Check Python dependencies
pip list | grep websockets
# Check if mDNS is working
dns-sd -B _remote-control._tcp local.
# Try manual IP configuration
# Edit config.py to use specific IP
- Ensure both devices are on same WiFi network
- Check firewall settings
- Verify mDNS is enabled on network
# Enable debug logging
export LOG_LEVEL=DEBUG
python run.py
This project is part of Tomas Control - a remote control solution for local networks.
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
Tomas Control Server - Transform your computer into a remotely controllable device with zero configuration! π