Press a key or type text in the game UI
ui_keyPresses named keys or types text into the focused game UI field, including dialogs, Derma text entries, and HTML inputs, after clicking the target.
Instructions
Presses a key and/or types text into the focused part of the game UI (a text entry of a dialog, a Derma TextEntry, an HTML input): key is a named key (enter, escape, tab, backspace, space, up, down, left, right, home, end, pageup, pagedown, insert, delete, f1..f12, a letter, a digit or space: those type the character, as WM_CHAR like text, they are not pressed as keys), text is typed character by character as WM_CHAR (up to 256 characters; no control characters: use key). The engine narrows every typed character through the machine's ANSI code page with best-fit (live, CP1252: accents of western Europe arrive, l-stroke becomes l, Greek a, Cyrillic and CJK ?): a text with such a character is refused with text_not_representable (before anything is typed; details: code_page, characters) unless allow_lossy: true. For those, set the text from Lua with lua_exec in the realm that owns the panel (menu for the main menu's dialogs, client for Derma in game): entry:SetText("...") on a DTextEntry (DTextEntry:SetValue does nothing while the entry has the keyboard focus, which a ui_click gives it; entry:OnValueChange(text) afterwards if the page listens to it). With both, the text is typed first, then the key is pressed (text "hello" + key enter). Click the field first with ui_click. Result: {sent: [messages], key?, text_units?, lossy_characters? and ansi_code_page? (allow_lossy), frames_waited, window, screen, cursor_via, screenshot?}. Windows game client only (unsupported on srcds). Refusals, each its own error code: unsupported; not_a_test_client (the game was not started by instances_launch: pass allow_user_game: true to post into the user's own game); client_locked (connected to a server that is not on this machine); loading (a map is loading: events_wait map_loaded); window_unavailable (window minimized or not found); cursor_hidden (the mouse is captured by the game view: no menu, dialog or popup is open; open one first, e.g. console_exec gameui_activate); out_of_bounds (ui_click only: the point is outside the image or window). The input is posted to the game's own window (PostMessage): the user's real cursor does not move and no window takes the focus. Example: {"text": "my name", "key": "enter"}.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "ui_key"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | No | Named key to press (enter, escape, tab, backspace, up, f1...). | |
| text | No | Text to type (UTF-8, 256 characters at most). Only characters of the machine's ANSI code page arrive unchanged (accents of western Europe on CP1252); see text_not_representable. | |
| instance | No | Optional. Instance identifier (see instances_list). If present and different from the local instance, the call is relayed by the coordinator to that instance. | |
| allow_lossy | No | Type the text even if the engine will alter some characters (l-stroke becomes l, Greek a, Cyrillic and CJK ?). Default false: the call is refused with text_not_representable. | |
| wait_frames | No | Frames to wait after the last message so the UI reacts (default 5; a light test client runs at 20 fps). | |
| allow_user_game | No | Post into a game that instances_launch did not start (the user's own). Default false. | |
| screenshot_after | No | Also return a screenshot after the wait (same image as `screenshot`: the render capture with a map loaded, the engine's own jpeg command at the main menu, in a dialog or on a loading screen). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | No | ||
| next | No | ||
| note | No | ||
| sent | Yes | ||
| screen | No | ||
| window | No | ||
| warning | No | ||
| next_call | No | ||
| cursor_via | No | ||
| screenshot | No | ||
| text_units | No | ||
| answered_by | No | ||
| frames_waited | Yes | ||
| ansi_code_page | No | ||
| truncated_note | No | ||
| screenshot_note | No | ||
| version_warning | No | ||
| lossy_characters | No | ||
| screenshot_error | No |