EN UO Topic menus context menus - LIHACHTETAN/ClassicUO-Bad-Newbie-CSharp-Scripts-IDE GitHub Wiki

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

Menus & Context Menus

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

Old menus, context menus and text input. These are separate mechanisms; take the item number from the answer of the desired menu.

Sections

Topic Commands and explanations
AutoMenu UO.AutoMenu
WaitMenu UO.WaitMenu
Menu Hooks UO.MenuHookPresent · UO.CancelAllMenuHooks
Menu Items UO.GetMenuItems · UO.GetMenuItemsEx · UO.GetLastMenuItems
CancelMenu UO.CancelMenu
Context Menu UO.GetContextMenu · UO.ClearContextMenu
RequestContextMenu UO.RequestContextMenu
Context Menu Hooks UO.SetContextMenuHook

All theme commands

Menus

UO.AutoMenu · UO.WaitMenu · UO.GetMenuItems · UO.GetMenuItemsEx · UO.GetLastMenuItems · UO.MenuHookPresent · UO.MenuPresent · UO.CancelAllMenuHooks · UO.CancelMenu · UO.CloseMenu · UO.WaitingForMenu · UO.WaitingMenu

Context Menu

UO.GetContextMenu · UO.RequestContextMenu · UO.SetContextMenuHook · UO.ClearContextMenu

Text Entry

UO.WaitTextEntry · UO.ConsoleEntryReply · UO.ConsoleEntryUnicodeReply

Examples on the topic

Each command card has several independent scenarios: direct code, functions and classes. Below are selected short scenarios; restrictions and full analysis are in the cards.

UO.RequestContextMenu

Parameters, result and all scenarios

var id = UO.GetSerial("lasttarget");
if (Truth(UO.Exists(id)))
{
    UO.RequestContextMenu(id);
}

bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;

UO.WaitMenu

Parameters, result and all scenarios

UO.WaitMenu("Craft", "Tools");

Complete command reference


UO.AutoMenu

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

C# signatures

void UO.AutoMenu(object? prompt, object? choice);

Registers a persistent menu hook: when a server menu with a suitable caption appears, the client selects the appropriate item. The call does not open the menu and does not wait for it synchronously.

Parameters

  • prompt — substring of the server menu title.
  • choice — substring of the menu item signature.

Return value

void. The call only registers a hook and does not report whether the menu was found or whether the item was successfully selected.

Behavior

  • Each time the client is updated, the hook looks for a server menu that has not yet been closed and whose title contains prompt. If an item is found whose signature contains choice, the client selects it. The hook remains registered after selection, so it will work on subsequent matching menus. You can remove hooks using UO.CancelMenu().

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.AutoMenu");
UO.AutoMenu("Choose material", "Copper");

1. Wait for a menu with the title "Choose material" and select the item with the text "Copper". - direct script

Parameters and execution flow:

  • Wait for a menu with the title "Choose material" and select the item with the text "Copper".
UO.AutoMenu("Choose material", "Copper");

2. Substrings are compared case-insensitively; hook also affects subsequent matched menus. - script function

Parameters and execution flow:

  • Substrings are compared case-insensitively; hook also affects subsequent matched menus.
return  RunScenario();
 object? RunScenario()
{
    var menuCaption = "choose color";
    var itemCaption = "blue";
    UO.AutoMenu(menuCaption, itemCaption);
    return null;
}

3. Register a hook for the duration of this task, then delete all hooks for this client. - script class

Parameters and execution flow:

  • Register a hook for the duration of this task, then delete all hooks for this client.
  • Other script actions can be performed before the menu appears.
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.AutoMenu("Choose material", "Iron");
        UO.CancelMenu();
        return null;
    }
}

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.AutoMenu(prompt, choice) — UO.AutoMenu(Any,Any)

Parameters: prompt (Any), choice (Any)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

case "automenu":

                    if (arguments.Length >= 2) bridge.AddMenuHook(arguments[0].ToString(), arguments[1].ToString(), true);

                    break;

UO.CancelAllMenuHooks

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

C# signatures

void UO.CancelAllMenuHooks();

Removes all registered automatic hooks from old client server menus.

Parameters

There are no parameters.

Return value

void - no return value.

Behavior

  • Calls ClearMenuHooks manager. Single and persistent selection rules are removed, including AutoMenu and WaitMenu. This command does not close already open menus; CloseMenu is used for this.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.CancelAllMenuHooks");
UO.CancelAllMenuHooks();

1. Remove all hooks - direct script

Parameters and execution flow:

  • Removal applies to the entire set of client menu hooks.
UO.CancelAllMenuHooks();

2. Restrict action AutoMenu - script function

Parameters and execution flow:

  • The hook is immediately removed; future matched menus are no longer automatically selected.
return  RunScenario();
 object? RunScenario()
{
    UO.AutoMenu("Choose material", "Iron");
    UO.CancelAllMenuHooks();
    return null;
}

3. Stop automatic selection and close menu - script class

Parameters and execution flow:

  • The first command removes hooks; the second separately cancels open old menus.
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.CancelAllMenuHooks();
        UO.CloseMenu();
        return null;
    }
}

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.CancelAllMenuHooks() — UO.CancelAllMenuHooks()

Parameters: No parameters.

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

case "cancelallmenuhooks": bridge.ClearMenuHooks(); return InjectionValue.Unit;

UO.CancelMenu

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

C# signatures

void UO.CancelMenu();

Removes all registered automatic hooks from old client server menus.

Parameters

There are no parameters.

Return value

void - no return value.

Behavior

  • Calls ClearMenuHooks manager. Single and persistent selection rules are removed, including AutoMenu and WaitMenu. This command does not close already open menus; CloseMenu is used for this.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.CancelMenu");
UO.CancelMenu();

1. Remove all hooks - direct script

Parameters and execution flow:

  • Removal applies to the entire set of client menu hooks.
UO.CancelMenu();

2. Restrict action AutoMenu - script function

Parameters and execution flow:

  • The hook is immediately removed; future matched menus are no longer automatically selected.
return  RunScenario();
 object? RunScenario()
{
    UO.AutoMenu("Choose material", "Iron");
    UO.CancelMenu();
    return null;
}

3. Stop automatic selection and close menu - script class

Parameters and execution flow:

  • The first command removes hooks; the second separately cancels open old menus.
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.CancelMenu();
        UO.CloseMenu();
        return null;
    }
}

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.CancelMenu() — UO.CancelMenu()

Parameters: No parameters.

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

case "cancelmenu": bridge.ClearMenuHooks(); break;

UO.ClearContextMenu

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

C# signatures

void UO.ClearContextMenu();

Removes the current local context menu model.

Parameters

There are no parameters.

Return value

void - no return value.

Behavior

  • Calls Dispose on ServerMenus.Context if there is a model; a new server menu may appear after the next request. This is not CloseMenu.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.ClearContextMenu");
UO.ClearContextMenu();

1. Clear state - direct script

Parameters and execution flow:

  • Removes the current local context menu model.
UO.ClearContextMenu();

2. Clear after setup - script function

Parameters and execution flow:

  • Remove local context menu after reading snapshot.
return  RunScenario();
 object? RunScenario()
{
    var entries = UO.GetContextMenu();
    UO.ClearContextMenu();
    return null;
}

3. Re-Purge - Script Class

Parameters and execution flow:

  • Clearing an empty set is acceptable and does not create a new setting.
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.ClearContextMenu();
        UO.ClearContextMenu();
        return null;
    }
}

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.ClearContextMenu() — UO.ClearContextMenu()

Parameters: No parameters.

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

case "clearcontextmenu": bridge.ClearContextMenu(); return InjectionValue.Unit;

UO.CloseMenu

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

C# signatures

void UO.CloseMenu();

Cancels all active old server menus via CancelForYoko.

Parameters

There are no parameters.

Return value

void - no return value.

Behavior

  • Iterates through snapshot ServerMenus and discards each model. Does not remove automatic menu hooks and does not close arbitrary gump/interface windows.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.CloseMenu");
UO.CloseMenu();

1. Cancel open menus - direct script

Parameters and execution flow:

  • Cancellation applies to old MenuGump/server menus.
UO.CloseMenu();

2. Remove hooks and cancel menu - script function

Parameters and execution flow:

  • Automatic selection and open menus are handled by separate commands.
return  RunScenario();
 object? RunScenario()
{
    UO.CancelAllMenuHooks();
    UO.CloseMenu();
    return null;
}

3. Cancel After View - Script Class

Parameters and execution flow:

  • A snapshot of the list is saved in items even after canceling the menu.
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 items = UO.GetLastMenuItems();
        UO.Print(Convert.ToString(ArrayLength(items)));
        UO.CloseMenu();
        return null;
    }

    int ArrayLength(object? value) => value is System.Array array ? array.Length : 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.CloseMenu() — UO.CloseMenu()

Parameters: No parameters.

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

case "closemenu": bridge.CloseMenu(); return InjectionValue.Unit;

UO.ConsoleEntryReply

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

C# signatures

void UO.ConsoleEntryReply(object? text);

Replies with text to the active server prompt via MessageManager.SendServerPromptResponse.

Parameters

  • text — The value to be converted to a string. An empty string is sent as an empty response.

Return value

void - no return value.

Behavior

  • Both teams head to ReplyServerPrompt. The package type ASCII/Unicode is selected based on the saved server prompt state; The command name does not force a separate encoding. If there is no active prompt, the manager does not send a response.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.ConsoleEntryReply");
UO.ConsoleEntryReply("reply");

1. Answer to prompt - direct script

Parameters and execution flow:

  • Sending refers to the current server input request.
UO.ConsoleEntryReply("reply");

2. Empty response - script function

Parameters and execution flow:

  • Empty text is sent to the manager as an empty response.
return  RunScenario();
 object? RunScenario()
{
    UO.ConsoleEntryReply("");
    return null;
}

3. Response from variable - script class

Parameters and execution flow:

  • The variable name does not affect the selected server prompt format.
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 reply = "New item name";
        UO.ConsoleEntryReply(reply);
        return null;
    }
}

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.ConsoleEntryReply(text) — UO.ConsoleEntryReply(Any)

Parameters: text (Any)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

case "consoleentryreply":

                case "consoleentryunicodereply": bridge.ReplyServerPrompt(Text(0)); return InjectionValue.Unit;

UO.ConsoleEntryUnicodeReply

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

C# signatures

void UO.ConsoleEntryUnicodeReply(object? text);

Replies with text to the active server prompt via MessageManager.SendServerPromptResponse.

Parameters

  • text — The value to be converted to a string. An empty string is sent as an empty response.

Return value

void - no return value.

Behavior

  • Both teams head to ReplyServerPrompt. The package type ASCII/Unicode is selected based on the saved server prompt state; The command name does not force a separate encoding. If there is no active prompt, the manager does not send a response.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.ConsoleEntryUnicodeReply");
UO.ConsoleEntryUnicodeReply("reply");

1. Answer to prompt - direct script

Parameters and execution flow:

  • Sending refers to the current server input request.
UO.ConsoleEntryUnicodeReply("reply");

2. Empty response - script function

Parameters and execution flow:

  • Empty text is sent to the manager as an empty response.
return  RunScenario();
 object? RunScenario()
{
    UO.ConsoleEntryUnicodeReply("");
    return null;
}

3. Response from variable - script class

Parameters and execution flow:

  • The variable name does not affect the selected server prompt format.
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 reply = "New item name";
        UO.ConsoleEntryUnicodeReply(reply);
        return null;
    }
}

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.ConsoleEntryUnicodeReply(text) — UO.ConsoleEntryUnicodeReply(Any)

Parameters: text (Any)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

case "consoleentryreply":

                case "consoleentryunicodereply": bridge.ReplyServerPrompt(Text(0)); return InjectionValue.Unit;

UO.GetContextMenu

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

C# signatures

dynamic UO.GetContextMenu();

Reads the item strings of the current context menu model.

Parameters

There are no parameters.

Return value

Array of strings from ServerMenus.Context.GetYokoItems(); if there is no model, an empty array.

Behavior

  • Does not send RequestContextMenu and does not wait for a server response. To get a new menu, first request it separately and wait for the model to appear. ClearContextMenu deletes the model after reading.

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.GetContextMenu();
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));

1. Read current menu - direct script

Parameters and execution flow:

  • The existing model is read.
var entries = UO.GetContextMenu();
for (int i = (int)(0); i <= ArrayLength(entries)-1; i += (int)(1))
{
    UO.Print(entries[i]);
}

int ArrayLength(object? value) => value is System.Array array ? array.Length : 0;

2. Request and Read Later - Script Function

Parameters and execution flow:

  • 500 ms - example pause, not a guarantee of a server response; an empty array is acceptable.
return await RunScenarioAsync();
async Task<object?> RunScenarioAsync()
{
    UO.RequestContextMenu(UO.Self());
    await Delay(500);
    var entries = UO.GetContextMenu();
    UO.Print(Convert.ToString(ArrayLength(entries)));
    return null;
}

int ArrayLength(object? value) => value is System.Array array ? array.Length : 0;
Task Delay(object? milliseconds) => WaitAsync(checked((int)Convert.ToDouble(milliseconds)));

3. Snapshot Before Cleanup - Script Class

Parameters and execution flow:

  • The saved array does not disappear after clearing the menu model.
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 entries = UO.GetContextMenu();
        UO.ClearContextMenu();
        UO.Print(Convert.ToString(ArrayLength(entries)));
        return null;
    }

    int ArrayLength(object? value) => value is System.Array array ? array.Length : 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.GetContextMenu() — UO.GetContextMenu()

Parameters: No parameters.

Result: dynamic / Any.

During a call:

Internal implementation code; this is not a standalone script.

case "getcontextmenu": return StringArray(bridge.GetContextMenu());

UO.GetLastMenuItems

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

C# signatures

dynamic UO.GetLastMenuItems();

Reads the items of the already open old server menu.

Parameters

There are no parameters.

Return value

Array of strings. Item name/description lines GetYokoItems. Missing a suitable menu results in an empty array.

Behavior

  • The last photo menu ServerMenus is selected. The command does not open the menu, does not place a hook, and does not select an item. This is not a context menu or a regular server gump.
  • The order corresponds to the points of the model. The list is a snapshot; subsequent menu changes do not update the saved array.

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.GetLastMenuItems();
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));

1. Display all items - direct script

Parameters and execution flow:

  • An empty array is loop safe.
var items = UO.GetLastMenuItems();
for (int i = (int)(0); i <= ArrayLength(items)-1; i += (int)(1))
{
    UO.Print(items[i]);
}

int ArrayLength(object? value) => value is System.Array array ? array.Length : 0;

2. The first point is the script function

Parameters and execution flow:

  • The index 0 is read only after checking the size.
return  RunScenario();
 object? RunScenario()
{
    var items = UO.GetLastMenuItems();
    if (Truth(ArrayLength(items) > 0))
    {
        UO.Print(items[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;

3. Save Snapshot Before Closing - Script Class

Parameters and execution flow:

  • The array remains available after canceling the server menu.
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 items = UO.GetLastMenuItems();
        UO.CloseMenu();
        UO.Print(Convert.ToString(ArrayLength(items)));
        return null;
    }

    int ArrayLength(object? value) => value is System.Array array ? array.Length : 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.GetLastMenuItems() — UO.GetLastMenuItems()

Parameters: No parameters.

Result: dynamic / Any.

During a call:

Internal implementation code; this is not a standalone script.

case "getlastmenuitems": return StringArray(bridge.GetLastMenuItems());

UO.GetMenuItems

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

C# signatures

dynamic UO.GetMenuItems(object? caption);

Reads the items of the already open old server menu.

Parameters

  • caption — Substring of the title of the old server menu; search OrdinalIgnoreCase. An empty line matches any header.

Return value

Array of strings. Item name/description lines GetYokoItems. Missing a suitable menu results in an empty array.

Behavior

  • The last non-Disposed menu with the matching title substring is selected. The command does not open the menu, does not place a hook, and does not select an item. This is not a context menu or a regular server gump.
  • The order corresponds to the points of the model. The list is a snapshot; subsequent menu changes do not update the saved array.

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.GetMenuItems("");
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));

1. Display all items - direct script

Parameters and execution flow:

  • An empty array is loop safe.
var items = UO.GetMenuItems("");
for (int i = (int)(0); i <= ArrayLength(items)-1; i += (int)(1))
{
    UO.Print(items[i]);
}

int ArrayLength(object? value) => value is System.Array array ? array.Length : 0;

2. The first point is the script function

Parameters and execution flow:

  • The index 0 is read only after checking the size.
return  RunScenario();
 object? RunScenario()
{
    var items = UO.GetMenuItems("");
    if (Truth(ArrayLength(items) > 0))
    {
        UO.Print(items[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;

3. Save Snapshot Before Closing - Script Class

Parameters and execution flow:

  • The array remains available after canceling the server menu.
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 items = UO.GetMenuItems("");
        UO.CloseMenu();
        UO.Print(Convert.ToString(ArrayLength(items)));
        return null;
    }

    int ArrayLength(object? value) => value is System.Array array ? array.Length : 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.GetMenuItems(caption) — UO.GetMenuItems(Any)

Parameters: caption (Any)

Result: dynamic / Any.

During a call:

Internal implementation code; this is not a standalone script.

case "getmenuitems": return StringArray(bridge.GetMenuItems(Text(0), false));

UO.GetMenuItemsEx

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

C# signatures

dynamic UO.GetMenuItemsEx(object? caption);

Reads the items of the already open old server menu.

Parameters

  • caption — Substring of the title of the old server menu; search OrdinalIgnoreCase. An empty line matches any header.

Return value

Array of strings. Strings graphicHex|hueHex|index|name, for example 0x0001|0x0000|1|choice. Missing a suitable menu results in an empty array.

Behavior

  • The last non-Disposed menu with the matching title substring is selected. The command does not open the menu, does not place a hook, and does not select an item. This is not a context menu or a regular server gump.
  • The order corresponds to the points of the model. The list is a snapshot; subsequent menu changes do not update the saved array.

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.GetMenuItemsEx("");
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));

1. Display all items - direct script

Parameters and execution flow:

  • An empty array is loop safe.
var items = UO.GetMenuItemsEx("");
for (int i = (int)(0); i <= ArrayLength(items)-1; i += (int)(1))
{
    UO.Print(items[i]);
}

int ArrayLength(object? value) => value is System.Array array ? array.Length : 0;

2. The first point is the script function

Parameters and execution flow:

  • The index 0 is read only after checking the size.
return  RunScenario();
 object? RunScenario()
{
    var items = UO.GetMenuItemsEx("");
    if (Truth(ArrayLength(items) > 0))
    {
        UO.Print(items[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;

3. Save Snapshot Before Closing - Script Class

Parameters and execution flow:

  • The array remains available after canceling the server menu.
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 items = UO.GetMenuItemsEx("");
        UO.CloseMenu();
        UO.Print(Convert.ToString(ArrayLength(items)));
        return null;
    }

    int ArrayLength(object? value) => value is System.Array array ? array.Length : 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.GetMenuItemsEx(caption) — UO.GetMenuItemsEx(Any)

Parameters: caption (Any)

Result: dynamic / Any.

During a call:

Internal implementation code; this is not a standalone script.

case "getmenuitemsex": return StringArray(bridge.GetMenuItems(Text(0), true));

UO.MenuHookPresent

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

C# signatures

dynamic UO.MenuHookPresent();

Reads the presence of registered menu hooks.

Parameters

There are no parameters.

Return value

Numeric flag int: 1 - _manager.HasMenuHooks, 0 - no hooks. The menu itself may still be missing.

Behavior

  • Reads the presence of registered menu hooks. Doesn't wait for a menu, doesn't check for server gump, and doesn't consume a hook.
  • Reads the current local state. There is no package, target or automatic update; individual reads may see different states.

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.MenuHookPresent();
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));

1. Direct call - direct script

Parameters and execution flow:

  • Reads the presence of registered menu hooks.
UO.Print(UO.MenuHookPresent());

2. Explicit option - script function

Parameters and execution flow:

  • Reads the presence of registered menu hooks. Doesn't wait for a menu, doesn't check for server gump, and doesn't consume a hook.
return  RunScenario();
 object? RunScenario()
{
    UO.WaitMenu("Craft", "Tools");
    UO.Print(UO.MenuHookPresent());
    return null;
}

3. Full Helper Function - Script Class

Parameters and execution flow:

  • Reads the current local state. There is no package, target or automatic update; individual reads may see different states.
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 before = UO.MenuHookPresent();
        UO.Wait(500);
        var after = UO.MenuHookPresent();
        UO.Print(before);
        UO.Print(after);
        return null;
    }
}

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.MenuHookPresent() — UO.MenuHookPresent()

Parameters: No parameters.

Result: dynamic / Any.

During a call:

Internal implementation code; this is not a standalone script.

case "menuhookpresent": return new InjectionValue(bridge.MenuHookPresent());

UO.MenuPresent

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

C# signatures

dynamic UO.MenuPresent();

MenuPresent directly calls WaitingMenu.

Parameters

There are no parameters.

Return value

Numeric flag int: 1 - there is a server menu, 0 - no.

Behavior

  • MenuPresent directly calls WaitingMenu. Does not check GetGumpsCount, context menus or registered hooks.
  • Reads the current local state. There is no package, target or automatic update; individual reads may see different states.

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.MenuPresent();
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));

1. Direct call - direct script

Parameters and execution flow:

  • MenuPresent directly calls WaitingMenu.
UO.Print(UO.MenuPresent());

2. Explicit option - script function

Parameters and execution flow:

  • MenuPresent directly calls WaitingMenu. Does not check GetGumpsCount, context menus or registered hooks.
return  RunScenario();
 object? RunScenario()
{
    if (Truth(UO.MenuPresent()))
    {
        UO.Print(UO.GetLastMenuItems());
    }

    return null;
}

bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;

3. Full Helper Function - Script Class

Parameters and execution flow:

  • Reads the current local state. There is no package, target or automatic update; individual reads may see different states.
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 before = UO.MenuPresent();
        UO.Wait(500);
        var after = UO.MenuPresent();
        UO.Print(before);
        UO.Print(after);
        return null;
    }
}

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.MenuPresent() — UO.MenuPresent()

Parameters: No parameters.

Result: dynamic / Any.

During a call:

Internal implementation code; this is not a standalone script.

case "menupresent": return new InjectionValue(bridge.MenuPresent());

UO.RequestContextMenu

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

C# signatures

void UO.RequestContextMenu(object? objID);

Requests the object's context menu.

Parameters

  • objID — Serial/ID object: int, numeric/hex string or set alias, for example "lasttarget". This is not a graphic/type. Check the loaded object before taking action.

Return value

void - no value. Call on a separate line; completion does not confirm the server's action.

Behavior

  • An explicit script request requires no Shift key and ignores the GUI HoldShiftForContext preference. Read its response separately with GetContextMenu; it does not select an entry. Ordinary GUI clicks retain their Shift check.
  • Bridge sends the request on the game thread. Server rules apply; There is no built-in waiting for confirmation.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.RequestContextMenu");
UO.RequestContextMenu(UO.GetSerial("lasttarget"));

1. Direct call - direct script

Parameters and execution flow:

  • Requests the object's context menu.
var id = UO.GetSerial("lasttarget");
if (Truth(UO.Exists(id)))
{
    UO.RequestContextMenu(id);
}

bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;

2. Explicit option - script function

Parameters and execution flow:

  • An explicit script request requires no Shift key and ignores the GUI HoldShiftForContext preference. Read its response separately with GetContextMenu; it does not select an entry. Ordinary GUI clicks retain their Shift check.
return  RunScenario();
 object? RunScenario()
{
    var id = UO.GetSerial("self");
    if (Truth(UO.Exists(id)))
    {
        UO.RequestContextMenu(id);
    }

    return null;
}

bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;

3. Full Helper Function - Script Class

Parameters and execution flow:

  • Bridge sends the request on the game thread. Server rules apply; There is no built-in waiting for confirmation.
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()
    {
        ApplyToLoaded(UO.GetSerial("lasttarget"));
        return null;
    }

    void ApplyToLoaded(dynamic id)
    {
        if (Truth(UO.Exists(id)))
        {
            UO.RequestContextMenu(id);
        }
    }

    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.RequestContextMenu(objID) — UO.RequestContextMenu(Any)

Parameters: objID (Any)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

case "requestcontextmenu": bridge.RequestContextMenu(Arg(0)); return InjectionValue.Unit;

UO.SetContextMenuHook

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

C# signatures

void UO.SetContextMenuHook(object? menuID, object? entryNumber);

Registers a one-time selection of a context menu item.

Parameters

  • menuID — Serial of the menu object, converted to uint; 0 fits any serial. This is not server gump ID.
  • entryNumber — Zero point index; a negative value disables the pending context hook. 0..GetArrayLength(UO.GetContextMenu())-1.

Return value

void - no value. Call on a separate line; completion does not confirm the server's action.

Behavior

  • Bridge passes data to _manager.SetContextMenuHook, where _contextMenuSerial/_contextMenuEntry is stored. The ProcessMenuHooks handler waits for an existing matching context menu.
  • If SelectYokoItem is successful, the fields are cleared to 0/-1. The menu is not requested by this setter: use RequestContextMenu alone. The call itself does not block or confirm the server action.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.SetContextMenuHook");
UO.SetContextMenuHook(0, 0);

1. Direct call - direct script

Parameters and execution flow:

  • Registers a one-time selection of a context menu item.
UO.SetContextMenuHook(0, 0);

2. Explicit option - script function

Parameters and execution flow:

  • Bridge passes data to _manager.SetContextMenuHook, where _contextMenuSerial/_contextMenuEntry is stored. The ProcessMenuHooks handler waits for an existing matching context menu.
return  RunScenario();
 object? RunScenario()
{
    var id = UO.GetSerial("lasttarget");
    UO.SetContextMenuHook(UO.Hex2Int(id), 0);
    UO.RequestContextMenu(id);
    return null;
}

3. Full Helper Function - Script Class

Parameters and execution flow:

  • If SelectYokoItem is successful, the fields are cleared to 0/-1. The menu is not requested by this setter: use RequestContextMenu alone. The call itself does not block or confirm the server action.
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.SetContextMenuHook(0, -1);
        UO.Print(UO.GetContextMenu());
        return null;
    }
}

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.SetContextMenuHook(menuID, entryNumber) — UO.SetContextMenuHook(Any,Any)

Parameters: menuID (Any), entryNumber (Any)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

case "setcontextmenuhook": bridge.SetContextMenuHook(Arg(0), Arg(1)); return InjectionValue.Unit;

UO.WaitMenu

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

C# signatures

void UO.WaitMenu(object? menuCaption, object? elementCaption);
void UO.WaitMenu(object? prompt1, object? choice1, object? prompt2, object? choice2);
void UO.WaitMenu(object? prompt1, object? choice1, object? prompt2, object? choice2, object? prompt3, object? choice3);

Registers up to three one-time menu hooks.

Parameters

  • menuCaption / prompt1 / prompt2 / prompt3 — Server menu title template string. Pairs are passed in order header, element.
  • menuCaption — Server menu title template string. Pairs are passed in order header, element.
  • prompt1 — Server menu title template string. Pairs are passed in order header, element.
  • prompt2 — Server menu title template string. Pairs are passed in order header, element.
  • prompt3 — Server menu title template string. Pairs are passed in order header, element.
  • elementCaption / choice1 / choice2 / choice3 — Line for selecting an element for the corresponding header. Not the ID regular gump button.
  • elementCaption — Line for selecting an element for the corresponding header. Not the ID regular gump button.
  • choice1 — Line for selecting an element for the corresponding header. Not the ID regular gump button.
  • choice2 — Line for selecting an element for the corresponding header. Not the ID regular gump button.
  • choice3 — Line for selecting an element for the corresponding header. Not the ID regular gump button.

Return value

void - no value. Call on a separate line; completion does not confirm the server's action.

Behavior

  • Each pair is passed to _manager.AddMenuHook(prompt, choice, false). Registered forms are 2/4/6 arguments. false denotes a one-time hook; AutoMenu/two-argument VendorMenu use a constant hook.
  • Does not block the script until the menu appears. Hook is consumed by the manager when the menu is suitable; the result of execution by the server is not returned. For a menu use WaitingMenu, for hooks - MenuHookPresent.
  • For menu/choice forms, the manager selects the first menu whose title contains prompt, case insensitive; SessionMenu selects the first item whose name contains choice, also case insensitive. Blank text is suitable for anyone; numeric text is a fragment of the name, not an index. A successful selection sends a response and closes the local menu. A one-time hook is deleted only after a successful selection; a permanent hook remains.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.WaitMenu");
UO.WaitMenu("Craft", "Tools");

1. Direct call - direct script

Parameters and execution flow:

  • Registers up to three one-time menu hooks.
UO.WaitMenu("Craft", "Tools");

2. Explicit option - script function

Parameters and execution flow:

  • Each pair is passed to _manager.AddMenuHook(prompt, choice, false). Registered forms are 2/4/6 arguments. false denotes a one-time hook; AutoMenu/two-argument VendorMenu use a constant hook.
return  RunScenario();
 object? RunScenario()
{
    UO.WaitMenu("Craft", "Tools", "Tools", "Shovel");
    return null;
}

3. Full Helper Function - Script Class

Parameters and execution flow:

  • Does not block the script until the menu appears. Hook is consumed by the manager when the menu is suitable; the result of execution by the server is not returned. For a menu use WaitingMenu, for hooks - MenuHookPresent.
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.WaitMenu("Craft", "Tools", "Tools", "Shovel", "Amount", "One");
        UO.Print(UO.MenuHookPresent());
        return null;
    }
}

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.WaitMenu(menuCaption, elementCaption) — UO.WaitMenu(Any,Any)

Parameters: menuCaption (Any/String), elementCaption (Any/String)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

case "waitmenu": bridge.WaitMenu(arguments.Select(value => value.ToString()).ToArray()); return InjectionValue.Unit;

UO.WaitMenu(menuCaption, elementCaption) — UO.WaitMenu(String,String)

Parameters: menuCaption (Any/String), elementCaption (Any/String)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

public void WaitMenu(string prompt, string choice)

            => bridge.WaitMenu(prompt, choice);

UO.WaitMenu(prompt1, choice1, prompt2, choice2) — UO.WaitMenu(String,String,String,String)

Parameters: prompt1 (String), choice1 (String), prompt2 (String), choice2 (String)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

public void WaitMenu(string prompt1, string choice1, string prompt2, string choice2)

            => bridge.WaitMenu(prompt1, choice1, prompt2, choice2);

UO.WaitMenu(prompt1, choice1, prompt2, choice2, prompt3, choice3) — UO.WaitMenu(String,String,String,String,String,String)

Parameters: prompt1 (String), choice1 (String), prompt2 (String), choice2 (String), prompt3 (String), choice3 (String)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

public void WaitMenu(string prompt1, string choice1, string prompt2, string choice2, string prompt3, string choice3)

            => bridge.WaitMenu(prompt1, choice1, prompt2, choice2, prompt3, choice3);

UO.WaitTextEntry

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

C# signatures

void UO.WaitTextEntry(object? value);

Tries to write text to the textentry of the current gump.

Parameters

  • value — Text through ToString; saved as transmitted.

Return value

void - no value. Call on a separate line; completion does not confirm the server's action.

Behavior

  • ExecuteClientApiCompatibility calls SetGumpValue(-1, "textentry", -1, Text(0)). key=-1 is not a normal null index: writing is only possible if an existing field maps to such ID in the gump implementation.
  • Doesn't wait for a future gump, doesn't open a prompt, and doesn't register a hook. If there is no matching field, SetGumpValue displays a message. For a known field, use SetGump with an explicit ID/index.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.WaitTextEntry");
UO.WaitTextEntry("Example");

1. Direct call - direct script

Parameters and execution flow:

  • Tries to write text to the textentry of the current gump.
UO.WaitTextEntry("Example");

2. Explicit option - script function

Parameters and execution flow:

  • ExecuteClientApiCompatibility calls SetGumpValue(-1, "textentry", -1, Text(0)). key=-1 is not a normal null index: writing is only possible if an existing field maps to such ID in the gump implementation.
return  RunScenario();
 object? RunScenario()
{
    if (Truth(UO.GetGumpsCount() > 0))
    {
        UO.WaitTextEntry("Example");
    }

    return null;
}

bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;

3. Full Helper Function - Script Class

Parameters and execution flow:

  • Doesn't wait for a future gump, doesn't open a prompt, and doesn't register a hook. If there is no matching field, SetGumpValue displays a message. For a known field, use SetGump with an explicit ID/index.
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.WaitTextEntry("Example");
        UO.Print("Check the target field in the current gump");
        return null;
    }
}

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.WaitTextEntry(value) — UO.WaitTextEntry(Any)

Parameters: value (Any)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

case "waittextentry": bridge.SetGumpValue(-1, "textentry", -1, Text(0)); return InjectionValue.Unit;

UO.WaitingForMenu

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

C# signatures

int UO.WaitingForMenu(object? delay);
int UO.WaitingForMenu(object? delay, object? menuCount);
int UO.WaitingForMenu(object? delay, object? menuCount, object? blockMenu);
int UO.WaitingForMenu(object? delay, object? menuCount, object? blockMenu, object? menuName);
int UO.WaitingForMenu(object? delayValue, object? menuCountValue, object? blockMenuValue, object? menuNameValue, object? skillOrSerial);

The required number of server menu appearances is limited.

Parameters

  • delay — int timeout in milliseconds, negative becomes 0. Even with 0 one check is performed.
  • delayValue — int timeout in milliseconds, negative becomes 0. Even with 0 one check is performed.
  • menuCount — Optional number of appearances, minimum 1; default is 1. This is not the number of menu items.
  • menuCountValue — Optional number of appearances, minimum 1; default is 1. This is not the number of menu items.
  • blockMenu — An optional non-zero number closes the menu when the condition is met; 0 leaves him.
  • blockMenuValue — An optional non-zero number closes the menu when the condition is met; 0 leaves him.
  • menuName - Optional exact title, case sensitive; empty allows anyone.
  • menuNameValue - Optional exact title, case sensitive; empty allows anyone.
  • skillOrSerial - Optional last argument: TriggerWaitAction can first use a skill by name or an object by serial. By default 0 - no action.

Return value

Numeric flag int: 1 - at least menuCount different occurrences are noticed and the last one has the desired title; 0 - timeout. The existing menu can be counted immediately.

Behavior

  • After TriggerWaitAction reads GetLastMenuIdentity; the new identity increases the counter. An empty identity resets the memory of the previous one, so the same menu can be counted again after closing/reopening.
  • The count boundary is checked only with a new identity. If and matches, blockMenu closes the menu. Between checks UO.Wait until 25 ms; the header is checked by Ordinal, not substring.

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.

var result = UO.WaitingForMenu(3000);
UO.Print("WaitingForMenu: " + Convert.ToString(result));

1. Direct call - direct script

Parameters and execution flow:

  • The required number of server menu appearances is limited.
UO.Print(UO.WaitingForMenu(3000));

2. Explicit option - script function

Parameters and execution flow:

  • After TriggerWaitAction reads GetLastMenuIdentity; the new identity increases the counter. An empty identity resets the memory of the previous one, so the same menu can be counted again after closing/reopening.
return  RunScenario();
 object? RunScenario()
{
    UO.Print(UO.WaitingForMenu(3000, 1, 1, "Craft"));
    return null;
}

3. Full Helper Function - Script Class

Parameters and execution flow:

  • The count boundary is checked only with a new identity. If and matches, blockMenu closes the menu. Between checks UO.Wait until 25 ms; the header is checked by Ordinal, not substring.
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 found = UO.WaitingForMenu(3000, 1, 0, "Craft", "lasttarget");
        if (Truth(found))
        {
            UO.Print(UO.GetLastMenuItems());
        }

        return null;
    }

    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.WaitingForMenu(delay) — UO.WaitingForMenu(Any)

Parameters: delay (Any)

Result: int / Integer.

During a call:

Internal implementation code; this is not a standalone script.

public int WaitingForMenu(InjectionValue delay) => WaitingForMenu(delay, InjectionValue.Zero, InjectionValue.Zero, new InjectionValue(string.Empty), InjectionValue.Zero);

UO.WaitingForMenu(delay, menuCount) — UO.WaitingForMenu(Any,Any)

Parameters: delay (Any), menuCount (Any)

Result: int / Integer.

During a call:

Internal implementation code; this is not a standalone script.

public int WaitingForMenu(InjectionValue delay, InjectionValue menuCount) => WaitingForMenu(delay, menuCount, InjectionValue.Zero, new InjectionValue(string.Empty), InjectionValue.Zero);

UO.WaitingForMenu(delay, menuCount, blockMenu) — UO.WaitingForMenu(Any,Any,Any)

Parameters: delay (Any), menuCount (Any), blockMenu (Any)

Result: int / Integer.

During a call:

Internal implementation code; this is not a standalone script.

public int WaitingForMenu(InjectionValue delay, InjectionValue menuCount, InjectionValue blockMenu) => WaitingForMenu(delay, menuCount, blockMenu, new InjectionValue(string.Empty), InjectionValue.Zero);

UO.WaitingForMenu(delay, menuCount, blockMenu, menuName) — UO.WaitingForMenu(Any,Any,Any,Any)

Parameters: delay (Any), menuCount (Any), blockMenu (Any), menuName (Any)

Result: int / Integer.

During a call:

Internal implementation code; this is not a standalone script.

public int WaitingForMenu(InjectionValue delay, InjectionValue menuCount, InjectionValue blockMenu, InjectionValue menuName) => WaitingForMenu(delay, menuCount, blockMenu, menuName, InjectionValue.Zero);

UO.WaitingForMenu(delayValue, menuCountValue, blockMenuValue, menuNameValue, skillOrSerial) — UO.WaitingForMenu(Any,Any,Any,Any,Any)

Parameters: delayValue (Any), menuCountValue (Any), blockMenuValue (Any), menuNameValue (Any), skillOrSerial (Any)

Result: int / Integer.

During a call:

Internal implementation code; this is not a standalone script.

public int WaitingForMenu(InjectionValue delayValue, InjectionValue menuCountValue, InjectionValue blockMenuValue, InjectionValue menuNameValue, InjectionValue skillOrSerial)

        {

            int delay = Math.Max(0, NumberConversions.ToInt(delayValue));

            int requiredMenuCount = Math.Max(1, NumberConversions.ToInt(menuCountValue));

            bool blockMenu = NumberConversions.ToInt(blockMenuValue) != 0;

            string expectedName = menuNameValue.ToString() ?? string.Empty;

            DateTime deadline = timeSource.Now.AddMilliseconds(delay);

            string previousIdentity = string.Empty;

            int observedMenuCount = 0;



            TriggerWaitAction(skillOrSerial);



            do

            {

                string identity = bridge.GetLastMenuIdentity() ?? string.Empty;

                if (identity.Length == 0)

                {

                    // Reset between server menus so an identical menu opened again

                    // still counts as a new appearance.

                    previousIdentity = string.Empty;

                }

                else if (!identity.Equals(previousIdentity, StringComparison.Ordinal))

                {

                    previousIdentity = identity;

                    observedMenuCount++;

                    string caption = bridge.GetLastMenuCaption() ?? string.Empty;

                    bool nameMatches = expectedName.Length == 0

                        || caption.Equals(expectedName, StringComparison.Ordinal);

                    if (observedMenuCount >= requiredMenuCount && nameMatches)

                    {

                        if (blockMenu)

                            bridge.CloseMenu();

                        return 1;

                    }

                }



                if (timeSource.Now >= deadline)

                    break;

                bridge.Wait(Math.Min(25, Math.Max(1, delay)));

            }

            while (true);



            return 0;

        }

UO.WaitingMenu

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

C# signatures

int UO.WaitingMenu();

Reads _world.ServerMenus.Snapshot().Length != 0.

Parameters

There are no parameters.

Return value

Numeric flag int: 1 - ServerMenus has at least one menu, 0 - does not. This is having a menu, not waiting for a script.

Behavior

  • Reads _world.ServerMenus.Snapshot().Length != 0. Legacy server menus are separate from regular server gumps and context menus.
  • Reads the current local state. There is no package, target or automatic update; individual reads may see different states.

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.

var result = UO.WaitingMenu();
UO.Print("WaitingMenu: " + Convert.ToString(result));

1. Direct call - direct script

Parameters and execution flow:

  • Reads _world.ServerMenus.Snapshot().Length != 0.
UO.Print(UO.WaitingMenu());

2. Explicit option - script function

Parameters and execution flow:

  • Reads _world.ServerMenus.Snapshot().Length != 0. Legacy server menus are separate from regular server gumps and context menus.
return  RunScenario();
 object? RunScenario()
{
    if (Truth(UO.WaitingMenu()))
    {
        UO.Print(UO.GetLastMenuItems());
    }

    return null;
}

bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;

3. Full Helper Function - Script Class

Parameters and execution flow:

  • Reads the current local state. There is no package, target or automatic update; individual reads may see different states.
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 before = UO.WaitingMenu();
        UO.Wait(500);
        var after = UO.WaitingMenu();
        UO.Print(before);
        UO.Print(after);
        return null;
    }
}

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.WaitingMenu() — UO.WaitingMenu()

Parameters: No parameters.

Result: int / Integer.

During a call:

Internal implementation code; this is not a standalone script.

public int WaitingMenu() => bridge.WaitingMenu();
⚠️ **GitHub.com Fallback** ⚠️