ethercat-linux/uia_find_dc.py

16 lines
756 B
Python
Raw Permalink Normal View History

import sys, time
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
from pywinauto import Application
app = Application(backend='uia').connect(process=int(sys.argv[1]), timeout=10)
win = app.top_window()
# look for DC-related text and combo boxes anywhere
texts = win.descendants(control_type='Text')
interesting = [t.window_text() for t in texts if t.window_text() and any(k in t.window_text() for k in ['FreeRun', 'DC', 'Synchron', 'EtherCAT', 'Sync'])]
print('interesting texts:', interesting[:40])
combos = win.descendants(control_type='ComboBox')
print('combos:', [c.window_text() for c in combos])
listitems = win.descendants(control_type='ListItem')
li = [l.window_text() for l in listitems if l.window_text()]
print('listitems:', li[:30])