Skip to content

EN API UO GetGumpInfo

LIHACHTETAN edited this page Nov 28, 2026 · 3 revisions

Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어

UO.GetGumpInfo

Home · C# · IDE · UO API · A–Z · Examples · Languages

C# signatures

dynamic UO.GetGumpInfo(object? gumpIndex);

Returns a consistent snapshot of the identifiers and elements of a single server gump.

Parameters

  • gumpIndex — Mandatory int — index of the active server gump, from 0 to GetGumpsCount()-1. This is not GumpID/serial. Negative number and index outside the list are invalid. Opening, closing, and reordering windows can change the index; check GetGumpID/GetGumpSerial before acting.

Return value

Array - exactly five elements: [0] int serial; [1] int GumpID; [2] Array of non-empty texts; [3] Array descriptions of regular buttons; [4] Array of descriptions of all living elements, including nested ones. An invalid/closed or ignored gump by this script produces an empty array []. ID with the most significant bit is represented by a negative int. An empty text array in itself does not mean there is no window.

Behavior

  • Works with active server gumps. Backpack, map, settings and other local windows are not included in this list. One call reads data in the game thread; different calls may see different states of the list.
  • The entire snapshot is copied in one game thread request. Changing/closing the window after returning does not change the saved array.
  • The control description indicates the type, page, ID, X/Y, dimensions. Buttons additionally contain ButtonID, action, toPage and graphic; switches - ID, checked, inactive/active. Texts may contain spaces and =; The string cannot be unconditionally parsed by spaces.
  • AddGumpIgnoreByID/AddGumpIgnoreBySerial hide the result of only this reading in the current script; ClearGumpsIgnore removes these filters. GetGumpsCount does not decrease.

Standalone C# scripts

Each example can be saved as a separate file .csx and run in IDE. The UO object and wait functions provide the host of the current game session. Replace demo serial names, coordinates and addresses with your own.

Simple example

Run this code as a separate .csx file. Arguments appear directly in the call; replace demonstration names, serials and addresses with your own.

The result of one call is printed in the journal. A number is not converted to bool; an array is displayed as its element count.

object? result = UO.GetGumpInfo(0);
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));

1. Read both ID - direct script

Parameters and execution flow:

  • GumpIndex=0 — the first server gump. Length checking protects access to missing window fields.
  • info[0] — serial, info[1] — GumpID; both belong to the same recording.
var info = UO.GetGumpInfo(0);
if (Truth(ArrayLength(info) == 5))
{
    UO.Print("Serial=" + Hex(info[0]));
    UO.Print("GumpID=" + Hex(info[1]));
}

int ArrayLength(object? value) => value is System.Array array ? array.Length : 0;
string Hex(object? value) => Convert.ToInt64(value).ToString("X");
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;

2. List real ButtonIDs - script function

Parameters and execution flow:

  • info[3] — array of button descriptions; the ButtonID field in the line specifies ID for the response. i is just the row index, not the ButtonID.
  • Radio buttons are radio buttons and appear in info[4], not in the list of regular buttons.
return  RunScenario();
 object? RunScenario()
{
    var info = UO.GetGumpInfo(0);
    if (Truth(ArrayLength(info) == 5))
    {
        var buttons = info[3];
        var i = 0;
        while (Truth(i < ArrayLength(buttons)))
        {
            UO.Print(buttons[i]);
            i = i + 1;
        }
    }

    return null;
}

int ArrayLength(object? value) => value is System.Array array ? array.Length : 0;
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;

3. Save text until close - script class

Parameters and execution flow:

  • info[2] - copy of texts. Closing is only allowed for the non-inhibited window NoClose.
  • Closing does not clear saved texts; An empty array of texts is also acceptable for an existing window.
return  new ScriptScenario(UO, WaitAsync, Args, Cancellation, Checkpoint).RunScenario();
class ScriptScenario
{
    private readonly global::ClassicUO.CSharp.CSharpGameApi UO;
    private readonly Func<int, Task> WaitAsync;
    private readonly string[] Args;
    private readonly CancellationToken Cancellation;
    private readonly Action Checkpoint;
    public ScriptScenario(global::ClassicUO.CSharp.CSharpGameApi api, Func<int, Task> wait, string[] args, CancellationToken cancellation, Action checkpoint)
    {
        UO = api;
        WaitAsync = wait;
        Args = args;
        Cancellation = cancellation;
        Checkpoint = checkpoint;
    }

     public object? RunScenario()
    {
        var info = UO.GetGumpInfo(0);
        if (Truth(ArrayLength(info) == 5))
        {
            var texts = info[2];
            UO.CloseSimpleGump(0);
            if (Truth(ArrayLength(texts) > 0))
            {
                UO.Print(texts[0]);
            }
        }

        return null;
    }

    int ArrayLength(object? value) => value is System.Array array ? array.Length : 0;
    bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;
}

Command implementation

C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.

UO.GetGumpInfo(gumpIndex) — UO.GetGumpInfo(Any)

Parameters: gumpIndex (Any)

Result: dynamic / Array.

During a call:

Internal implementation code; this is not a standalone script.

case "getgumpinfo":

                {

                    int index = Arg(0);

                    GumpSnapshot snapshot;

                    if (bridge is IApiGumpAccess reader)

                        snapshot = reader.ReadGump(index);

                    else

                    {

                        int id = bridge.GetGumpId(index);

                        snapshot = id == 0 ? null : new GumpSnapshot(bridge.GetGumpSerial(index), id,

                            bridge.GetGumpTextLines(index), bridge.GetGumpButtonsDescription(index), bridge.GetGumpFullLines(index));

                    }

                    if (snapshot == null || state.IgnoredGumpIds.Contains(snapshot.Id)

                        || state.IgnoredGumpSerials.Contains(snapshot.Serial))

                        return new InjectionValue(Array.Empty<InjectionValue>());

                    return new InjectionValue(new[]

                    {

                        new InjectionValue(snapshot.Serial), new InjectionValue(snapshot.Id), StringArray(snapshot.Text),

                        StringArray(snapshot.Buttons), StringArray(snapshot.Controls)

                    });

                }

Clone this wiki locally