Repository navigation
EN API UO GetGump
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
Home · C# · IDE · UO API · A–Z · Examples · Languages
dynamic UO.GetGump(object? identifier);
dynamic UO.GetGump(object? gumpId, object? identifier);
dynamic UO.GetGump(object? gumpId, object? identifier, object? key);Reads one field of the selected server gump. Allows you to explicitly set the window selector.
-
gumpId- Optional first int in the forms (gumpId,identifier) and (gumpId,identifier,key). int or numeric string: Looks for an exact GumpID/serial match first, then the index with 0. -1 is the gump selected by this script, and if it is not there, the last one in the current list. Other negative int retain 32-bit ID. This is a selector, as opposed to the strict GumpIndex in NumGump*. -
identifier- string case insensitive. All supported values and result types are listed in the Returns section. Unknown name returns an empty string. -
key— Optional int, default - 1. Index with 0 for button/text/object/command; this is not ID control. A negative index and out-of-bounds result in 0 for button or an empty string for text fields. Other identifiers do not use key.
The type of the result depends on the identifier. int: buttonlen — number of regular buttons; button — ButtonID by index key; textlen — number of available text elements; injid — current window index; replyed — 0 (response history is not stored); inclient — 1 for a found live window, 0 if absent; objectcount — number of live controls, including nested ones. string: serial and gumpid - hex strings 0xXXXXXXXX; text — element text at index key; object — control type name; command — description of the control (type, page, ID, coordinates, dimensions and supported fields). If there is no window, numeric identifiers give 0, string identifiers give an empty string. injid=0 is also a valid first index: 0 by itself does not prove the absence of a window. This is not Array or Pascal TGumpInfo.
- 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.
- SelectGump/InfoGump specifies the selected window only in the current runtime. If the selected window is closed, the last item in the current list is used, which is not necessarily the most recent item in time.
- textlen/text refer to the available text controls, not the server package's original string pool. object/command refer to the entire tree of live controls. Indexes from different lists cannot be mixed.
- Each call reads the current state separately. For matched serial, GumpID and lists, use GetGumpInfo.
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.
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.GetGump("gumpid");
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));Parameters and execution flow:
- gumpid and serial return strings already formatted in hex; no additional Hex needed. Empty lines mean there is no window when reading.
var id = UO.GetGump("gumpid");
var serial = UO.GetGump("serial");
UO.Print(id + " / " + serial);Parameters and execution flow:
- buttonlen — number of buttons; i is the index of the row from 0 to count-1. button - ID for answer, not graphics or index. When changing windows, re-read the list.
return RunScenario();
object? RunScenario()
{
var count = UO.GetGump("buttonlen");
var i = 0;
while (Truth(i < count))
{
var button = UO.GetGump("button", i);
UO.Print(Convert.ToString(button));
i = i + 1;
}
return null;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;Parameters and execution flow:
- 0x12345678 is an example of GumpID/serial, replace ID with the desired form. text with key=0 reads the first available text control; this is a different list than button.
- SelectGump reports the absence of the specified window, but does not block subsequent reading: check the returned gumpid separately if necessary.
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()
{
UO.SelectGump(0x12345678);
if (Truth(UO.GetGump("inclient")))
{
var count = UO.GetGump("textlen");
if (Truth(count > 0))
{
UO.Print(UO.GetGump("text", 0));
}
}
return null;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: identifier (String)
Result: dynamic / Any.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.GetGump. -
InjectionScript.Runtime.InjectionApiUO.LastGump:LastGump(identifier, -1).
Internal implementation code; this is not a standalone script.
public InjectionValue GetGump(string identifier) => LastGump(identifier, -1);Parameters: gumpId (Integer/String), identifier (String/Integer)
Result: dynamic / Any.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.GetGump. -
InjectionScript.Runtime.InjectionApiUO.GetGump:GetGump(gumpId, identifier, -1).
Internal implementation code; this is not a standalone script.
public InjectionValue GetGump(int gumpId, string identifier) => GetGump(gumpId, identifier, -1);Parameters: gumpId (Integer/String), identifier (String/Integer)
Result: dynamic / Any.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.GetGump. -
InjectionScript.Runtime.InjectionApiUO.LastGump:LastGump(identifier, key).
Internal implementation code; this is not a standalone script.
public InjectionValue GetGump(string identifier, int key) => LastGump(identifier, key);Parameters: gumpId (Integer), identifier (String), key (Integer)
Result: dynamic / Any.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.GetGump. -
InjectionScript.Runtime.InjectionApiUO.ConvertGumpValue:ConvertGumpValue(identifier, bridge.GetGumpValue(gumpId, identifier, key)). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.GetGumpValue:bridge.GetGumpValue(gumpId, identifier, key).
Internal implementation code; this is not a standalone script.
public InjectionValue GetGump(int gumpId, string identifier, int key)
=> ConvertGumpValue(identifier, bridge.GetGumpValue(gumpId, identifier, key));ClassicUO — Bad Newbie & C# Scripts IDE