Preserve tested Verify source, authoritative READY checks, bounded bridge retries, diagnostics and failure-only reporting. Include 336-test suite and packaging assets; exclude live Mentor samples, field logs, backups and distributions.
56 lines
2.4 KiB
Python
56 lines
2.4 KiB
Python
import ctypes
|
|
import json
|
|
import time
|
|
from pathlib import Path
|
|
|
|
import win32con
|
|
import win32gui
|
|
from pywinauto import Desktop, win32defines
|
|
from pywinauto.controls.common_controls import TreeViewWrapper
|
|
|
|
|
|
library = Path(r"F:\Sync Tool Skyworth\Work Maps\cbb-refresh-verify-795\build\background-fixture\Mentor_lib_EE7.9\mentor_lib.lmc")
|
|
output = Path(r"F:\Sync Tool Skyworth\Work Maps\cbb-refresh-verify-795\build\context-child-result.jsonl")
|
|
name = "Audio_D2128_ESD"
|
|
target = None
|
|
for _ in range(160):
|
|
windows = [w for w in Desktop(backend="win32").windows()
|
|
if w.is_visible() and w.window_text().startswith("Library Manager:")
|
|
and str(library).casefold() in w.window_text().casefold()]
|
|
if windows:
|
|
target = windows[-1]
|
|
break
|
|
time.sleep(0.25)
|
|
if target is None:
|
|
raise RuntimeError("Library Manager child window not found")
|
|
|
|
tw = [w for w in target.descendants() if "TreeView" in w.class_name()][0]
|
|
tree = TreeViewWrapper(tw.handle)
|
|
item = tree.get_item(["Central Libraries", library.name, "Reusable Blocks", "Logical-Physical", name], exact=True)
|
|
item.ensure_visible()
|
|
tree.send_message(win32defines.TVM_SELECTITEM, win32defines.TVGN_CARET, item.elem)
|
|
|
|
def dump(label):
|
|
time.sleep(0.5)
|
|
menus = [m for m in Desktop(backend="uia").windows(control_type="Menu") if m.is_visible()]
|
|
values = []
|
|
for menu in menus:
|
|
values.append({"menu": getattr(menu, "handle", None), "items": [
|
|
(x.window_text(), x.element_info.automation_id, x.is_enabled())
|
|
for x in menu.descendants(control_type="MenuItem")
|
|
]})
|
|
line = label + " " + json.dumps(values, ensure_ascii=False)
|
|
output.open("a", encoding="utf-8").write(line + "\n")
|
|
print(line, flush=True)
|
|
ctypes.windll.user32.EndMenu()
|
|
|
|
output.write_text(f"target {target.handle} {target.process_id()} tree {tw.handle} selected {item.is_selected()}\n", encoding="utf-8")
|
|
print("target", target.handle, target.process_id(), "tree", tw.handle, "selected", item.is_selected(), flush=True)
|
|
ctypes.windll.user32.PostMessageW(tw.handle, win32con.WM_CONTEXTMENU, tw.handle, 0xFFFFFFFF)
|
|
dump("context--1")
|
|
ctypes.windll.user32.PostMessageW(tw.handle, win32con.WM_CONTEXTMENU, tw.handle, 0)
|
|
dump("context-0")
|
|
ctypes.windll.user32.PostMessageW(tw.handle, win32con.WM_KEYDOWN, win32con.VK_APPS, 0)
|
|
ctypes.windll.user32.PostMessageW(tw.handle, win32con.WM_KEYUP, win32con.VK_APPS, 0)
|
|
dump("apps")
|