Repository navigation
EN UO Topic mouse keyboard
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
Home · C# · IDE · UO API · A–Z · Examples · Languages
Mouse and keyboard input. Screen coordinates, world cells, and coordinates inside a gump have different meanings.
| Topic | Commands and explanations |
|---|---|
| Click | UO.Click |
| LClick | UO.LClick |
| RClick | UO.RClick |
| DoubleClick | UO.LDblClick · UO.RDblClick |
| KeyPress | UO.KeyPress |
| Press | UO.Press |
UO.Click · UO.LClick · UO.RClick · UO.LDblClick · UO.RDblClick · UO.KeyPress · UO.Press
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
UO.LClick(100, 100);Parameters, result and all scenarios
UO.KeyPress(0x70);Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.Click(object? name);Sends a single click on an object via GameActions.SingleClick.
-
name— Serial of the object or supported name of self/backpack/lasttarget/saved object; numeric strings and 0x strings are resolved by runtime.
void - no return value.
- Click resolves the link via ObjectChecked. ClickOnObject first uses Arg for serial and calls Click(int). This is a request for the item's signature/information, not DoubleClick or use of the item. The server response comes asynchronously.
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.Click");
UO.Click("self");Parameters and execution flow:
- A single click is sent to self.
UO.Click("self");Parameters and execution flow:
- Before sending, the local existence of the target is checked.
return RunScenario();
object? RunScenario()
{
var target = UO.LastTarget();
if (Truth(UO.Exists(target)))
{
UO.Click(target);
}
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:
- Single clicking on a backpack does not open it like double clicking it.
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 bag = UO.Backpack();
if (Truth(bag != 0))
{
UO.Click(bag);
}
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: name (Any)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.Click. -
InjectionScript.Runtime.InjectionApiUO.ObjectChecked:ObjectChecked(name, id => Click(id)). -
InjectionScript.Runtime.InjectionApiUO.Click:Click(id).
Internal implementation code; this is not a standalone script.
public void Click(InjectionValue name) => ObjectChecked(name, id => Click(id));Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.KeyPress(object? key);
void UO.KeyPress(object? key, object? count);
void UO.KeyPress(object? key, object? count, object? delay);Synthesizes one or more virtual-key presses.
-
key- int virtual-key Windows, converted to byte. It is not a character string, nor is it a ID target. -
count— Optional number of repetitions, default 1. 0/negative - no pressing or waiting. -
delay- Optional pause of milliseconds after each press, including the last one; default is 105. Passed bridge.Wait without further restriction by this function.
void - no value. Call on a separate line; completion does not confirm the server's action.
- Press forwards all forms to KeyPress. KeyPress executes a loop count>0: bridge.KeyPress(key), bridge.Wait(delay), count--. Bridge sends user32 keybd_event down/up.
- Requires open Graphics ClassicUO with input focus; otherwise RequireGameInput throws an error. The click processes the current interface/macro, the result of the server command is not returned.
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.KeyPress");
UO.KeyPress(0x70);Parameters and execution flow:
- Synthesizes one or more virtual-key presses.
UO.KeyPress(0x70);Parameters and execution flow:
- Press forwards all forms to KeyPress. KeyPress executes a loop count>0: bridge.KeyPress(key), bridge.Wait(delay), count--. Bridge sends user32 keybd_event down/up.
return RunScenario();
object? RunScenario()
{
UO.KeyPress(0x70, 2, 250);
return null;
}Parameters and execution flow:
- Requires open Graphics ClassicUO with input focus; otherwise RequireGameInput throws an error. The click processes the current interface/macro, the result of the server command is not returned.
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.KeyPress(0x70, 0);
UO.Print("Zero count sends no key");
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: key (Integer)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.KeyPress. -
InjectionScript.Runtime.InjectionApiUO.KeyPress:KeyPress(key, 1).
Internal implementation code; this is not a standalone script.
public void KeyPress(int key) => KeyPress(key, 1);Parameters: key (Integer), count (Integer)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.KeyPress. -
InjectionScript.Runtime.InjectionApiUO.KeyPress:KeyPress(key, count, 105).
Internal implementation code; this is not a standalone script.
public void KeyPress(int key, int count) => KeyPress(key, count, 105);Parameters: key (Integer), count (Integer), delay (Integer)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.KeyPress. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.KeyPress:bridge.KeyPress(key). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.Wait:bridge.Wait(delay).
Internal implementation code; this is not a standalone script.
public void KeyPress(int key, int count, int delay)
{
while (count > 0)
{
bridge.KeyPress(key);
bridge.Wait(delay);
count--;
}
}Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.LClick(object? x, object? y);Synthesizes a single mouse click: left button.
-
x— int X in ClassicUO window pixels, not world coordinate. -
y— int Y in ClassicUO window pixels, not world coordinate.
void - no value. Call on a separate line; completion does not confirm the server's action.
- Bridge calls WarpMouse(x,y), updates Mouse.Position and SDL_WarpMouseInWindow, then MouseButton down/up once. There is no pause between double clicks.
- Requires an open ClassicUO graphics window with input focus; otherwise RequireGameInput throws InvalidOperationException. user32 mouse_event is available on Windows. The button/object under the dot depends on the current interface.
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.LClick");
UO.LClick(100, 100);Parameters and execution flow:
- Synthesizes a single mouse click: left button.
UO.LClick(100, 100);Parameters and execution flow:
- Bridge calls WarpMouse(x,y), updates Mouse.Position and SDL_WarpMouseInWindow, then MouseButton down/up once. There is no pause between double clicks.
return RunScenario();
object? RunScenario()
{
var x = 120;
var y = 140;
UO.LClick(x, y);
return null;
}Parameters and execution flow:
- Requires an open ClassicUO graphics window with input focus; otherwise RequireGameInput throws InvalidOperationException. user32 mouse_event is available on Windows. The button/object under the dot depends on the current interface.
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()
{
ClickAt(100, 100);
return null;
}
void ClickAt(dynamic x, dynamic y)
{
UO.LClick(x, y);
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: x (Integer), y (Integer)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.LClick. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.LClick:bridge.LClick(x, y).
Internal implementation code; this is not a standalone script.
public void LClick(int x, int y) => bridge.LClick(x, y);Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.LDblClick(object? x, object? y);Synthesizes a double mouse click: left button.
-
x— int X in ClassicUO window pixels, not world coordinate. -
y— int Y in ClassicUO window pixels, not world coordinate.
void - no value. Call on a separate line; completion does not confirm the server's action.
- Bridge calls WarpMouse(x,y), updates Mouse.Position and SDL_WarpMouseInWindow, then MouseButton down/up twice. There is no pause between double clicks.
- Requires an open ClassicUO graphics window with input focus; otherwise RequireGameInput throws InvalidOperationException. user32 mouse_event is available on Windows. The button/object under the dot depends on the current interface.
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.LDblClick");
UO.LDblClick(100, 100);Parameters and execution flow:
- Synthesizes a double mouse click: left button.
UO.LDblClick(100, 100);Parameters and execution flow:
- Bridge calls WarpMouse(x,y), updates Mouse.Position and SDL_WarpMouseInWindow, then MouseButton down/up twice. There is no pause between double clicks.
return RunScenario();
object? RunScenario()
{
var x = 120;
var y = 140;
UO.LDblClick(x, y);
return null;
}Parameters and execution flow:
- Requires an open ClassicUO graphics window with input focus; otherwise RequireGameInput throws InvalidOperationException. user32 mouse_event is available on Windows. The button/object under the dot depends on the current interface.
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()
{
ClickAt(100, 100);
return null;
}
void ClickAt(dynamic x, dynamic y)
{
UO.LDblClick(x, y);
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: x (Integer), y (Integer)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.LDblClick. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.LDblClick:bridge.LDblClick(x, y).
Internal implementation code; this is not a standalone script.
public void LDblClick(int x, int y) => bridge.LDblClick(x, y);Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.Press(object? key);
void UO.Press(object? key, object? count);
void UO.Press(object? key, object? count, object? delay);Synthesizes one or more virtual-key presses.
-
key- int virtual-key Windows, converted to byte. It is not a character string, nor is it a ID target. -
count— Optional number of repetitions, default 1. 0/negative - no pressing or waiting. -
delay- Optional pause of milliseconds after each press, including the last one; default is 105. Passed bridge.Wait without further restriction by this function.
void - no value. Call on a separate line; completion does not confirm the server's action.
- Press forwards all forms to KeyPress. KeyPress executes a loop count>0: bridge.KeyPress(key), bridge.Wait(delay), count--. Bridge sends user32 keybd_event down/up.
- Requires open Graphics ClassicUO with input focus; otherwise RequireGameInput throws an error. The click processes the current interface/macro, the result of the server command is not returned.
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.Press");
UO.Press(0x70);Parameters and execution flow:
- Synthesizes one or more virtual-key presses.
UO.Press(0x70);Parameters and execution flow:
- Press forwards all forms to KeyPress. KeyPress executes a loop count>0: bridge.KeyPress(key), bridge.Wait(delay), count--. Bridge sends user32 keybd_event down/up.
return RunScenario();
object? RunScenario()
{
UO.Press(0x70, 2, 250);
return null;
}Parameters and execution flow:
- Requires open Graphics ClassicUO with input focus; otherwise RequireGameInput throws an error. The click processes the current interface/macro, the result of the server command is not returned.
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.Press(0x70, 0);
UO.Print("Zero count sends no key");
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: key (Integer)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.Press. -
InjectionScript.Runtime.InjectionApiUO.KeyPress:KeyPress(key).
Internal implementation code; this is not a standalone script.
public void Press(int key) => KeyPress(key);Parameters: key (Integer), count (Integer)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.Press. -
InjectionScript.Runtime.InjectionApiUO.KeyPress:KeyPress(key, count).
Internal implementation code; this is not a standalone script.
public void Press(int key, int count) => KeyPress(key, count);Parameters: key (Integer), count (Integer), delay (Integer)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.Press. -
InjectionScript.Runtime.InjectionApiUO.KeyPress:KeyPress(key, count, delay).
Internal implementation code; this is not a standalone script.
public void Press(int key, int count, int delay) => KeyPress(key, count, delay);Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.RClick(object? x, object? y);Synthesizes a single mouse click: right button.
-
x— int X in ClassicUO window pixels, not world coordinate. -
y— int Y in ClassicUO window pixels, not world coordinate.
void - no value. Call on a separate line; completion does not confirm the server's action.
- Bridge calls WarpMouse(x,y), updates Mouse.Position and SDL_WarpMouseInWindow, then MouseButton down/up once. There is no pause between double clicks.
- Requires an open ClassicUO graphics window with input focus; otherwise RequireGameInput throws InvalidOperationException. user32 mouse_event is available on Windows. The button/object under the dot depends on the current interface.
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.RClick");
UO.RClick(100, 100);Parameters and execution flow:
- Synthesizes a single mouse click: right button.
UO.RClick(100, 100);Parameters and execution flow:
- Bridge calls WarpMouse(x,y), updates Mouse.Position and SDL_WarpMouseInWindow, then MouseButton down/up once. There is no pause between double clicks.
return RunScenario();
object? RunScenario()
{
var x = 120;
var y = 140;
UO.RClick(x, y);
return null;
}Parameters and execution flow:
- Requires an open ClassicUO graphics window with input focus; otherwise RequireGameInput throws InvalidOperationException. user32 mouse_event is available on Windows. The button/object under the dot depends on the current interface.
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()
{
ClickAt(100, 100);
return null;
}
void ClickAt(dynamic x, dynamic y)
{
UO.RClick(x, y);
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: x (Integer), y (Integer)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.RClick. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.RClick:bridge.RClick(x, y).
Internal implementation code; this is not a standalone script.
public void RClick(int x, int y) => bridge.RClick(x, y);Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.RDblClick(object? x, object? y);Synthesizes a double mouse click: right button.
-
x— int X in ClassicUO window pixels, not world coordinate. -
y— int Y in ClassicUO window pixels, not world coordinate.
void - no value. Call on a separate line; completion does not confirm the server's action.
- Bridge calls WarpMouse(x,y), updates Mouse.Position and SDL_WarpMouseInWindow, then MouseButton down/up twice. There is no pause between double clicks.
- Requires an open ClassicUO graphics window with input focus; otherwise RequireGameInput throws InvalidOperationException. user32 mouse_event is available on Windows. The button/object under the dot depends on the current interface.
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.RDblClick");
UO.RDblClick(100, 100);Parameters and execution flow:
- Synthesizes a double mouse click: right button.
UO.RDblClick(100, 100);Parameters and execution flow:
- Bridge calls WarpMouse(x,y), updates Mouse.Position and SDL_WarpMouseInWindow, then MouseButton down/up twice. There is no pause between double clicks.
return RunScenario();
object? RunScenario()
{
var x = 120;
var y = 140;
UO.RDblClick(x, y);
return null;
}Parameters and execution flow:
- Requires an open ClassicUO graphics window with input focus; otherwise RequireGameInput throws InvalidOperationException. user32 mouse_event is available on Windows. The button/object under the dot depends on the current interface.
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()
{
ClickAt(100, 100);
return null;
}
void ClickAt(dynamic x, dynamic y)
{
UO.RDblClick(x, y);
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: x (Integer), y (Integer)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.RDblClick. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.RDblClick:bridge.RDblClick(x, y).
Internal implementation code; this is not a standalone script.
public void RDblClick(int x, int y) => bridge.RDblClick(x, y);ClassicUO — Bad Newbie & C# Scripts IDE