Skip to content

Commit 1c9003a

Browse files
committed
feat: upgrade to FastJava-Style OO-API & Context Explorer Demo
- Implemented FastUIAElement wrapper for object-oriented interaction - Added full support for 15+ UIA Patterns (Value, Text, Scroll, Grid, etc.) - Refactored native core to C++ Singleton architecture (fastuia_native) - Renamed JNI layer to camelCase native... signatures for consistency - Added ContextDemo.java as the new primary 'Context Explorer' showcase - Updated README.md with modern API examples and GitHub metadata
1 parent a827b51 commit 1c9003a

11 files changed

Lines changed: 676 additions & 541 deletions

File tree

README.md

Lines changed: 25 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# FastUIA — Native Windows UI Automation API for Java
22

3-
**Lightweight native Windows UI Automation capabilities for Java applications.**
3+
**High-performance, native Windows UI Automation (UIA) for Java.**
44

55
[![Build](https://img.shields.io/github/actions/workflow/status/andrestubbe/FastUIA/maven.yml?branch=main)](https://github.com/andrestubbe/FastUIA/actions)
66
[![Java](https://img.shields.io/badge/Java-17+-blue.svg)](https://www.java.com)
@@ -13,15 +13,23 @@ FastUIA provides **real-time native UI Automation** for Java applications withou
1313
```java
1414
// Quick Start — Example
1515
import fastuia.FastUIA;
16+
import fastuia.FastUIAElement;
1617

1718
public class Demo {
1819
public static void main(String[] args) {
1920
FastUIA uia = new FastUIA();
2021

21-
long focusedElement = uia.GetFocusedElement();
22-
String name = uia.GetName(focusedElement);
22+
// Get focused element
23+
FastUIAElement el = uia.getFocusedElement();
2324

24-
System.out.println("Focused element: " + name);
25+
if (el != null) {
26+
System.out.println("Focused: " + el.getName());
27+
System.out.println("Type: " + el.getControlType());
28+
29+
if (el.supportsValue()) {
30+
System.out.println("Value: " + el.getValue());
31+
}
32+
}
2533
}
2634
}
2735
```
@@ -45,6 +53,7 @@ public class Demo {
4553
- **🚀 Native Performance** — Direct UI Automation API access via JNI.
4654
- **⚡ Zero Overhead** — No polling, purely event-driven callbacks.
4755
- **📦 Zero Dependencies** — Just requires Java 17+ and Windows.
56+
- **🎯 Object-Oriented** — Clean, type-safe API for elements and patterns.
4857

4958
---
5059

@@ -78,52 +87,21 @@ FastJava modules require **two** dependencies: the module itself, and `FastCore`
7887
</dependencies>
7988
```
8089

81-
### Gradle (JitPack)
82-
```groovy
83-
repositories {
84-
maven { url 'https://jitpack.io' }
85-
}
86-
87-
dependencies {
88-
implementation 'com.github.andrestubbe:fastuia:0.1.0'
89-
implementation 'com.github.andrestubbe:fastcore:0.1.0'
90-
}
91-
```
92-
93-
---
94-
95-
## Try the Demo
96-
97-
Want to see it in action without configuring anything?
98-
99-
1. Clone this repository
100-
2. Open the `examples/Demo` folder
101-
3. Run `mvn exec:java`
102-
103-
*Note: The demo automatically downloads the required JitPack dependencies.*
104-
10590
---
10691

107-
## API Reference
92+
## API Reference (FastUIAElement)
10893

10994
| Method | Description |
11095
|--------|-------------|
111-
| `long GetFocusedElement()` | Get the currently focused UI element. |
112-
| `String GetControlType(long elementHandle)` | Get the control type of a UI element. |
113-
| `int[] GetBoundingRect(long elementHandle)` | Get the bounding rectangle of a UI element. |
114-
| `String GetName(long elementHandle)` | Get the name of a UI element. |
115-
| `String GetValue(long elementHandle)` | Get the value of a UI element. |
116-
| `void SetValue(long elementHandle, String value)` | Set the value of a UI element. |
117-
| `String GetSelection(long elementHandle)` | Get the selection of a UI element. |
118-
| `void SetSelection(long elementHandle, String selection)` | Set the selection of a UI element. |
119-
| `void Invoke(long elementHandle)` | Invoke the default action of a UI element. |
120-
| `void Expand(long elementHandle)` | Expand a UI element. |
121-
| `void Collapse(long elementHandle)` | Collapse a UI element. |
122-
| `void Scroll(long elementHandle, double horizontalPercent, double verticalPercent)` | Scroll a UI element. |
123-
| `long GetParent(long elementHandle)` | Get the parent element of a UI element. |
124-
| `long GetFirstChild(long elementHandle)` | Get the first child element of a UI element. |
125-
| `long GetNextSibling(long elementHandle)` | Get the next sibling element of a UI element. |
126-
| `long GetPreviousSibling(long elementHandle)` | Get the previous sibling element of a UI element. |
96+
| `getName()` | Get the name of the UI element. |
97+
| `getControlType()` | Get the `ControlType` enum value. |
98+
| `getValue()` / `setValue(String)` | Access the `ValuePattern` if supported. |
99+
| `getSelection()` / `setSelection(String)` | Access the `TextPattern` if supported. |
100+
| `invoke()` | Trigger the default action (`InvokePattern`). |
101+
| `expand()` / `collapse()` | Control `ExpandCollapsePattern`. |
102+
| `getBoundingRect()` | Get the `Rect` (x, y, w, h). |
103+
| `getParent()` / `getFirstChild()` | Navigate the UI tree. |
104+
| `supportsValue()` / `supportsText()` | Check for pattern support. |
127105

128106
---
129107

@@ -157,6 +135,6 @@ MIT License — See [LICENSE](LICENSE) file for details.
157135
**Made with ⚡ by Andre Stubbe**
158136

159137
<!--
160-
SEO Keywords: java, jni, native, fastjava, ui automation, windows api, performance tuning
161-
Remember to also add these keywords as Topics in the GitHub repository settings!
138+
GitHub About: High-performance, native Windows UI Automation (UIA) for Java. Lightweight, event-driven, and architected for real-time system tools, overlays, and automation.
139+
Topics: java, jni, native, windows-api, ui-automation, uia, performance, low-latency, fastjava, automation-framework
162140
-->

examples/Demo/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
<artifactId>exec-maven-plugin</artifactId>
6969
<version>3.1.0</version>
7070
<configuration>
71-
<mainClass>fastuia.Demo</mainClass>
71+
<mainClass>fastuia.ContextDemo</mainClass>
7272
</configuration>
7373
</plugin>
7474
</plugins>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package fastuia;
2+
3+
import fastuia.*;
4+
5+
/**
6+
* FastUIA Context Explorer — Native Context Explorer Demo.
7+
* Showcases real-time focus tracking and interaction with UI elements.
8+
*/
9+
public class ContextDemo {
10+
11+
public static void main(String[] args) throws Exception {
12+
13+
FastUIA uia = new FastUIA();
14+
FastUIAElement last = null;
15+
16+
System.out.println("==================================================");
17+
System.out.println(" FastUIA Context Explorer — Running... ");
18+
System.out.println(" (Focus on any window to see its structure) ");
19+
System.out.println("==================================================\n");
20+
21+
while (true) {
22+
23+
FastUIAElement el = uia.getFocusedElement();
24+
if (el == null || !el.isValid()) {
25+
Thread.sleep(200);
26+
continue;
27+
}
28+
29+
// Display info only when focus changes
30+
if (last == null || el.handle() != last.handle()) {
31+
32+
System.out.println("--------------------------------------------------");
33+
34+
// 1. Identity
35+
System.out.println("Element: " + el.getName());
36+
System.out.println("Typ: " + el.getControlType());
37+
38+
// 2. Geometry
39+
Rect r = el.getBoundingRect();
40+
if (r != null) {
41+
System.out.println("Rect: " + r.x() + "," + r.y() +
42+
" [" + r.width() + "x" + r.height() + "]");
43+
}
44+
45+
// 3. Capabilities
46+
System.out.println("Supports:");
47+
System.out.println(" Value: " + el.supportsValue());
48+
System.out.println(" Text: " + el.supportsText());
49+
System.out.println(" Invoke: " + el.supportsInvoke());
50+
System.out.println(" ExpandCollapse: " + el.supportsExpandCollapse());
51+
System.out.println(" Scroll: " + el.supportsScroll());
52+
System.out.println(" isTextField: " + el.isTextField());
53+
54+
// 4. Action (Demo: Interact with text fields)
55+
if (el.supportsValue()) {
56+
String current = el.getValue();
57+
if (current != null && !current.contains("[FastUIA]")) {
58+
String updated = current + " [FastUIA]";
59+
el.setValue(updated);
60+
System.out.println("Action: Text updated in native element.");
61+
}
62+
}
63+
64+
if (el.supportsInvoke()) {
65+
System.out.println("Action: (Button could be invoked via el.invoke())");
66+
}
67+
68+
last = el;
69+
}
70+
71+
Thread.sleep(150);
72+
}
73+
}
74+
}

0 commit comments

Comments
 (0)