VisualTree

Register the VisualTree tool suite to inspect the live UI hierarchy and capture screenshots from a paired .NET app.

Install

dotnet add package Ansight.Tools.VisualTree

Register the Suite

using Ansight;
using Ansight.Tools.VisualTree;

var options = Options.CreateBuilder()
    .WithVisualTreeTools()
    .WithReadOnlyToolAccess()
    .Build();

Registration API

  • WithVisualTreeTools(): registers the full visual tree and screenshot suite. No suite-specific configuration is currently required.

Specific Concerns

  • The tools inspect the foreground scene only.
  • Screenshot capture exports rendered UI content, so treat it as sensitive.
  • includeComputedStyles and detailed node inspection can reveal UI labels and accessibility metadata.

Tool Matrix

NameIdScopeDescriptionSecurity
Get Visual Treeui.get_visual_treeReadReturns the current UI hierarchy for the foreground scene.High
Get Screenshotui.get_screenshotReadCaptures a screenshot of the current app scene.High
Inspect Nodeui.inspect_nodeReadReturns detailed metadata for a visual tree node.High

Get Visual Tree

Arguments:

  • includeBounds: include node bounds, default true
  • includeComputedStyles: include implementation-specific properties, default false
  • maxDepth: child depth limit, default 8
  • rootNodeId: optional subtree root

Returns:

  • platform
  • capturedAtUtc
  • root

Example:

{
  "toolId": "ui.get_visual_tree",
  "arguments": {
    "includeBounds": true,
    "includeComputedStyles": false,
    "maxDepth": 6
  }
}

Get Screenshot

Arguments:

  • format: png or jpeg
  • quality: JPEG quality 1-100
  • maxWidth: optional width cap
  • annotateNodeIds: overlay node ids on the screenshot

Returns:

  • platform
  • capturedAtUtc
  • format
  • width
  • height
  • base64
  • annotationApplied

Example:

{
  "toolId": "ui.get_screenshot",
  "arguments": {
    "format": "jpeg",
    "quality": 85,
    "maxWidth": 1080,
    "annotateNodeIds": false
  }
}

Inspect Node

Arguments:

  • nodeId: required node identifier
  • includeAncestors: include ancestor chain
  • includeDescendants: include descendants
  • includeProperties: include implementation-specific properties

Returns:

  • platform
  • capturedAtUtc
  • node
  • optional ancestors
  • optional descendants

Example:

{
  "toolId": "ui.inspect_node",
  "arguments": {
    "nodeId": "root/stack[0]/button[1]",
    "includeAncestors": true,
    "includeDescendants": false,
    "includeProperties": true
  }
}