38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
"""企业微信成功案例的安全提炼:probe 和 dry-run,不默认发送邀请。"""
|
||
|
||
from __future__ import annotations
|
||
|
||
from dataclasses import asdict
|
||
from typing import Any
|
||
|
||
from service.desktop_session import resolve_unique_window
|
||
from service.uia_locator import locate_unique, root_from_window, type_text
|
||
from util.selectors import ADD_CUSTOMER_WINDOW, CONTACTS_ENTRY, MAIN_WINDOW, SEARCH_INPUT
|
||
|
||
|
||
def probe() -> dict[str, Any]:
|
||
main = resolve_unique_window(MAIN_WINDOW)
|
||
root = root_from_window(main)
|
||
contacts = locate_unique(root, CONTACTS_ENTRY)
|
||
return {
|
||
"success": True,
|
||
"main_window": asdict(main),
|
||
"contacts_entry": {
|
||
"name": getattr(contacts, "Name", ""),
|
||
"control_type": getattr(contacts, "ControlTypeName", ""),
|
||
},
|
||
}
|
||
|
||
|
||
def fill_search_dry_run(target: str) -> dict[str, Any]:
|
||
"""要求操作者已打开“添加客户”窗口;只填写搜索框,不提交。"""
|
||
search_window = resolve_unique_window(ADD_CUSTOMER_WINDOW)
|
||
root = root_from_window(search_window)
|
||
search_input = locate_unique(root, SEARCH_INPUT)
|
||
type_text(search_input, target, window=search_window)
|
||
return {
|
||
"success": True,
|
||
"mode": "dry-run",
|
||
"message": "已填写搜索条件,未发送邀请",
|
||
}
|