EN UO Topic menus context menus - LIHACHTETAN/ClassicUO-Bad-Newbie-CSharp-Scripts-IDE GitHub Wiki
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
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.
| 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 |
UO.AutoMenu · UO.WaitMenu · UO.GetMenuItems · UO.GetMenuItemsEx · UO.GetLastMenuItems · UO.MenuHookPresent · UO.MenuPresent · UO.CancelAllMenuHooks · UO.CancelMenu · UO.CloseMenu · UO.WaitingForMenu · UO.WaitingMenu
UO.GetContextMenu · UO.RequestContextMenu · UO.SetContextMenuHook · UO.ClearContextMenu
UO.WaitTextEntry · UO.ConsoleEntryReply · UO.ConsoleEntryUnicodeReply
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.
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;Parameters, result and all scenarios
UO.WaitMenu("Craft", "Tools");Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
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.
-
prompt— substring of the server menu title. -
choice— substring of the menu item signature.
void. The call only registers a hook and does not report whether the menu was found or whether the item was successfully selected.
- 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 containschoice, the client selects it. The hook remains registered after selection, so it will work on subsequent matching menus. You can remove hooks usingUO.CancelMenu().
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 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;
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: prompt (Any), choice (Any)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteLegacyManualAlias. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.AddMenuHook:bridge.AddMenuHook(arguments[0].ToString(), arguments[1].ToString(), true). -
InjectionScript.Runtime.InjectionValue.ToString:arguments[0].ToString().
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;Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.CancelAllMenuHooks();Removes all registered automatic hooks from old client server menus.
There are no parameters.
void - no return value.
- 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.
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 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();Parameters and execution flow:
- Removal applies to the entire set of client menu hooks.
UO.CancelAllMenuHooks();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;
}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;
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: No parameters.
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.ClearMenuHooks:bridge.ClearMenuHooks().
Internal implementation code; this is not a standalone script.
case "cancelallmenuhooks": bridge.ClearMenuHooks(); return InjectionValue.Unit;Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.CancelMenu();Removes all registered automatic hooks from old client server menus.
There are no parameters.
void - no return value.
- 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.
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 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();Parameters and execution flow:
- Removal applies to the entire set of client menu hooks.
UO.CancelMenu();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;
}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;
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: No parameters.
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteLegacyManualAlias. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.ClearMenuHooks:bridge.ClearMenuHooks().
Internal implementation code; this is not a standalone script.
case "cancelmenu": bridge.ClearMenuHooks(); break;Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.ClearContextMenu();Removes the current local context menu model.
There are no parameters.
void - no return value.
- Calls Dispose on ServerMenus.Context if there is a model; a new server menu may appear after the next request. This is not CloseMenu.
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 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();Parameters and execution flow:
- Removes the current local context menu model.
UO.ClearContextMenu();Parameters and execution flow:
- Remove local context menu after reading snapshot.
return RunScenario();
object? RunScenario()
{
var entries = UO.GetContextMenu();
UO.ClearContextMenu();
return null;
}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;
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: No parameters.
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.ClearContextMenu:bridge.ClearContextMenu().
Internal implementation code; this is not a standalone script.
case "clearcontextmenu": bridge.ClearContextMenu(); return InjectionValue.Unit;Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.CloseMenu();Cancels all active old server menus via CancelForYoko.
There are no parameters.
void - no return value.
- Iterates through snapshot ServerMenus and discards each model. Does not remove automatic menu hooks and does not close arbitrary gump/interface windows.
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 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();Parameters and execution flow:
- Cancellation applies to old MenuGump/server menus.
UO.CloseMenu();Parameters and execution flow:
- Automatic selection and open menus are handled by separate commands.
return RunScenario();
object? RunScenario()
{
UO.CancelAllMenuHooks();
UO.CloseMenu();
return null;
}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;
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: No parameters.
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.CloseMenu:bridge.CloseMenu().
Internal implementation code; this is not a standalone script.
case "closemenu": bridge.CloseMenu(); return InjectionValue.Unit;Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.ConsoleEntryReply(object? text);Replies with text to the active server prompt via MessageManager.SendServerPromptResponse.
-
text— The value to be converted to a string. An empty string is sent as an empty response.
void - no return value.
- 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.
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 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");Parameters and execution flow:
- Sending refers to the current server input request.
UO.ConsoleEntryReply("reply");Parameters and execution flow:
- Empty text is sent to the manager as an empty response.
return RunScenario();
object? RunScenario()
{
UO.ConsoleEntryReply("");
return null;
}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;
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: text (Any)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.ReplyServerPrompt:bridge.ReplyServerPrompt(Text(0)). -
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility::Text:Text(0).
Internal implementation code; this is not a standalone script.
case "consoleentryreply":
case "consoleentryunicodereply": bridge.ReplyServerPrompt(Text(0)); return InjectionValue.Unit;Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.ConsoleEntryUnicodeReply(object? text);Replies with text to the active server prompt via MessageManager.SendServerPromptResponse.
-
text— The value to be converted to a string. An empty string is sent as an empty response.
void - no return value.
- 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.
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 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");Parameters and execution flow:
- Sending refers to the current server input request.
UO.ConsoleEntryUnicodeReply("reply");Parameters and execution flow:
- Empty text is sent to the manager as an empty response.
return RunScenario();
object? RunScenario()
{
UO.ConsoleEntryUnicodeReply("");
return null;
}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;
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: text (Any)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.ReplyServerPrompt:bridge.ReplyServerPrompt(Text(0)). -
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility::Text:Text(0).
Internal implementation code; this is not a standalone script.
case "consoleentryreply":
case "consoleentryunicodereply": bridge.ReplyServerPrompt(Text(0)); return InjectionValue.Unit;Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
dynamic UO.GetContextMenu();Reads the item strings of the current context menu model.
There are no parameters.
Array of strings from ServerMenus.Context.GetYokoItems(); if there is no model, an empty array.
- 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.
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.GetContextMenu();
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));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;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)));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;
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: No parameters.
Result: dynamic / Any.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
InjectionScript.Runtime.InjectionApiUO.StringArray:StringArray(bridge.GetContextMenu()). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.GetContextMenu:bridge.GetContextMenu().
Internal implementation code; this is not a standalone script.
case "getcontextmenu": return StringArray(bridge.GetContextMenu());Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
dynamic UO.GetLastMenuItems();Reads the items of the already open old server menu.
There are no parameters.
Array of strings. Item name/description lines GetYokoItems. Missing a suitable menu results in an empty array.
- 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.
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.GetLastMenuItems();
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));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;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;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;
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: No parameters.
Result: dynamic / Any.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
InjectionScript.Runtime.InjectionApiUO.StringArray:StringArray(bridge.GetLastMenuItems()). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.GetLastMenuItems:bridge.GetLastMenuItems().
Internal implementation code; this is not a standalone script.
case "getlastmenuitems": return StringArray(bridge.GetLastMenuItems());Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
dynamic UO.GetMenuItems(object? caption);Reads the items of the already open old server menu.
-
caption— Substring of the title of the old server menu; search OrdinalIgnoreCase. An empty line matches any header.
Array of strings. Item name/description lines GetYokoItems. Missing a suitable menu results in an empty array.
- 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.
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.GetMenuItems("");
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));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;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;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;
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: caption (Any)
Result: dynamic / Any.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
InjectionScript.Runtime.InjectionApiUO.StringArray:StringArray(bridge.GetMenuItems(Text(0), false)). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.GetMenuItems:bridge.GetMenuItems(Text(0), false). -
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility::Text:Text(0).
Internal implementation code; this is not a standalone script.
case "getmenuitems": return StringArray(bridge.GetMenuItems(Text(0), false));Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
dynamic UO.GetMenuItemsEx(object? caption);Reads the items of the already open old server menu.
-
caption— Substring of the title of the old server menu; search OrdinalIgnoreCase. An empty line matches any header.
Array of strings. Strings graphicHex|hueHex|index|name, for example 0x0001|0x0000|1|choice. Missing a suitable menu results in an empty array.
- 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.
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.GetMenuItemsEx("");
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));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;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;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;
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: caption (Any)
Result: dynamic / Any.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
InjectionScript.Runtime.InjectionApiUO.StringArray:StringArray(bridge.GetMenuItems(Text(0), true)). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.GetMenuItems:bridge.GetMenuItems(Text(0), true). -
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility::Text:Text(0).
Internal implementation code; this is not a standalone script.
case "getmenuitemsex": return StringArray(bridge.GetMenuItems(Text(0), true));Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
dynamic UO.MenuHookPresent();Reads the presence of registered menu hooks.
There are no parameters.
Numeric flag int: 1 - _manager.HasMenuHooks, 0 - no hooks. The menu itself may still be missing.
- 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.
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.MenuHookPresent();
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));Parameters and execution flow:
- Reads the presence of registered menu hooks.
UO.Print(UO.MenuHookPresent());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;
}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;
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: No parameters.
Result: dynamic / Any.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.MenuHookPresent:bridge.MenuHookPresent().
Internal implementation code; this is not a standalone script.
case "menuhookpresent": return new InjectionValue(bridge.MenuHookPresent());Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
dynamic UO.MenuPresent();MenuPresent directly calls WaitingMenu.
There are no parameters.
Numeric flag int: 1 - there is a server menu, 0 - no.
- 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.
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.MenuPresent();
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));Parameters and execution flow:
- MenuPresent directly calls WaitingMenu.
UO.Print(UO.MenuPresent());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;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;
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: No parameters.
Result: dynamic / Any.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.MenuPresent:bridge.MenuPresent().
Internal implementation code; this is not a standalone script.
case "menupresent": return new InjectionValue(bridge.MenuPresent());Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.RequestContextMenu(object? objID);Requests the object's context menu.
-
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.
void - no value. Call on a separate line; completion does not confirm the server's action.
- 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.
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 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"));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;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;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;
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: objID (Any)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.RequestContextMenu:bridge.RequestContextMenu(Arg(0)). -
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility::Arg:Arg(0).
Internal implementation code; this is not a standalone script.
case "requestcontextmenu": bridge.RequestContextMenu(Arg(0)); return InjectionValue.Unit;Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.SetContextMenuHook(object? menuID, object? entryNumber);Registers a one-time selection of a context menu item.
-
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.
void - no value. Call on a separate line; completion does not confirm the server's action.
- 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.
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 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);Parameters and execution flow:
- Registers a one-time selection of a context menu item.
UO.SetContextMenuHook(0, 0);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;
}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;
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: menuID (Any), entryNumber (Any)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.SetContextMenuHook:bridge.SetContextMenuHook(Arg(0), Arg(1)). -
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility::Arg:Arg(0).
Internal implementation code; this is not a standalone script.
case "setcontextmenuhook": bridge.SetContextMenuHook(Arg(0), Arg(1)); return InjectionValue.Unit;Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
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.
-
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.
void - no value. Call on a separate line; completion does not confirm the server's action.
- 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.
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 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");Parameters and execution flow:
- Registers up to three one-time menu hooks.
UO.WaitMenu("Craft", "Tools");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;
}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;
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: menuCaption (Any/String), elementCaption (Any/String)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.WaitMenu:bridge.WaitMenu(arguments.Select(value => value.ToString()).ToArray()). -
InjectionScript.Runtime.InjectionValue.ToString:value.ToString().
Internal implementation code; this is not a standalone script.
case "waitmenu": bridge.WaitMenu(arguments.Select(value => value.ToString()).ToArray()); return InjectionValue.Unit;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);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);Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.WaitTextEntry(object? value);Tries to write text to the textentry of the current gump.
-
value— Text through ToString; saved as transmitted.
void - no value. Call on a separate line; completion does not confirm the server's action.
- 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.
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 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");Parameters and execution flow:
- Tries to write text to the textentry of the current gump.
UO.WaitTextEntry("Example");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;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;
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: value (Any)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.SetGumpValue:bridge.SetGumpValue(-1, "textentry", -1, Text(0)). -
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility::Text:Text(0).
Internal implementation code; this is not a standalone script.
case "waittextentry": bridge.SetGumpValue(-1, "textentry", -1, Text(0)); return InjectionValue.Unit;Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
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.
-
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.
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.
- 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.
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.
var result = UO.WaitingForMenu(3000);
UO.Print("WaitingForMenu: " + Convert.ToString(result));Parameters and execution flow:
- The required number of server menu appearances is limited.
UO.Print(UO.WaitingForMenu(3000));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;
}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;
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: delay (Any)
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.WaitingForMenu. -
InjectionScript.Runtime.InjectionApiUO.WaitingForMenu:WaitingForMenu(delay, InjectionValue.Zero, InjectionValue.Zero, new InjectionValue(string.Empty), InjectionValue.Zero).
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);Parameters: delay (Any), menuCount (Any)
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.WaitingForMenu. -
InjectionScript.Runtime.InjectionApiUO.WaitingForMenu:WaitingForMenu(delay, menuCount, InjectionValue.Zero, new InjectionValue(string.Empty), InjectionValue.Zero).
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);Parameters: delay (Any), menuCount (Any), blockMenu (Any)
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.WaitingForMenu. -
InjectionScript.Runtime.InjectionApiUO.WaitingForMenu:WaitingForMenu(delay, menuCount, blockMenu, new InjectionValue(string.Empty), InjectionValue.Zero).
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);Parameters: delay (Any), menuCount (Any), blockMenu (Any), menuName (Any)
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.WaitingForMenu. -
InjectionScript.Runtime.InjectionApiUO.WaitingForMenu:WaitingForMenu(delay, menuCount, blockMenu, menuName, InjectionValue.Zero).
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:
-
InjectionScript.Runtime.InjectionApiUO.WaitingForMenu. -
InjectionScript.Runtime.NumberConversions.ToInt:NumberConversions.ToInt(delayValue). -
InjectionScript.Runtime.InjectionValue.ToString:menuNameValue.ToString(). -
InjectionScript.Runtime.InjectionApiUO.TriggerWaitAction:TriggerWaitAction(skillOrSerial). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.GetLastMenuIdentity:bridge.GetLastMenuIdentity(). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.GetLastMenuCaption:bridge.GetLastMenuCaption(). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.CloseMenu:bridge.CloseMenu(). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.Wait:bridge.Wait(Math.Min(25, Math.Max(1, delay))).
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;
}Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
int UO.WaitingMenu();Reads _world.ServerMenus.Snapshot().Length != 0.
There are no parameters.
Numeric flag int: 1 - ServerMenus has at least one menu, 0 - does not. This is having a menu, not waiting for a script.
- 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.
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.
var result = UO.WaitingMenu();
UO.Print("WaitingMenu: " + Convert.ToString(result));Parameters and execution flow:
- Reads _world.ServerMenus.Snapshot().Length != 0.
UO.Print(UO.WaitingMenu());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;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;
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: No parameters.
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.WaitingMenu. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.WaitingMenu:bridge.WaitingMenu().
Internal implementation code; this is not a standalone script.
public int WaitingMenu() => bridge.WaitingMenu();