send_key
Send a keystroke to a specified window with optional modifiers. Supports background input without activating the window.
Instructions
Send a keystroke with optional modifiers. noActivate uses PostMessage WM_KEYDOWN/WM_KEYUP so the target window doesn't need focus.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hwnd | No | Window handle from list_windows or launch_app. | |
| pid | No | ||
| processName | No | ||
| titleContains | No | ||
| key | Yes | Key name to send. Supports single printable ASCII characters and named keys: esc, tab, enter, space, arrows, f1-f12, backspace, delete, home, end, pageup, pagedown. | |
| modifiers | No | Modifier keys to hold during the keypress. | |
| delayMs | No | ||
| pressMs | No | ||
| noActivate | No | When true, sends WM_KEYDOWN/WM_KEYUP via PostMessage instead of keybd_event, so the target window never needs focus. Some applications may not respond to posted messages. |