54 lines
1.8 KiB
Python
54 lines
1.8 KiB
Python
|
|
import sys, time
|
||
|
|
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
|
||
|
|
from pywinauto import Application
|
||
|
|
from pywinauto.mouse import double_click
|
||
|
|
|
||
|
|
app = Application(backend='uia').connect(process=1456, timeout=10)
|
||
|
|
win = app.window(title_re='.*TcXaeShell.*')
|
||
|
|
tree = win.descendants(control_type='Tree')[0]
|
||
|
|
|
||
|
|
def find_item(item, name, depth=0):
|
||
|
|
try:
|
||
|
|
item.expand(); time.sleep(0.25)
|
||
|
|
except Exception:
|
||
|
|
pass
|
||
|
|
try:
|
||
|
|
for ch in item.children():
|
||
|
|
if ch.window_text() == name:
|
||
|
|
return ch
|
||
|
|
r = find_item(ch, name, depth + 1)
|
||
|
|
if r is not None:
|
||
|
|
return r
|
||
|
|
except Exception:
|
||
|
|
pass
|
||
|
|
return None
|
||
|
|
|
||
|
|
rt = None
|
||
|
|
for root in tree.children():
|
||
|
|
rt = find_item(root, '实时')
|
||
|
|
if rt:
|
||
|
|
break
|
||
|
|
if not rt:
|
||
|
|
print('实时 node not found'); sys.exit(1)
|
||
|
|
print('found 实时, double-clicking...')
|
||
|
|
rt.iface_expand_collapse.Expand()
|
||
|
|
time.sleep(0.5)
|
||
|
|
r = rt.rectangle()
|
||
|
|
double_click(coords=(int((r.left + r.right) / 2), int((r.top + r.bottom) / 2)))
|
||
|
|
time.sleep(3)
|
||
|
|
|
||
|
|
# dump new document/dialog contents
|
||
|
|
win.set_focus()
|
||
|
|
tabs = win.descendants(control_type='TabItem')
|
||
|
|
print('tab items:', [t.window_text() for t in tabs])
|
||
|
|
combos = win.descendants(control_type='ComboBox')
|
||
|
|
print('combos:', [(c.window_text()) for c in combos])
|
||
|
|
edits = win.descendants(control_type='Edit')
|
||
|
|
print('edits:', [(e.window_text()) for e in edits][:20])
|
||
|
|
buttons = win.descendants(control_type='Button')
|
||
|
|
print('buttons:', [b.window_text() for b in buttons][:20])
|
||
|
|
# text labels containing Base
|
||
|
|
texts = win.descendants(control_type='Text')
|
||
|
|
base_related = [t.window_text() for t in texts if t.window_text() and ('Base' in t.window_text() or '基' in t.window_text() or 'ms' in t.window_text() or 'CPU' in t.window_text())]
|
||
|
|
print('base-related texts:', base_related[:30])
|