app_click_menu
Invoke an Altium menu command by named path through a real menu click, so commands run reliably or return the failure reason and any dialog opened.
Instructions
Invoke ANY Altium menu command by path, by driving the menu.
Use this when app_run_menu will not do, which is more often
than it looks: that tool reports success for commands it never
invokes, because the process ids it dispatches cannot report
failure and some of them are not real (task #83). This one
clicks the actual menu, so a command either runs or the reply
says why not.
PATH BY NAME. "Design|Rules...", "Tools|Update From Libraries...". Accelerator markers and a trailing ellipsis are
ignored, so "Design|Rules" works too. Nested submenus work
by adding levels. Names are used rather than positions because
entries move with context and separators are invisible.
IT NEEDS THE FOREGROUND. Altium has no Win32 menu and its
DevExpress bars expose no working accessible action, so the only
thing that opens them is real input: this brings Altium to the
front and briefly moves the pointer, putting it back afterwards.
Every other press in this package is addressed to a window
handle and depends on none of that, which is why this one is
gated behind may_steal_focus and never happens by default.
THE MENU BAR IS PER EDITOR. With a board focused you get the PCB menus, with a schematic the schematic ones. Focus the matching document first, or the reply will tell you the item was not there and list what was.
WHAT HAPPENS NEXT IS NOT THIS TOOL'S JOB. Many commands open a
dialog. Read it with app_list_open_dialogs; the dialog
drivers handle the rest.
Args:
menu_path: pipe-separated path, top level first.
may_steal_focus: required to actually click anything.
list_only: do not invoke. Reports the top-level menus
currently on screen, which is the way to find out what
this editor context offers.
expect_dialog: part of the title of the dialog the command
should open. Then ok means that dialog appeared; any
other dialog, or none, fails and names what did open.
Returns:
Dict with ok and opened (titles of dialogs that
appeared); on failure reason and offered listing what
that level actually contained. A path that leaves the menu
open (it ended at a submenu, or the click did not land) is a
failure: no command ran. A level that reads empty, or without
the entry asked for, is walked once more before failing
(retried); first_read then says what the first read
found, and both reads are in reason when both fail.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| list_only | No | ||
| menu_path | Yes | ||
| expect_dialog | No | ||
| may_steal_focus | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||