Can a menu condition specify both the menu and item name?

I’m writing a Mail macro that depends on whether the Delete item in the Edit menu is enabled. Just branching on a “Delete” menu item seems overly general; I’d rather specify which menu the menu item is in. Can I?

I’ve tried “Edit/Delete” and “Edit:Delete”; neither worked. For the “Select or Show a Menu Item” action there’s a tool to choose and specify a menu item’s parent and name (and even submenu name); is there a text-only way to specify the same info in a condition?

No, there is no way within Keyboard Maestro to specify the full menu path for that condition.

You could, presumably, use AppleScript to determine the information, though I’m not sure exactly how that is done.

Yes.

tell application "System Events"
  if quit delay ≠ 0 then set quit delay to 0
  tell application process "Mail"
    set frontmost to true
    tell menu item "Delete" of menu 1 of menu bar item "Edit" of menu bar 1
      if enabled = true then
        # click it
        set deleteIsEnabled to true
      else
        set deleteIsEnabled to false
      end if
    end tell
  end tell
end tell

--
Best Regards,
Chris

1 Like