Skip to main content
akinuri
Known Participant
September 11, 2016
Answered

Get menu command strings

  • September 11, 2016
  • 2 replies
  • 2247 views

I recently needed a way to fit the artboards into view and learned that I can do it using app.executeMenuCommand("fitall"). When I searched through the scripting PDFs, I've found no mention of this method.

Then I was made aware of this question [JS] CS6+  executeMenuCommand2. There are lists of commands and some links in the answers. I've visited the links and this AI CS6 `app.executeMenuCommand` was the most enlightening one as to where and how to get these commands. So I followed what the author did.

  1. Create a new document
    1. Profile: Print
    2. Size: Letter
  2. Create a new Action set
    1. Name it "My Set"
  3. Create a new Action inside the new set
    1. Name it "Fit artboard"
  4. Insert menu item
    1. Select View->Fit Artboard in Window.
    2. Click OK
  5. Save Actions to file
    1. File name is "My Set.aia"

When I examine the "My Set.aia" file, I see there are 3 parameters. The first is the menu command. The second is the name of the command. I don't know what the third is. Parameter values are in hex format. Once I convert "666974696e" into ASCII, I get "fitin", the menu command string for "Fit Artboard in Window".

/parameter-1 {

  /key 1769238125

  /showInPalette -1

  /type (ustring)

  /value [ 5

      666974696e

  ]

}

See the original and the converted action files.

I've tested this with few other commands and it seems to work. Although I couldn't make it work for "Fit All in Window". When inserting menu item in Actions, selecting View->Fit All in Window does nothing. Typing "Fit All in Window" and clicking on "Find" also doesn't work. Gives the warning "No menu item matching that name was found". Why is that?

Sigh. I wish there was an official documentation for app.executeMenuCommand() and these commands were easier to access.

This topic has been closed for replies.
Correct answer pixxxelschubser

I'm using CS6 64-bit on Windows 8.1 Pro and this isn't working for me.


Ok. It seems to be that you are totally right.

It is not possible to record this menu command in CS6 (64-bit) and not in CS6 (32-bit). Perhaps a bug in this Illustrator version.

2 replies

pixxxelschubser
Community Expert
Community Expert
September 12, 2016

How about

/value [ 6

                666974616c6c

            ]

akinuri
akinuriAuthor
Known Participant
September 12, 2016

Did you get it by recording "Fit All in Window" in an action? If so, how? I'm using CS6 64-bit and it doesn't record "Fit All in Window".

pixxxelschubser
Community Expert
Community Expert
September 12, 2016

akinuri schrieb:

Did you get it by recording "Fit All in Window" in an action? …

Yes.

akinuri schrieb:

…If so, how? …

How? Simply recorded.

(Tested with CS5, CC2014 and CC2015 Win)

edit:

If you cannot record the menu command, try to type the first or the first two words of the menu command in the dialog insert menu command and after than press [search]. Perhaps this helps.

Silly-V
Legend
September 12, 2016

It's just here:

[JS] CS6+ executeMenuCommand

But, that list is gotten from the .kys keyboard shortcut file of Adobe Illustrator.