Skip to main content
dublove
Legend
April 27, 2026
Question

Is it possible to set a shortcut key by reading the script name?

  • April 27, 2026
  • 2 replies
  • 33 views

I often change my script names, which causes the shortcut keys to stop working.
However, the part of the script name that contains the shortcut key is fixed, for example:
001-get Actual image width【Ctrl+Alt+O】.jsx
【Ctrl+Alt+O】 represents the suggested shortcut key, and this part generally doesn’t change.

Is it possible to ignore this part and modify the shortcut file (e.g., myShortCut.indk) to generate code like the following:

    <shortcut>
        <action-id value="0xff000000 + 11" name="Script:Application:C Common.lnk:001-get Actual image width【Ctrl+Alt+O】.jsx"></action-id>
        <context>DefaultContext</context>
        <string>Ctrl+Alt+O</string>
    </shortcut>

It seems the shortcut stops working because it gets automatically cleaned up.

    2 replies

    dublove
    dubloveAuthor
    Legend
    April 27, 2026

    I want to scan my script directory. If there are files with the extension `.jsx` inside the ‘【 】’ , I will use the ‘【 】’ shortcut key to set up the `.indk` file.

    Community Expert
    April 27, 2026

    I’ve given you the best option in my opinion. Scanning the files and setting up the ldlk file is risky.

    What’s wrong with ‘shell script’ to point to the script? It’s the best option I’ve found and the idlk route didn’t work for me. 

     

    If you find a way I’d love to now. Other than that there’s not much else I know. Except the KBSC is not accessible via scripting as far as I can tell. 

     

    dublove
    dubloveAuthor
    Legend
    April 27, 2026
    value="0xff000000 + 11"

    Is there a specific basis for setting this value? Which shortcut key does the number refer to?

    Community Expert
    April 27, 2026

    I’ve looked into this before 

    You can edit the .indk file because it is plain text, but I would not present that as a reliable solution.

    The real issue is that InDesign does not seem to bind script shortcuts by a partial filename rule like “match the text inside ``”. It binds them to the specific script action that InDesign has registered. When you rename the script, InDesign may see it as a different action, and the old shortcut entry can be removed or cleaned up. So I don’t think it is possible to make InDesign simply “ignore” the changing part of the script name.

    As far as scripting goes, I’m not aware of any public InDesign scripting API that can directly assign a keyboard shortcut to a script. You can apply a shortcut set by script, and you can experiment with editing the .indk file, but that is really a workaround, not a supported mechanism.

    So the short answer is maybe hackable, but not dependable.

    ***

    The safest approach is usually to keep the filename of any shortcut-driven script stable. If you want to rename things freely, a better pattern is to keep a fixed wrapper script with the shortcut assigned to it, and let that wrapper call the script you actually want to run. That avoids the shortcut breaking every time the visible script name changes.

    That way you change the filename from 001-get Actual image width - to 002-…. 

    And the Wrapper Script has the shortcut, so it finds the script with the filename as a close match name to the script. 

    So your files would look like 
    Wrapper - actual image width  
    Ctrl+Alt+O
    then that finds the script with the slightly altered name 

    Finds - 002- actual image width getter

    or something like that
     

    ****

    A helper script that scans filenames for something like `` and rewrites the .indk file is possible in principle, but I would describe it as fragile rather than robust.