Initial commit with translated description

This commit is contained in:
2026-03-29 09:39:00 +08:00
commit 952514b082
4 changed files with 138 additions and 0 deletions

34
scripts/inspect_ui.py Normal file
View File

@@ -0,0 +1,34 @@
#!/usr/bin/env python3
import sys
import argparse
from dogtail.tree import root
def dump_node(node, depth=0, max_depth=10):
if depth > max_depth:
return
try:
name = node.name.strip()
role = node.roleName
# Only print if it has a name or is an interesting interactive element
if name or role in ['push button', 'entry', 'menu item', 'toggle button', 'check box']:
print(' ' * depth + f'<{role}> {name}')
for child in node.children:
dump_node(child, depth + 1, max_depth)
except:
pass
def main():
parser = argparse.ArgumentParser(description="Inspect Linux GUI application UI tree.")
parser.add_argument("app_name", help="Name of the application to inspect.")
parser.add_argument("--max-depth", type=int, default=15, help="Maximum depth to traverse.")
args = parser.parse_args()
try:
app = root.application(args.app_name)
print(f"Dump for application: {args.app_name}")
dump_node(app, max_depth=args.max_depth)
except Exception as e:
print(f"Error: Could not find or inspect application '{args.app_name}'. {e}")
if __name__ == "__main__":
main()