⚡ Direct COM-level Windows UI Automation (UIA) access, zero-copy element queries, and event-driven focus tracking for Java.
FastUIA provides low-latency native UI Automation for Java by communicating directly with the Windows IUIAutomation COM interfaces via JNI, bypassing the marshaling overhead of standard frameworks. Designed for AI agents, RPA bots, and desktop automation systems that need to read and interact with UI elements at millisecond speed using FastCore for seamless native library loading.
import fastuia.FastUIA;
import fastuia.FastUIAElement;
public class Demo {
public static void main(String[] args) {
FastUIA uia = new FastUIA();
// 1. Query the currently focused UI element
FastUIAElement el = uia.getFocusedElement();
if (el != null) {
System.out.println("Focused: " + el.getName());
System.out.println("Type: " + el.getControlType());
if (el.supportsValue()) {
System.out.println("Value: " + el.getValue());
}
}
// 2. Get element at specific screen coordinates
FastUIAElement atPoint = uia.getElementFromPoint(960, 540);
if (atPoint != null) {
System.out.println("At (960,540): " + atPoint.getName());
}
// 3. Traverse the UI tree
FastUIAElement root = uia.getRootElement();
FastUIAElement first = root != null ? root.getFirstChild() : null;
if (first != null) {
System.out.println("First desktop child: " + first.getName());
}
}
}- Why FastUIA?
- Quick Start
- Key Features
- Real-World Use Cases
- API Quick Reference
- Technical Demos & Benchmarks
- Installation
- Documentation
- Platform Support
- Related Projects
- License
Standard Java UI automation stacks (Microsoft's own UIAutomationClient, third-party wrappers like WinAppDriver, Selenium) introduce multiple abstraction layers that severely degrade performance for tight automation loops:
- COM Marshaling Overhead: Every UIA call crosses process boundaries through heavyweight COM proxy stubs, adding 1-5 ms of latency per element query in framework wrappers.
- No Direct Event Dispatch: Standard Java UIA wrappers poll element state or piggyback on slow managed event queues. True event-driven focus and structure change callbacks require native COM sinks.
- Heap Allocation on Every Query: Wrapper APIs typically box all COM results into managed objects before returning them to Java, causing heap churn and GC pauses inside automation hot paths.
FastUIA bypasses all of these by binding directly to IUIAutomation COM interfaces via JNI:
| Feature | Standard Java UIA Wrappers | FastUIA |
|---|---|---|
| Element Access Latency | 1-5 ms per call (proxy COM marshaling) | Sub-millisecond direct IUIAutomation COM query |
| Screen-Point Lookup | Framework polling or slow HitTest | Direct ElementFromPoint via native COM call |
| Focus Events | Polling or heavy event listener overhead | Native IUIAutomationFocusChangedEventHandler sink |
| Tree Traversal | Object allocation per node | Zero-copy handle-based traversal |
| Heap Pressure | Boxed COM results on every call | GetPrimitiveArrayCritical pinning, no heap churn |
| Pattern Support | Generic pattern factory with reflection | Typed native pattern check per interface |
- ⚡ Direct COM-Level Access: JNI binds directly to
IUIAutomationandIUIAutomationElementCOM interfaces without managed marshaling proxies. - 🎯 Zero-Copy Element Queries: Bounding rectangles and primitive properties are transferred via
GetPrimitiveArrayCriticalpinning with no intermediate object allocation. - 📡 Event-Driven Callbacks: Register native
FocusChangedListener,TextChangedListener, andStructureChangedListenersinks backed by real Windows UIA event handlers. - 🌳 Full Tree Traversal: Navigate the full desktop UI automation tree via
getParent(),getFirstChild(),getNextSibling(),getPreviousSibling()with handle-level zero allocation. - đź§© Pattern Introspection: Typed per-pattern support checks (
supportsValue(),supportsInvoke(),supportsExpandCollapse(),supportsScroll(), and 9 more) backed by native COMQueryInterface. - đź”— FastCore Integration: Automated zero-dependency native DLL extraction and loading via
FastCore.loadLibrary.
- 🤖 Autonomous AI Desktop Agents: Read the focused element, control type, and bounding rectangle at each step of an AI agent loop to build a real-time UI state model for LLM-driven desktop automation.
- 🕵️ RPA & Workflow Automation: Drive enterprise desktop applications (SAP, thick-client ERP, legacy WinForms) by querying and interacting with UI elements at native COM speed.
- đź§Ş High-Speed UI Testing: Poll and validate element states in tight integration test loops without the 5-15 ms overhead of COM-proxied automation frameworks.
- 🖥️ Live UI Inspection & Overlay: Pair FastUIA element queries with FastOverlay to draw real-time bounding boxes around focused or hovered elements.
| Method | Return Type | Description | Docs |
|---|---|---|---|
getFocusedElement() |
FastUIAElement |
Returns the currently keyboard-focused UI element. | Reference |
getRootElement() |
FastUIAElement |
Returns the root desktop automation element. | Reference |
getElementFromPoint(x, y) |
FastUIAElement |
Returns the element at the given screen coordinates. | Reference |
setClickThrough(title, enabled) |
void |
Toggles Win32 click-through on a window by title. | Reference |
addFocusChangedListener(l) |
void |
Registers a native focus-change event sink. | Reference |
addTextChangedListener(l) |
void |
Registers a native text-change event sink. | Reference |
addStructureChangedListener(l) |
void |
Registers a native UI structure-change event sink. | Reference |
| Method | Return Type | Description | Docs |
|---|---|---|---|
getName() |
String |
Returns the accessible name of the element. | Reference |
getControlType() |
ControlType |
Returns the typed ControlType enum value. |
Reference |
getBoundingRect() |
Rect |
Returns the screen bounding rectangle (x, y, w, h). | Reference |
getValue() / setValue(s) |
String / void |
Gets or sets the element's ValuePattern text. |
Reference |
getSelection() / setSelection(s) |
String / void |
Gets or sets the element's TextPattern selection. |
Reference |
invoke() |
void |
Triggers the element's default action via InvokePattern. |
Reference |
expand() / collapse() |
void |
Controls ExpandCollapsePattern state. |
Reference |
scroll(h, v) |
void |
Scrolls element by horizontal and vertical percent. | Reference |
getParent() / getFirstChild() |
FastUIAElement |
Navigates the UI automation tree. | Reference |
getNextSibling() / getPreviousSibling() |
FastUIAElement |
Sibling-level tree traversal. | Reference |
getAutomationId() |
String |
Returns the automation ID string of the element. | Reference |
getFrameworkId() |
String |
Returns the UI framework name (e.g. "Win32", "WPF"). |
Reference |
getProcessId() |
int |
Returns the owning process ID. | Reference |
supportsValue() / supportsInvoke() |
boolean |
Pattern support introspection via native QueryInterface. |
Reference |
release() |
void |
Releases the underlying native COM element handle. | Reference |
| Case | Java Example | Launcher | Description |
|---|---|---|---|
| Focus Inspector Demo | Demo.java | run-demo.bat |
Queries the focused element, control type, bounding rect, and pattern support at each keystroke. |
| JMH Microbenchmark Suite | Benchmark.java | run-benchmark.bat |
JMH throughput measurements for element queries, tree traversal, and pattern introspection. |
Add the JitPack repository and the dependencies to your pom.xml:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<!-- FastUIA - Native Windows UI Automation -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastUIA</artifactId>
<version>0.1.0</version>
</dependency>
<!-- FastCore - Required Native JNI Loader -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastCore</artifactId>
<version>0.1.0</version>
</dependency>
</dependencies>repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.andrestubbe:FastUIA:0.1.0'
implementation 'com.github.andrestubbe:FastCore:0.1.0'
}Download the release JARs directly from GitHub Releases:
- 📦 FastUIA-0.1.0.jar (Core UI Automation Library)
- ⚙️ FastCore-0.1.0.jar (Mandatory Native Loader)
Important
Both JARs must be included in your classpath for the JNI calls to function correctly.
- COMPILE.md: Full native compilation guide (MSVC C++17 build chain + JNI setup).
- REFERENCE.md: Comprehensive API specification, COM architecture, and event system.
- PHILOSOPHY.md: Engineering rationale for direct COM-level UI Automation binding.
- ROADMAP.md: Planned milestones, pattern expansion, and cross-platform support.
- CHANGELOG.md: Complete version history and release notes.
| Platform | Architecture | Status | Driver / Subsystem |
|---|---|---|---|
| Windows 10 / 11 | x64 | âś… Fully Supported | IUIAutomation COM via native Win32 JNI |
| Linux | x64 / AArch64 | đźš§ Planned | AT-SPI2 / Atspi via D-Bus |
| macOS | Apple Silicon / x64 | đźš§ Planned | Accessibility API (AXUIElement) |
FastCore: Native Library Loader & JNI Utilities for JavaFastOverlay: High-Performance Native DirectComposition Transparent Overlay API for JavaFastRobot: Low-Latency Native Input & Bot Automation SubstrateFastScreen: High-Speed DXGI Screen Capture Engine (240-2000 FPS)FastWindow: Native Win32 Window Management & Styling SubstrateFastKeyboard: Ultra-Fast Native RawInput Keyboard Engine
MIT License. See LICENSE file for details.
Part of the FastJava Ecosystem — Making the JVM faster. 🚀
