If what you're asking is whether it's possible to assign a keyboard
shortcut in the regular way to a menu item created by a script, then
sure, of course you can.
Add the menu item, and then assign whatever k.shortcut you want --
you'll find your menu items under the "Scripts" category in the keyboard
Thank you very much, Ariel!
It's so-o-o obvious! How could I miss it? For sure, I grow old and become senile.
I'm sorry for the late reply: I've been too busy and just got back to scripting.
Thank you again.
Now I encountered another problem: I can assign shortcuts to custom menu items but InDesign doesn't keep them after restart so every time I start up/restart Indy, I have to assign them again.
I checked out the indk-file located in the "InDesign Shortcut Sets" folder and the assigned shortcuts are there -- even after restart:
However, it isn't used when the menu is loaded on start up.
You need to set up indesign that it loads the correct shortcut set.
I think you should be able to do this through the UI when all the documents are closed and then close indesign when all the documents are close.
Then next time it opens it should be ok.
Thank you for your reply, Trevor.
The correct set (my custom) is always loaded. I checked it. But the shortcuts assigned to the menu items created by script disappear after restart.
I made the same menu with APID ToolKit and the shortcuts assigned to this menu are in place after restart. I'm going to generate a small plug-in and use it instead of the regular start up script for creating menu. If it works, I'll post the code.
Did you tried putting your script in to the startup folder, so that the menu items are created on startup and available?
If you already tried this and still facing the issue. Then the problem may be the shortcut set is loaded before the menu item is created.
Yes, the script was in the startup folder. As far as I know, that's the only way to use custom menus.
Thanks, Obi-wan Kenobi.
It's an interesting article, but it doesn't solve this particular problem.
Why not write a little script that would create keyboard shortcuts and the user manually launch after starting Indy?
As when we start a car: first one goes in, then the engine is started! without this start, the car will not go far !!!!
Unfortunately It's impossible to do this by script.
@Kayan – I see the same problems with keyboard shortcuts sets. After a restart of InDesign the assigned KBSC of a menu generated by a startup script is removed.
I found no solution to that. Just a hint how we can edit the indk file, but this will not help at all:
Make a new KBSC set. Assign a keyboard shortcut to your startup script.
Go to preferences and open the new indk file in a text editor. Find the menu name for your menu action and look at the code:
(I did this with a startup script by Gerald Singelmann)
Assign a keyboard shortcut in the UI.
The code for the KBSC is defined in XML notation like that:
<shortcut> <action-id value="0xff002000 + 1" name="KBSCE Scripts menu:.Group Remembers Layers"></action-id> <context>DefaultContext</context> <string>Ctrl+Cmd+G</string> </shortcut>
As long as the session persists this is working.
But the next time InDesign will be restarted the the value of action-id will be changed and the KBSC cannot be found in the GUI.
I've solved the problem by creating the menu with Rorohiko's APID ToolKit. Now keyboard shortcuts assigned to menu items (In the "Active Page Item" product area) don't disappear after restart. The APID menu looks almost the same way as the one created with InDesign's "built-in" scripting. The only difference: no separator between menu items. (Maybe I haven't found how to do this yet.)
I'll try to post the code in the next post. At the moment, when I'm answering to your post, I can't find the "Use Advanced Editor" link. A while ago all controls on the forum without (or, to be more precise against) my will became Russian and that's unbearable to me.
It turns out to get to the advanced editor I have to post the message and then edit it. What a user friendly forum software! Argh!
Here's the code:
Here are the events listened by the plug-in: enableMenus, menu*, docLoaded
In the APID menu I use evenCode instead of menu title/name (in a regular menu).
To get a separator menu item, use the '-' character, I think.
The screenshot I posted was mainly for sorting out the advanced editor, I gather you got that fixed.
Yes, it works now. Thanks, Trevor.