mouse_drag
Drag the mouse from specified start to end coordinates while holding a button, enabling precise screen interactions in Hyprland desktop automation.
Instructions
Drag from one position to another.
Args: start_x: Starting X coordinate start_y: Starting Y coordinate end_x: Ending X coordinate end_y: Ending Y coordinate button: Mouse button to hold during drag ("left", "right", "middle")
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| start_x | Yes | ||
| start_y | Yes | ||
| end_x | Yes | ||
| end_y | Yes | ||
| button | No | left |
Implementation Reference
- hyprland_mcp/input.py:75-114 (handler)The actual implementation of the drag logic using ydotool to simulate button-down, move, and button-up events.
async def drag( start_x: int, start_y: int, end_x: int, end_y: int, button: str = "left", ) -> None: """Drag from one position to another.""" require_tool("ydotool") down_code = _BUTTON_DOWN.get(button) up_code = _BUTTON_UP.get(button) if down_code is None: raise InputError(f"Unknown button: {button}") # Move to start position await move_cursor(start_x, start_y) await asyncio.sleep(0.05) # Button down proc = await asyncio.create_subprocess_exec( "ydotool", "click", down_code, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE, ) await proc.communicate() await asyncio.sleep(0.05) # Move to end position await move_cursor(end_x, end_y) await asyncio.sleep(0.05) # Button up proc = await asyncio.create_subprocess_exec( "ydotool", "click", up_code, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE, ) await proc.communicate() - hyprland_mcp/server.py:306-324 (registration)MCP tool registration for mouse_drag.
async def mouse_drag( start_x: int, start_y: int, end_x: int, end_y: int, button: str = "left", ) -> str: """Drag from one position to another. Args: start_x: Starting X coordinate start_y: Starting Y coordinate end_x: Ending X coordinate end_y: Ending Y coordinate button: Mouse button to hold during drag ("left", "right", "middle") """ from . import input as inp await inp.drag(start_x, start_y, end_x, end_y, button) return f"Dragged {button} from ({start_x},{start_y}) to ({end_x},{end_y})"