hyperv_keyboard
Type ASCII text, press single keys, or send key combinations inside a running Hyper-V guest over a basic session. Use it to enter input, trigger shortcuts, or wake a blank guest display.
Instructions
Type text, press a single key or press a key combination inside a running Hyper-V guest. BASIC SESSION ONLY: Msvm_Keyboard events reach a basic session, but not an Enhanced Session Mode (RDP / HvSocket) connection, where they are silently dropped. The tool 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. The clipboard route described below runs entirely inside the guest and is not affected. ROUTING: text that is pure ASCII is typed with Msvm_Keyboard.TypeText; tabs and line breaks in it become real Tab and Enter key presses. text containing ANY non-ASCII character is pasted: the host backs up the guest clipboard with Get-Clipboard, sets the new text, sends Ctrl+V and then restores the original clipboard. That route needs a stored credential (hyperv_credential_set; otherwise NEED_CREDENTIAL) and a logged-on interactive desktop session in the guest (otherwise a clear GUEST_ERROR), and it uses a temporary scheduled task with LogonType = Interactive running powershell.exe -NoProfile -WindowStyle Hidden -STA -EncodedCommand (never -File, which returns -196608 on this guest without executing anything). The temporary task and temp files are always removed. Only TEXT on the clipboard is backed up and restored: if the original clipboard held an image or files, that content is not preserved. SendKeys targets the foreground window, so a higher-integrity foreground window blocks the paste via UIPI. key accepts Enter, Esc, Tab, Backspace, Delete, Insert, Home, End, PageUp, PageDown, arrows (Left/Up/Right/Down), Space, F1-F12, Shift/Ctrl/Alt/Win on their own (useful to wake a blank guest display), a single letter or digit, and common punctuation on a US layout. combo is a modifier combination such as Ctrl+V or Ctrl+Shift+Esc; modifiers are pressed in order and released in reverse. provide at least one of text, key, combo (otherwise INVALID_ARGUMENT). Actions run in the order text, key, combo, and submit presses Enter last when true (default false). settleMs (default 250) is the pause after each action. Errors: VM_NOT_FOUND, VM_NOT_RUNNING, NEED_CREDENTIAL, GUEST_ERROR (enhanced session or no interactive session), INVALID_ARGUMENT for bad arguments. 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>"
},
"name": "hyperv_keyboard"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| vm | Yes | Name of the Hyper-V virtual machine, as shown by hyperv_vm_list. | |
| key | No | A single key name: Enter, Esc, Tab, Backspace, Delete, Insert, Home, End, PageUp, PageDown, Left/Up/Right/Down, Space, F1-F12, Shift/Ctrl/Alt/Win on their own, a letter or digit, or common punctuation. | |
| text | No | Text to type. Pure ASCII is typed with TypeText; any non-ASCII character switches the whole string to the clipboard-paste route, which needs a credential and an interactive guest session. | |
| combo | No | Key combination such as Ctrl+V or Ctrl+Shift+Esc. | |
| submit | No | Press Enter after the text. Default false. | |
| settleMs | No | Pause in milliseconds after each action. Default 250. |