[Framers] create custom keyboard shortcut - for ES script ?

Monique Semp monique.semp at earthlink.net
Tue Jun 21 09:17:02 PDT 2016


> Theoretically an ExtendScript can define it's own keyboard shortcuts - but this mechanism does not work at all (see end of line 04 hereafter)
01 // --- Menu definition for documents
02 var menuLocation = app.GetNamedMenu("FormatMenu");
03 var FMcalcMenu  = menuLocation.DefineAndAddMenu("!FMcalcMain", oMenus.MenuMain);
04 FMcalcMenu.DefineAndAddCommand(1,"docFMcalcDocu", oMenus.MenuDocu, "\!qd");

Hi Klaus,

It turned out that the script I’m working with *does* define its own shortcut, in a local setUpMenus() function that is called before the script’s main() function. Among other things, the setUpMenus() function includes the following code to add the script to FrameMaker’s File > Import submenu:

01    var cmd = DefineCommand(1, “<script-name>”, “<menu-text>”, “<shortcut>”);
02    var importMenu = app.GetNamedMenu(“ImportMenu”);
03    var bookImportMenu = app.GetNamedMenu(“BookImportMenu”);
04    importMenu.AddCommandToMenu(cmd);
05    bookImportMenu.AddCommandToMenu(cmd);
06    UpdateMenus();

Initially there was nothing in the <shortcut> argument (just empty quotes), so I was able to add the keyboard shortcut that I wanted, and everything works.

That said, there is an oddity that you allude to in your customisation doc: you can use any two of the Ctrl, Alt, Shift modifiers, but not all three. I often use all three to make sure that my custom keyboard shortcuts (no matter which app I’m working with) don’t interfere with standard shortcuts. But I couldn’t make it work. Your doc says, "A key group should not use more than two modifier keys, because humans have only two hands …". Yes, but... :-). So I’m assuming that this is actually a limitation imposed by FrameMaker, not just your advice and voice of experience?

This did the trick for what I need, so I’m sure I’ll put this aside for the time being. But I certainly do want to figure out how to get a keyboard shortcut working for plugins that are provided via DLL, which of course I cannot edit like I can an ExtendScript that’s provided as source code. So sometime in the future, I’ll be checking out the scripts that Winifried Reng pointed us to, http://4xscripts.com/scripts/free-scripts.html (and putting the text through Google Translate).

Thanks for all the details; I’m looking forward to figuring it out!
-Monique


More information about the Framers mailing list