fix(type): paste long text via clipboard to avoid scan-code race
The Type tool drops characters and repeats stuck keys on slower or
loaded Windows systems. Reproduces reliably on a 4-core Win11 dev VM:
typing "hello from windows-mcp drive test" renders in Notepad as
"hello tttttttttttttttttttttttttt" — the first 5–6 chars land, then
the rest of the string collapses into repeated 't's.
Cause: uia.SendKeys generates a KeyDown/KeyUp pair per character at
20ms intervals. Under contention (small VMs, RDP sessions, busy
desktops) some KeyUp events get dropped, leaving the previous key
stuck "down" so each subsequent KeyDown reads as a repeat.
Fix:
- For text >= 20 chars without control chars (newlines / tabs /
braces): stash on clipboard, Ctrl+V, restore prior clipboard. The
paste path bypasses the scan-code queue entirely, so the race
doesn't apply.
- For short text or text containing control chars: still use
SendKeys, but bump the per-key interval 0.02 → 0.04. Short strings
remain effectively instant; longer ones get a small but reliable
slowdown.
The clipboard path is plain-text only — escape sequences like
{Enter} and {Tab} still need SendKeys to be honored.
Tested on a Win11 dev VM (windows-mcp 0.8.2 + this patch); long
strings now round-trip cleanly through Notepad in repeat tests. A
Austin Renfroe committed
879a09c37c91d89df4e32be82ea47bd79ec3c799
Parent: 0428e90