UI Tree Logs
UFO can capture the complete UI control tree of application windows at every step. This structured data represents the hierarchical UI layout and is useful for analysis and debugging.
Configuration
Enable UI tree logging by setting SAVE_UI_TREE: true in config_dev.yaml.
Location: logs/{task_name}/ui_tree/
File naming: step_{step_number}.json
Example
{
"id": "node_0",
"name": "Mail - Chaoyun Zhang - Outlook",
"control_type": "Window",
"rectangle": {
"left": 628,
"top": 258,
"right": 3508,
"bottom": 1795
},
"adjusted_rectangle": {
"left": 0,
"top": 0,
"right": 2880,
"bottom": 1537
},
"relative_rectangle": {
"left": 0.0,
"top": 0.0,
"right": 1.0,
"bottom": 1.0
},
"level": 0,
"children": [
{
"id": "node_1",
"name": "",
"control_type": "Pane",
"rectangle": {
"left": 3282,
"top": 258,
"right": 3498,
"bottom": 330
},
"adjusted_rectangle": {
"left": 2654,
"top": 0,
"right": 2870,
"bottom": 72
},
"relative_rectangle": {
"left": 0.9215277777777777,
"top": 0.0,
"right": 0.9965277777777778,
"bottom": 0.0468445022771633
},
"level": 1,
"children": []
}
]
}
Field Reference
| Field | Description | Type |
|---|---|---|
id |
Unique node identifier in the tree | String |
name |
Control element name/text | String |
control_type |
UI element type (Window, Button, Edit, etc.) | String |
rectangle |
Absolute screen coordinates | Dictionary |
adjusted_rectangle |
Coordinates relative to window | Dictionary |
relative_rectangle |
Normalized coordinates (0.0-1.0) | Dictionary |
level |
Depth in the UI tree hierarchy | Integer |
children |
Child UI elements | List |
Rectangle Structure
All rectangle fields contain:
{
"left": 0,
"top": 0,
"right": 100,
"bottom": 100
}
Usage
UI tree logs enable:
- Understanding application structure
- Analyzing control element hierarchy
- Debugging control selection issues
- Training ML models on UI data
Performance Impact
Saving UI trees increases execution latency. Disable when not needed for data collection.
Reference
A class to represent the UI tree.
Initialize the UI tree with the root element.
| Parameters: |
|
|---|
Source code in automator/ui_control/ui_tree.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
ui_tree
property
The UI tree.
apply_ui_tree_diff(ui_tree_1, diff)
staticmethod
Apply a UI tree diff to ui_tree_1 to get ui_tree_2.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in automator/ui_control/ui_tree.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | |
flatten_ui_tree()
Flatten the UI tree into a list in width-first order.
Source code in automator/ui_control/ui_tree.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
save_ui_tree_to_json(file_path)
Save the UI tree to a JSON file.
| Parameters: |
|
|---|
Source code in automator/ui_control/ui_tree.py
108 109 110 111 112 113 114 115 116 117 118 119 120 | |
ui_tree_diff(ui_tree_1, ui_tree_2)
staticmethod
Compute the difference between two UI trees.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in automator/ui_control/ui_tree.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |