Detect which menu item is selected, and copy item name as variable

I understand KM can detect if a menu item is "marked" (essentially what was discussed in this thread Detecting whether a menu item has been selected). But is there some way for KM to look through a submenu of multiple items, find which of those items is marked (as only one submenu item in this case can be marked at a time), and then copy the name of that menu item (or just react accordingly based on its findings)?

For example, only one of these three menu items can be selected at once. I'd like KM to be able to read which one is selected, and possibly even copy that name to a variable (without having to create a huge nested list of If/Then statements based on all possible results).

image

Since you are asking KM to check if a particular menu item is checked and do something if it is, there is no way of avoiding an If/Then for each of the menu items you want to check...

But rather than nesting the If/Then Actions, put them one after the other.

In the example you gave there are three possible results if an item is checked. So, you would have a series of three If/Then Actions one after the other.

If you want the Macro to do nothing if none of the items are checked then that would do it. But if you want a "fourth" result for when none are checked you could add a fourth If/Then.

EXAMPLE Marked Menu Items.kmmacros (6.6 KB)

Click to Show Image of Macro

2 Likes