Skip to main content
frameexpert
Community Expert
Community Expert
Sep 1, 2023 9:12 PM UTC
Question

Using ExtendScript to loop through all of the items on a menu

I am trying to loop through all of the items in a FrameMaker menu with ExtendScript. I am using this code, but it only gets me the first command on the menu. Any help would be appreciated.

 

#target framemaker

var menu, item;

menu = app.GetNamedMenu ("!HelpMenu");
Console (menu.Label);
item = menu.FirstMenuItemInMenu;
while (item.ObjectValid () === 1) {
    Console (item.Label);    
    item = item.NextMenuItemInMenu;
}

 

This topic is closed to new replies. Start a new post to keep the conversation going.

3 replies

Legend
Sep 5, 2023 11:18 AM UTC

Hi Rick, I can't help any more than to confirm that I see the same thing on FM2020. It doesn't surprise me... I've had lots of problems with menus and ExtendScript.

 

Russ

Translate
frameexpert
Community Expert
Community Expert
Sep 5, 2023 3:11 PM UTC

Thank you Klaus and Russ for checking. I was looking for an easy way to count the number of separators on a menu. I will post if I find a reliable way to loop through all of the items on a menu.

Translate
www.frameexpert.com
K.Daube
Community Expert
Community Expert
Sep 2, 2023 6:56 AM UTC

Rick,

I have tried with NextMenuItemInSession - this provides the full list. Watch the expanded sub-menu for S1000D Functionality:

 

&Help
&Help Topics...
&Samples...
S&upport...
&Manage My Account...
S&ign Out... (klaus@daube.ch)
U&pdates...
&Third-party Plugins/Add-ons...
Tr&aining/Consulting partners...
&Frequently asked questions...
&Application Pack Guide...
&Enhanced 3rd party extension for S1000D/ATA from Mekon...
FrameMaker &Online...
A&bout FrameMaker...

 

Translate