Recursive AI

System-wide input, display capture, click-through overlays, accessory apps

All oneplatform docs

Four additions for programs that look at and act on the whole desktop, not only on their own windows: remote-desktop and automation tools, screen annotators, tray utilities. They are opt-in and separate from the app's own event queue and InputInjector. Namespace OnePlatform.SystemDesktop.

A missing capability or permission is always a typed exception that names what is missing and how to get it, never a silent no-op: ShellUnavailableException (service plus requirement), and its subclass OsPermissionException (Permission) when the user can grant the thing.

System-wide input: SystemInput

C#
using var input = await SystemInput.OpenAsync();   // or SystemInput.Open()
input.ClickAt(400, 300);
input.TypeText("Hello é€ 日本");
input.Key(Key.LeftControl, true); input.KeyPress(Key.S); input.Key(Key.LeftControl, false);
input.Scroll(0, 3);                                 // three notches down

Members: MoveTo, MoveBy, Button, Click, ClickAt, Scroll(dx, dy) (notches; positive is down and right), Key, KeyPress, TypeText. Events reach the window under the pointer or with the keyboard focus, whichever program owns it. Positions are desktop coordinates, the ones ScreenCapture.GetDisplays reports (points on macOS). Key names a physical key by its position on a US keyboard; TypeText sends characters whatever the layout, so any Unicode works, but the target sees text, not key presses. Calls return when the system took the event, not when the target handled it. Threading: any thread, one call at a time.

SystemBackend (SystemInputBackend)Needs
WindowsWindows: SendInput; absolute moves across the virtual desktop, scan codes for keys, Unicode packets for textan interactive desktop. A locked desktop, a secure prompt, or a target running at a higher integrity level is refused by Windows; the call then throws ShellUnavailableException (events delivered fewer than sent) where Windows says so, and otherwise the target never sees the input.
macOSQuartz: CGEventPost at the HID tapthe Accessibility permission (System Settings, Privacy & Security). Checked with AXIsProcessTrusted, without the system prompt; OsPermissionException with Permission == "Accessibility" when missing.
Linux, X11XTest: the XTEST extension on DISPLAY (or SystemInputOptions.DisplayName)libXtst. Characters no key makes are bound to a spare key code for the length of the key stroke, so a target that does not follow keyboard-map changes sees nothing for them. Under Xwayland it reaches X windows only.
Linux, WaylandRemoteDesktopPortal: the XDG RemoteDesktop portal (a session with keyboard and pointer, plus the ScreenCast monitors for absolute positions)the desktop's portal backend, and the user accepting its dialog; declining throws OsPermissionException ("Remote desktop access"). Disposing the SystemInput closes the session. AbsolutePointer = false skips the monitor request, leaving only MoveBy.

Auto picks the portal when WAYLAND_DISPLAY is set (or there is no DISPLAY), XTEST otherwise. libei is not used: the portal's Notify* methods cover the same ground without a second protocol.

Display capture: ScreenCapture

C#
foreach (var d in ScreenCapture.GetDisplays()) Console.WriteLine($"{d.Id} {d.Name} {d.Bounds} x{d.Scale}");
ScreenshotImage shot = ScreenCapture.CaptureDisplay(displayId);   // BGRA, rows top to bottom, alpha 255
File.WriteAllBytes("screen.png", shot.ToPng());

GetDisplays lists displays, primary first, with Id (pass it back; opaque), Name, Bounds (desktop pixels, points on macOS), IsPrimary and Scale (pixels per bounds unit). CaptureDisplay / CaptureDisplayAsync return a ScreenshotImage.

SystemBackend (ScreenCaptureBackend)Needs
WindowsWindows: GDI BitBlt of the composed screen with CAPTUREBLT, so GPU-drawn and layered windows are includedan interactive desktop
macOSQuartz: CGDisplayCreateImagethe Screen Recording permission, checked with CGPreflightScreenCaptureAccess (without it the system returns only the wallpaper, which would look like a capture); OsPermissionException with Permission == "Screen Recording"
Linux, X11X11: XGetImage of the root window, monitors from RandRnothing. Under Xwayland it shows X windows only.
Linux, WaylandScreenshotPortal: the XDG Screenshot portalthe portal. It captures the whole desktop in one image (one display, id 0, bounds unknown), and may ask the user to confirm (the first time, or always with Interactive = true); a cancelled request throws OsPermissionException. The image the portal writes is read and then deleted.

Click-through overlays: OverlayOptions.ClickThrough

An overlay window (WindowOptions.Overlay) with ClickThrough = true takes no pointer input: clicks, movement and the wheel go to whatever is below it. Window.ClickThrough reports it. Fixed for the window's lifetime. Pair it with OverlayKeyboard.None.

  • Windows: WS_EX_TRANSPARENT | WS_EX_LAYERED (opaque layered window).
  • macOS: ignoresMouseEvents.
  • Wayland: an empty input region (wl_surface.set_input_region) on the layer surface.
  • X11: an empty input shape (Shape extension, ShapeInput); without the extension or libXext, creating the window throws OverlayUnavailableException.

macOS accessory apps: PlatformOptions.AccessoryApp

true runs the app with NSApplicationActivationPolicyAccessory: no Dock icon, no app menu in the menu bar, not in the Cmd-Tab switcher; its windows still take focus. For tray-icon tools and overlays. Ignored on other systems.

What is proven where

See the changelog entry; the tests are SystemDesktopPortableTests (tables, PNG reader, portal conversations against a stand-in portal), SystemDesktopX11Tests (Xvfb), SystemDesktopWindowsTests, SystemDesktopMacTests and the click-through test in DesktopWindowKwinTests (a nested compositor).