Open general

Four generic desktop verbs every bridge re-implements: guard_background, menu_invoke, post_key/post_text, play_audio

John Lauer · 2mo ago

Four generic desktop verbs the KiCad bridge carries today as private Win32 code that every other bridge (Fusion, Altium, Blender) needs too. Written up in the KiCad bridge's Rust port plan: https://wiki.adom.inc/adom/kicad-bridge/files/docs/rust-port-plan.md (section "Asks for the ab-core thread"). If ab declines any of them the KiCad binary keeps its own copy, so none of these block the port; they decide whether the etiquette is shared or duplicated.

  1. desktop_guard_background {pids|images, seconds}: the focus guardian as an ab service. The policy loop the KiCad bridge measured over a month: a 120 ms foreground sentinel plus a WinEventHook on EVENT_SYSTEM_FOREGROUND and EVENT_OBJECT_SHOW; when a guarded window takes the foreground while a verb is in flight, push it to HWND_BOTTOM once per (hwnd, pid), never minimize, never park off screen; skip when the user clicked it (GetAsyncKeyState on mouse buttons plus cursor-over check), alt-tabbed to it, or has been idle past the foreground lock timeout (the idle rule); auto-release after the verb ends. ab already has get_foreground, send_to_bottom and raise_window; what is missing is the loop and the rules. Reference implementation: handlers/win_focus.py on the kicad-bridge page.

  2. desktop_menu_invoke {hwnd, path:["View","3D Viewer"]} (and a desktop_menu_list {hwnd} to read the tree): walk the native Win32 menu bar with GetMenu, GetSubMenu, GetMenuStringW, GetMenuItemID and post WM_COMMAND with the resolved id. Background, no focus, no cursor, version-proof because ids come from the live menu bar. This is the KiCad bridge's most reliable trigger for opening editors and viewers and it is generic to every wx and MFC app. Reference: handlers/win_menu.py.

  3. desktop_post_key {hwnd, vk, char?} and desktop_post_text {hwnd, text}: PostMessage WM_KEYDOWN/WM_CHAR/WM_KEYUP and WM_SETTEXT to ONE window's queue. ab's type and press_key are SendInput and therefore global; they need the foreground. Posted keys are the only way to drive a library-tree filter box while the user keeps working. Known limit to document in the hint: modifier chords are unreliable this way.

  4. desktop_play_audio {path, volume?} with stop and status: the tour narration today is a hidden PowerShell WPF MediaPlayer because ab has no audio verb. A WinRT MediaPlayer in ab would serve every narrated bridge demo.

Priority from the KiCad side: 2 and 3 first (they delete PowerShell and the most fragile code), then 1, then 4.

0 Replies

Log in to reply.