Skip to main content
Glama

click_element

Invoke Windows UI elements by name or automationId via UIA InvokePattern—no screen coordinates needed. Use for buttons, menu items, and links when mouse clicks are unreliable.

Instructions

Invoke a UI element by name or automationId via UIA InvokePattern — no screen coordinates needed. The server auto-guards using windowTitle (verifies it is still the same window; it does not check for a modal dialog — an hwnd whose window is disabled by its dialog acts on that dialog, warning parent_disabled_prefer_popup) and returns post.perception.status. Prefer over mouse_click for buttons, menu items, and links in native Windows apps. Use desktop_discover first to discover automationIds. Pass fixId from a suggestedFix to re-target after window identity drift. lensId is optional for advanced pinned-lens use. Caveats: Typed errors: code:'InvokePatternNotSupported' — the control does not expose InvokePattern, fall back to mouse_click; code:'ElementDisabled' — the element is in a disabled state, re-check preconditions before retry; code:'GuardFailed' — read the perception envelope (attention / guard fields) and choose recovery (re-focus, wait, or pass the suggestedFix.fixId on the next call). Some custom controls do not expose InvokePattern at all; fall back to mouse_click for those.

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": {
      "windowTitle": "<windowTitle>"
    },
    "name": "click_element"
  }
}

Input Schema

NameRequiredDescriptionDefault
hwndNoDirect window handle ID (takes precedence over windowTitle). String to avoid 64-bit precision issues.
nameNoElement name/label (partial match, case-insensitive)
fixIdNoApprove a pending suggestedFix (one-shot, 15s TTL).
lensIdNoOptional perception lens ID. Guards (safe.keyboardTarget, target.identityStable) are evaluated before clicking, and a perception envelope is attached to post.perception on success.
includeNoOptional response-shape opt-in. `['envelope']` returns the self-documenting envelope (`_version` / `data` / `as_of` / `confidence`). `['raw']` forces raw shape (overrides DESKTOP_TOUCH_ENVELOPE=1 server default). Default behaviour is raw shape (compat with existing clients).
narrateNoNarration level. "rich": include UIA diff in post.rich (appeared/disappeared/valueDeltas, and nameDeltas when an element's name changed, such as a calculator display) — usually removes the need for a verification screenshot. It is withheld, with post.rich.diffDegraded saying why, when the diff cannot be shown to describe the window that was acted on. On click_element and keyboard (and set_element_value where the server registers it), which resolve the target window before acting: another open window's title contains the text this call resolved to, whether you named the hwnd or the server did — "@active" and the dialog rescue both resolve one ("ambiguous_title"); or the target moved between the snapshot and the action ("target_changed"). On those and on mouse_click, retrying with a fixId also withholds it, because the stored fix names a window this cannot see ("fix_target_unknown") — browser tools keep their diff on a fixId retry, because theirs is a tab diff and does not depend on a window title. mouse_click and mouse_drag accept an hwnd and still take their snapshots by windowTitle, so nothing else is withheld for them: verify those with a screenshot. A window too large to read whole is withheld too ("tree_truncated"). The action itself is unaffected in every case; only the diff is. Default: "minimal".minimal
controlTypeNoControl type filter, e.g. 'Button', 'MenuItem'
windowTitleYesPartial window title of the target window. Use '@active' for the current foreground window.
automationIdNoExact AutomationId of the element

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changedv2.3.1
    • addedInput schema / $schema
      Added value: +"http://json-schema.org/draft-07/schema#"
    • removedInput schema / additionalProperties
      Removed value: -false
    • changedInput schema / properties / narrate / description
      Previous value: -"Narration level. rich includes UIA or browser state diff when supported, and is withheld with post.rich.diffDegraded when the diff cannot be shown to describe the window that was acted on."New value: +"Narration level. \"rich\": include UIA diff in post.rich (appeared/disappeared/valueDeltas, and nameDeltas when an element's name changed, such as a calculator display) — usually removes the need for a verification screenshot. It is withheld, with post.rich.diffDegraded saying why, when the diff cannot be shown to describe the window that was acted on. On click_element and keyboard (and set_element_value where the server registers it), which resolve the target window before acting: another open window's title contains the text this call resolved to, whether you named the hwnd or the server did — \"@active\" and the dialog rescue both resolve one (\"ambiguous_title\"); or the target moved between the snapshot and the action (\"target_changed\"). On those and on mouse_click, retrying with a fixId also withholds it, because the stored fix names a window this cannot see (\"fix_target_unknown\") — browser tools keep their diff on a fixId retry, because theirs is a tab diff and does not depend on a window title. mouse_click and mouse_drag accept an hwnd and still take their snapshots by windowTitle, so nothing else is withheld for them: verify those with a screenshot. A window too large to read whole is withheld too (\"tree_truncated\"). The action itself is unaffected in every case; only the diff is. Default: \"minimal\"."
  2. Changed1 schema field changedv2.0.0
    • changedInput schema / properties / narrate / description
      Previous value: -"Narration level. rich includes UIA or browser state diff when supported."New value: +"Narration level. rich includes UIA or browser state diff when supported, and is withheld with post.rich.diffDegraded when the diff cannot be shown to describe the window that was acted on."
  3. Addedv1.12.0
  4. Removedv1.10.4
  5. Addedv1.9.2
  6. Removedv1.8.0
  7. Addedv1.6.0
  8. Removedv1.5.1
  9. Addedv1.5.0
  10. Removedv1.4.3
  11. Addedv1.4.2
  12. Removedv1.4.0
  13. Changed1 schema field changedv1.2.1
    • addedInput schema / properties / include
      Added value: +{
      +  "description": "Optional response-shape opt-in. `['envelope']` returns the self-documenting envelope (`_version` / `data` / `as_of` / `confidence`). `['raw']` forces raw shape (overrides DESKTOP_TOUCH_ENVELOPE=1 server default). Default behaviour is raw shape (compat with existing clients).",
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
  14. Addedv1.1.3
  15. Removedv1.1.1
  16. Addedv1.0.3
  17. Removedv0.15.7
  18. Changed2 schema fields changedv0.15.4
    • addedInput schema / properties / hwnd
      Added value: +{
      +  "description": "Direct window handle ID (takes precedence over windowTitle). String to avoid 64-bit precision issues.",
      +  "maxLength": 20,
      +  "type": "string"
      +}
    • changedInput schema / properties / windowTitle / description
      Previous value: -"Partial window title of the target window"New value: +"Partial window title of the target window. Use '@active' for the current foreground window."
  19. Changed1 schema field changedv0.13.1
    • addedInput schema / properties / fixId
      Added value: +{
      +  "description": "Approve a pending suggestedFix (one-shot, 15s TTL).",
      +  "type": "string"
      +}
  20. Changed10 schema fields changedv0.10.0
    • removedInput schema / $schema
      Removed value: -"http://json-schema.org/draft-07/schema#"
    • addedInput schema / additionalProperties
      Added value: +false
    • removedInput schema / properties / _stub
      Removed value: -{
      -  "description": "Stub tool — arguments ignored."
      -}
    • addedInput schema / properties / automationId
      Added value: +{
      +  "description": "Exact AutomationId of the element",
      +  "maxLength": 200,
      +  "type": "string"
      +}
    • addedInput schema / properties / controlType
      Added value: +{
      +  "description": "Control type filter, e.g. 'Button', 'MenuItem'",
      +  "maxLength": 100,
      +  "type": "string"
      +}
    • addedInput schema / properties / lensId
      Added value: +{
      +  "description": "Optional perception lens ID. Guards (safe.keyboardTarget, target.identityStable) are evaluated before clicking, and a perception envelope is attached to post.perception on success.",
      +  "type": "string"
      +}
    • addedInput schema / properties / name
      Added value: +{
      +  "description": "Element name/label (partial match, case-insensitive)",
      +  "maxLength": 200,
      +  "type": "string"
      +}
    • addedInput schema / properties / narrate
      Added value: +{
      +  "default": "minimal",
      +  "description": "Narration level. rich includes UIA or browser state diff when supported.",
      +  "enum": [
      +    "minimal",
      +    "rich"
      +  ],
      +  "type": "string"
      +}
    • addedInput schema / properties / windowTitle
      Added value: +{
      +  "description": "Partial window title of the target window",
      +  "maxLength": 200,
      +  "type": "string"
      +}
    • addedInput schema / required
      Added value: +[
      +  "windowTitle"
      +]
  21. First observedv0.6.2

TDQS

A4.9/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden; it discloses the windowTitle identity guard, the modal-dialog caveat, post.perception.status, typed errors with recovery guidance, and fixId re-targeting. This is rich operational context well beyond the structured schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The core purpose and usage rules are front-loaded, and most sentences carry operational value. The final sentence repeats the InvokePattern fallback already covered by the typed-error caveat, so the definition is slightly redundant and longer than necessary.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 9-parameter UI automation tool with no annotations and no output schema, the description covers guards, error codes, fallbacks, and parameter roles. It gives an agent enough information to invoke the tool correctly and recover from common failures.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Although schema description coverage is 100%, the description adds meaningful semantics for key parameters: fixId is tied to suggestedFix re-targeting after identity drift, lensId is framed as optional advanced pinned-lens use, and windowTitle is explained as the guard identity source. This goes beyond the property descriptions and helps the agent choose values correctly.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening states a specific verb ('Invoke'), resource ('UI element by name or automationId'), mechanism ('UIA InvokePattern'), and scope ('no screen coordinates'). It also distinguishes the tool from mouse_click, so an agent can select it without opening either schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly says to prefer this over mouse_click for buttons, menu items, and links in native Windows apps, to use desktop_discover first for automationIds, and to pass fixId from a suggestedFix after window identity drift. It also names fallback paths for unsupported InvokePattern and disabled/GuardFailed errors.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.