Click in the game UI
ui_clickClicks or scrolls the game window using screenshot or client-area coordinates to operate VGUI2 dialogs, Derma panels, and HTML menus that have no console command.
Instructions
Clicks (or scrolls the wheel) at a point of the game window: use it for what has no console command, the buttons of VGUI2 dialogs ("Disconnected by the server" > Close), Derma panels and the menu's HTML. Take the coordinates from a screenshot (coords "screenshot", the default: pixels of that image, origin top-left; if the image you read has another size than the game window's, e.g. a screenshot with w/h, pass screenshot_size [w, h] and the point is scaled) or give coords "window" (pixels of the window's client area, title bar excluded). DPI scaling is handled: the result says the window size, DPI and the scale applied. Posts WM_MOUSEMOVE, then the button down and up (double: down, up, double-click, up) one frame apart, or WM_MOUSEMOVE and one WM_MOUSEWHEEL (wheel: notches, positive = up). Result: {sent: [messages], at: {x, y} (client pixels), coords, button | wheel, scale?, frames_waited, window: {client_w, client_h, dpi, dpi_awareness, class}, screen: {w, h}, cursor_via (game_ui | vgui), screenshot?, screenshot_error?} plus the image with screenshot_after (the engine's jpeg capture when there is no client realm). The cursor is visible when the game menu (main menu, ESC menu, a dialog on it) is up, gui.IsGameUIVisible(), or a Derma popup, the context or spawn menu has it, vgui.CursorVisible() in the client realm. 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: {"x": 640, "y": 400, "screenshot_after": true}.
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": {
"x": "<x>",
"y": "<y>"
},
"name": "ui_click"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | Yes | Pixel column (see coords). | |
| y | Yes | Pixel row (see coords). | |
| wheel | No | Scroll this many notches instead of clicking (positive = up, negative = down; not 0). | |
| button | No | Default left. Not with wheel. | |
| coords | No | Space of x and y: "screenshot" (default) or "window" (client-area pixels). | |
| double | No | Double click (down, up, double-click, up). Not with wheel. | |
| 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. | |
| 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_size | No | [w, h] of the image x and y were read on, when it is not the game window's size (a screenshot with w/h). | |
| 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 |
|---|---|---|---|
| at | Yes | ||
| next | No | ||
| note | No | ||
| sent | Yes | ||
| scale | No | ||
| wheel | No | ||
| button | No | ||
| coords | No | ||
| screen | No | ||
| window | No | ||
| warning | No | ||
| next_call | No | ||
| cursor_via | No | ||
| screenshot | No | ||
| answered_by | No | ||
| frames_waited | Yes | ||
| truncated_note | No | ||
| screenshot_note | No | ||
| version_warning | No | ||
| screenshot_error | No |