This script demonstrates how to draw a small, live-updating rectangle around the mouse cursor using EyeAuras’ On-Screen Display (OSD) API. It uses the IOnScreenCanvas API to dynamically render an overlay element that tracks the cursor in real time.
EyeAuras exposes a scripting API for creating lightweight on-screen visuals:
These APIs allow you to create, manipulate, and remove lightweight on-screen overlays, which are perfect for scripting HUDs, tracking UI elements, debug helpers, or cursor markers.
try
{
Log.Info("Booting up OSD");
// Create an overlay canvas
using var canvas = GetService<IOnScreenCanvasScriptingApi>().Create();
// Add a 10x10 green-outlined rectangle (no fill) to the canvas
using var cursorBox = canvas.AddRectangle()
.WithSize(new Size(10, 10))
.WithBackground(Color.Transparent)
.WithBorderThickness(2)
.WithBorderColor(Color.Green);
// Continuously update position to follow the cursor
while (!cancellationToken.IsCancellationRequested)
{
cursorBox.Location = System.Windows.Forms.Cursor.Position.OffsetBy(-5, -5);
}
}
finally
{
Log.Info("OSD routine has stopped");
}
canvas.AddRectangle() creates a new rectangle overlay object.2px)10x10).OffsetBy(-5, -5)).Task.Delay(16) for ~60 FPS (optional)..WithBackground(Color.FromArgb(...)) if you want a filled marker.canvas.ShowDevTools() for live UI inspection (great for debugging overlay layout).