Skip to main content
frameexpert
Community Expert
Community Expert
September 1, 2023
Question

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

  • September 1, 2023
  • 2 replies
  • 327 views

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 has been closed for replies.

2 replies

Legend
September 5, 2023

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

frameexpert
Community Expert
Community Expert
September 5, 2023

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.

K.Daube
Community Expert
Community Expert
September 2, 2023

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...