@@ -10,6 +10,7 @@ public class ContextDemo {
1010
1111 public static void main (String [] args ) throws Exception {
1212
13+ System .out .println ("[DEBUG] Initializing FastUIA..." );
1314 FastUIA uia = new FastUIA ();
1415 FastUIAElement last = null ;
1516
@@ -19,50 +20,65 @@ public static void main(String[] args) throws Exception {
1920 System .out .println ("==================================================\n " );
2021
2122 while (true ) {
22-
2323 FastUIAElement el = uia .getFocusedElement ();
24- if (el == null || !el .isValid ()) {
24+
25+ if (el == null ) {
26+ // Silent wait if nothing is focused (e.g. desktop transition)
27+ Thread .sleep (200 );
28+ continue ;
29+ }
30+
31+ if (!el .isValid ()) {
32+ System .out .println ("[DEBUG] Focused element handle " + el .handle () + " is invalid." );
2533 Thread .sleep (200 );
2634 continue ;
2735 }
2836
2937 // Display info only when focus changes
3038 if (last == null || el .handle () != last .handle ()) {
3139
40+ System .out .println ("\n [EVENT] Focus Changed -> Handle: " + el .handle ());
3241 System .out .println ("--------------------------------------------------" );
3342
3443 // 1. Identity
35- System .out .println ("Element: " + el .getName ());
36- System .out .println ("Typ: " + el .getControlType ());
44+ String name = el .getName ();
45+ ControlType type = el .getControlType ();
46+ System .out .println ("[DATA] Name: " + (name != null ? "\" " + name + "\" " : "<null>" ));
47+ System .out .println ("[DATA] Type: " + type );
3748
3849 // 2. Geometry
3950 Rect r = el .getBoundingRect ();
4051 if (r != null ) {
41- System .out .println ("Rect: " + r .x () + "," + r .y () +
42- " [" + r .width () + "x" + r .height () + "]" );
52+ System .out .println ("[DATA] Rect: " + r .x () + "," + r .y () +
53+ " [" + r .width () + "x" + r .height () + "]" );
54+ } else {
55+ System .out .println ("[DATA] Rect: <null>" );
4356 }
4457
4558 // 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 ());
59+ System .out .println ("[CHECK] Pattern Support :" );
60+ System .out .println (" - Value: " + el .supportsValue ());
61+ System .out .println (" - Text: " + el .supportsText ());
62+ System .out .println (" - Invoke: " + el .supportsInvoke ());
63+ System .out .println (" - ExpandCollapse: " + el .supportsExpandCollapse ());
64+ System .out .println (" - Scroll: " + el .supportsScroll ());
65+ System .out .println (" - isTextField: " + el .isTextField ());
5366
5467 // 4. Action (Demo: Interact with text fields)
5568 if (el .supportsValue ()) {
5669 String current = el .getValue ();
70+ System .out .println ("[DATA] Current Value: " + (current != null ? "\" " + current + "\" " : "<null>" ));
71+
5772 if (current != null && !current .contains ("[FastUIA]" )) {
5873 String updated = current + " [FastUIA]" ;
74+ System .out .println ("[ACTION] Setting new value: \" " + updated + "\" " );
5975 el .setValue (updated );
60- System .out .println ("Action: Text updated in native element ." );
76+ System .out .println ("[SUCCESS] Value updated." );
6177 }
6278 }
6379
6480 if (el .supportsInvoke ()) {
65- System .out .println ("Action: (Button could be invoked via el.invoke()) " );
81+ System .out .println ("[INFO] Element is invokable (Button/Link). " );
6682 }
6783
6884 last = el ;
0 commit comments