The root UI surface and nested container interface. All Add* methods return a handle for reading values, listening to changes, or further layout.

Automatic persistence: Every element that takes an id as its first argument (AddSlider, AddTextInput, AddToggle, AddDropdown, AddTextArea, AddColorPicker, AddHotkeyCapture, AddFilePicker, AddDirectoryPicker, AddListBox, AddDataGrid) automatically saves its value to per-script storage whenever the user changes it and restores the saved value on the next run. The id is the storage key — keep it stable across script edits. Layout-only elements (AddText, AddButton, AddRow, AddColumn, AddTabGroup) have no state and are not persisted.

UI.AddText("Configure your macro:");
const delaySlider = UI.AddSlider("delay", 0, 1000, "Delay (ms)");
const startBtn = UI.AddButton("Start", () => { Console.Log("started"); });
interface UIContainer {
    Clear(): void;
    AddText(text: string): UIElement;
    AddButton(text: string, onClick: () => void): UIElement;
    AddSlider(
        id: string,
        min: number,
        max: number,
        label: string,
    ): ValueWrapper<number>;
    AddTextInput(
        id: string,
        label: string,
        defaultText?: string,
    ): ValueWrapper<string>;
    AddToggle(id: string, label: string): ValueWrapper<boolean>;
    AddDropdown(
        id: string,
        label: string,
        options: string[],
    ): ValueWrapper<string>;
    AddTextArea(
        id: string,
        label: string,
        defaultText?: string,
    ): ValueWrapper<string>;
    AddColorPicker(
        id: string,
        label: string,
        defaultColor?: string,
    ): ValueWrapper<string>;
    AddHotkeyCapture(
        id: string,
        label: string,
        defaultBind?: string,
    ): HotkeyCaptureWrapper;
    AddFilePicker(
        id: string,
        label: string,
        options?: { filters?: string[] },
    ): ValueWrapper<string>;
    AddDirectoryPicker(id: string, label: string): ValueWrapper<string>;
    AddListBox(
        id: string,
        label: string,
        items?: string[],
    ): ValueWrapper<string[]>;
    AddDataGrid(id: string, columns: DataGridColumn[]): DataGridWrapper;
    AddTabGroup(): TabGroupWrapper;
    AddRow(builder?: (row: ContainerWrapper) => void): ContainerWrapper;
    AddColumn(builder?: (col: ContainerWrapper) => void): ContainerWrapper;
}

Hierarchy (View Summary)

Methods

  • Removes all child elements from this container.

    Returns void

  • Adds a read-only text label. Not persisted.

    Parameters

    • text: string

    Returns UIElement

    UI.AddText("Status: ready");
    
  • Adds a clickable button. Not persisted.

    Parameters

    • text: string
    • onClick: () => void

    Returns UIElement

    UI.AddButton("Run", () => { Console.Log("clicked"); });
    
  • Adds a numeric range slider. Value is persisted by id and restored on next run.

    Parameters

    • id: string
    • min: number
    • max: number
    • label: string

    Returns ValueWrapper<number>

    const s = UI.AddSlider("vol", 0, 100, "Volume"); s.GetValue();
    
  • Adds a single-line text input. Value is persisted by id and restored on next run. defaultText is only used when no saved value exists.

    Parameters

    • id: string
    • label: string
    • OptionaldefaultText: string

    Returns ValueWrapper<string>

    const name = UI.AddTextInput("name", "Your name", "Alice");
    
  • Adds a boolean toggle switch. Value is persisted by id and restored on next run.

    Parameters

    • id: string
    • label: string

    Returns ValueWrapper<boolean>

    const t = UI.AddToggle("on", "Enable");
    
  • Adds a dropdown selector. Value is persisted by id and restored on next run.

    Parameters

    • id: string
    • label: string
    • options: string[]

    Returns ValueWrapper<string>

    const d = UI.AddDropdown("mode", "Mode", ["Fast", "Slow"]);
    
  • Adds a multi-line text area. Value is persisted by id and restored on next run. defaultText is only used when no saved value exists.

    Parameters

    • id: string
    • label: string
    • OptionaldefaultText: string

    Returns ValueWrapper<string>

    const ta = UI.AddTextArea("notes", "Notes");
    
  • Adds a color picker. Value is persisted by id and restored on next run. defaultColor is only used when no saved value exists.

    Parameters

    • id: string
    • label: string
    • OptionaldefaultColor: string

    Returns ValueWrapper<string>

    const cp = UI.AddColorPicker("bg", "Background", "#FFFFFF");
    
  • Adds a hotkey capture field. The captured combo is persisted by id and restored on next run, including its active binding.

    Parameters

    • id: string
    • label: string
    • OptionaldefaultBind: string

    Returns HotkeyCaptureWrapper

    const hk = UI.AddHotkeyCapture("trigger", "Trigger", "Ctrl+F");
    
  • Adds a file picker dialog button. Selected path is persisted by id and restored on next run.

    Parameters

    • id: string
    • label: string
    • Optionaloptions: { filters?: string[] }

    Returns ValueWrapper<string>

    const fp = UI.AddFilePicker("img", "Image", { filters: ["png", "jpg"] });
    
  • Adds a directory picker dialog button. Selected path is persisted by id and restored on next run.

    Parameters

    • id: string
    • label: string

    Returns ValueWrapper<string>

    const dp = UI.AddDirectoryPicker("dir", "Output folder");
    
  • Adds a multi-select list box. Selected items are persisted by id and restored on next run.

    Parameters

    • id: string
    • label: string
    • Optionalitems: string[]

    Returns ValueWrapper<string[]>

    const lb = UI.AddListBox("tags", "Tags", ["alpha", "beta"]);
    
  • Adds a data grid with typed columns. Row data is persisted by id and restored on next run.

    Parameters

    Returns DataGridWrapper

    const g = UI.AddDataGrid("rows", [{ key: "name", title: "Name", type: "text" }]);
    
  • Adds a tabbed container group. Not persisted.

    Returns TabGroupWrapper

    const tabs = UI.AddTabGroup(); tabs.AddTab("Main", t => t.AddText("hello"));
    
  • Adds a horizontal row layout container. Children are arranged left-to-right. Not persisted.

    Parameters

    Returns ContainerWrapper

    UI.AddRow(row => { row.AddButton("A", () => {}); row.AddButton("B", () => {}); });
    
  • Adds a vertical column layout container. Children are stacked top-to-bottom. Not persisted.

    Parameters

    Returns ContainerWrapper

    UI.AddColumn(col => { col.AddText("label"); col.AddToggle("x", "X"); });