← Commit history

Upload 1 file(s)

John Lauer ·7ca93f0b5a ·2mo ago ·parent 4b80138
1 file changed +28−5
server.py+28−5
@@ -3731,17 +3731,40 @@ def _chrome_authorize_urls(max_age_min: int = 15):     return found  +def _fusion_window_hwnd():+    """Find the main Fusion window's hwnd by title (via desktop_list_windows). Returns int|None."""+    r = _ad_call("desktop_list_windows", {}, timeout=40)+    wins = (r.get("windows") if isinstance(r, dict) else None) or []+    if not wins and isinstance(r, dict):+        wins = ((r.get("data") or {}).get("windows")) or []+    cand = None+    for w in wins:+        t = str(w.get("title", ""))+        tl = t.lower()+        if "autodesk fusion" in tl or tl.startswith("signing in") or t.strip() == "Autodesk Fusion":+            # prefer the sign-in/welcome window+            if "signing in" in tl or "welcome" in tl:+                return w.get("hwnd")+            cand = cand or w.get("hwnd")+    return cand++ def _fusion_click_signin() -> bool:     """Click Fusion's 'Welcome to Fusion' -> Sign In button SERVER-SIDE (it is a webview with     no UIA node, so image-space click). Returns True if a click was dispatched. Runs on-box so     it adds no remote round-trip to the ~2-min OAuth window."""-    rd = _handle_fusion_readiness({}, {})-    hwnd = rd.get("hwnd") or rd.get("windowHandle")-    shot = _ad_call("desktop_screenshot_window", {"hwnd": hwnd} if hwnd else {"titleContains": "Autodesk Fusion"}, timeout=45)-    sd = shot.get("data", shot) if isinstance(shot, dict) else {}+    hwnd = _fusion_window_hwnd()+    if not hwnd:+        rd = _handle_fusion_readiness({}, {})+        hwnd = rd.get("hwnd") or rd.get("windowHandle")+    if not hwnd:+        return False+    shot = _ad_call("desktop_screenshot_window", {"hwnd": int(hwnd)}, timeout=45)+    sd = shot if isinstance(shot, dict) else {}     cm = sd.get("coordMap") or {}     sid = cm.get("shotId") or sd.get("shotId")-    w = sd.get("width") or 1400; h = sd.get("height") or 860+    w = sd.get("width") or (cm.get("imageWidth") if isinstance(cm, dict) else None) or 1400+    h = sd.get("height") or (cm.get("imageHeight") if isinstance(cm, dict) else None) or 860     if not sid:         return False     # the Sign In button sits centered, ~57% down the welcome screen