← Commit history

dev skill: Win32 menu-bar technique for plugin-free menu actions (#26)

John Lauer ·a9ea3bfd2d ·2mo ago ·parent 9881123
1 file changed +19
skills/kicad-bridge-dev/SKILL.md+19
@@ -366,3 +366,22 @@ out capturing every window. - Lib-table self-heal (0.9.84): early bootstraps left users with ZERO stock   libraries; boot now merges missing stock-template rows. If a part won't load,   check the sym/fp-lib-table row count FIRST.+++## Plugin-free menu actions: the Win32 menu bar (2026-08-15, #26)++When you need to trigger a KiCad MENU action (3D Viewer, and anything else on a+menu) WITHOUT the late-binding plugin and WITHOUT stealing focus: wxFrame menus+on Windows are NATIVE Win32 menus. `handlers/win_menu.py`:+  win_menu.open_via_menu(hwnd, "3d viewer")+walks the window's menu bar (GetMenu -> GetSubMenu recursion), matches the item+by text, reads its command id, and PostMessage(WM_COMMAND)s it. No plugin, no+focus, no cursor, no UIA. This is Tier 0 of open_3d_viewer and the template for+any future "invoke a KiCad menu item from cold" need.++TRAP that cost time: KiCad's toolbar/menu is opaque to an out-of-process UIA+WALK (FindAll returns no named buttons / menu items), which looked like "no+plugin-free path exists." It was a red herring — the Win32 menu API sees the menu+perfectly. When a UIA walk comes back empty, try GetMenu before concluding the+control is unreachable. (Also: PowerShell P/Invoke through shell_execute is+quoting-hell; write the ctypes walk in a bridge handler and test via the verb.)