hyperv_mouse
Sends mouse moves, clicks, drags and scrolls into a running Hyper-V guest via the synthetic mouse, requiring no guest OS cooperation or credentials. Works only in basic sessions.
Instructions
Move, click, drag or scroll the mouse inside a running Hyper-V guest, using the hypervisor's synthetic mouse (Msvm_SyntheticMouse). No guest OS cooperation and no credential are needed; the VM only has to be Running. BASIC SESSION ONLY: synthetic mouse events reach a basic session, but not an Enhanced Session Mode (RDP / HvSocket) connection — the click is silently dropped there. The tool therefore refuses to run when Get-VM reports EnhancedSessionTransportType = HvSocket, and when that property cannot be read it falls back to a black-frame probe (non-zero Msvm_VideoHead resolution but a near-black screen) and refuses with the same explanation. Disconnect the enhanced session (switch vmconnect back to a basic session) and retry. Coordinates are guest pixels of the guest's CURRENT resolution with the origin at the top-left (read from Msvm_VideoHead). Valid x is 0..width-1 and y is 0..height-1; out-of-range values are rejected as INVALID_ARGUMENT after the resolution is read, never clamped. action=click moves the pointer first, then calls ClickButton; count=2 is a double click (two ClickButton calls about 100 ms apart). action=drag presses the button at x,y, moves through five interpolated points and releases at toX,toY, pausing briefly on the end point before release. action=scroll moves to x,y and calls SetScrollPosition with delta; -120 is approximately two lines, so delta is approximate and its exact effect is guest- and application-specific. settleMs (default 250) is the pause after the action, before the call returns. The result text states what was done, the target coordinates, the guest resolution, the detected session type and the observed elapsed time. Errors: VM_NOT_FOUND, VM_NOT_RUNNING — the VM must be Running; HYPERV_UNAVAILABLE when the per-VM mouse device or the resolution cannot be resolved; INVALID_ARGUMENT for bad arguments or out-of-range coordinates; GUEST_ERROR when an enhanced session (or a suspected one) was detected. This tool is not concurrency safe: it is serialized with other guest input, screenshots and lifecycle calls.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"vm": "<vm>",
"action": "<action>"
},
"name": "hyperv_mouse"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | No | Target horizontal guest pixel (origin top-left). For drag this is the start point. Must be 0..width-1 of the guest's current resolution. | |
| y | No | Target vertical guest pixel (origin top-left). For drag this is the start point. Must be 0..height-1 of the guest's current resolution. | |
| vm | Yes | Name of the Hyper-V virtual machine, as shown by hyperv_vm_list. | |
| toX | No | Drag end horizontal pixel. Required when action=drag. | |
| toY | No | Drag end vertical pixel. Required when action=drag. | |
| count | No | Number of clicks for action=click. Default 1; 2 means double click. | |
| delta | No | Scroll delta for action=scroll; negative scrolls down. -120 is about two lines, so the value is an approximation. | |
| action | Yes | move = position the pointer; click = click count times with button; drag = press at x,y and release at toX,toY; scroll = wheel delta at x,y. | |
| button | No | Mouse button for click and drag. Default left. | |
| settleMs | No | Pause in milliseconds after the action. Default 250. |