4 Replies Latest reply on Jul 14, 2011 9:00 AM by John Hawkinson

    Scripting Styles keyboard shortcuts

    Kevin Atkins



      I'm creating an Applescript for Indd 5.5 that will create a number of documents and add them to a book file. I'm trying to flesh out all the book's documents with as many text and object styles as I can, and ensure each document has only the swatches etc. needed for the book.


      I've managed to create text styles and groups (folders) quite easily, but I can't find a way of assigning a keyboard shortcut to a style. Typically, I will be using shortcuts on the numeric keypad, and using the command key (Mac) – Command+Num 8, for example. I've searched the web, but can't find anything that shows how to do it – only how to assign global shortcut sets for InDesign.


      Can anyone point me in the right direction?




        • 1. Re: Scripting Styles keyboard shortcuts
          John Hawkinson Level 5

          So, this is the second time this week I am going to propose a solution I've never used to solve a problem.

          This is kind of a dangerous habit.


          It appears that this is an omission from the scripting DOM, and there is no direct way to do this with scripting.


          You can do it with IDML/snippets, though.  Construct a paragraph style in IDML XML and save it as a snippet:

            KeyboardShortcut="16 103"


          making sure to set the KeyboardShortcut attribute appropriately. Then place the snippet. Then you can modify the attributes of the style in the scripting DOM.


          Let me know if this actually works...

          1 person found this helpful
          • 2. Re: Scripting Styles keyboard shortcuts
            Kevin Atkins Level 1

            Thanks John.


            I'll try that out ASAP.



            • 3. Re: Scripting Styles keyboard shortcuts
              Kevin Atkins Level 1

              Ok, I've tried it out and it does work.


              However, the easiest way for me to create the IDML is to make a dummy .indd with the styles and shortcuts, create a frame with refs to each style that has a shortcut, then import via AppleScript – which sort of negates the ease of putting the shortcuts into the AppleScript code. It does mean that I wouldn't need to format the style within the script, but I'd be reliant on an external file to get the shortcuts, and (as I'm no XML expert), a 'master' .indd with the styles already setup in it.


              Still, it's a definite solution, and I may use this method once I've polished off other areas. Of course, it also depends on whether our Production Dept. will even use the shortcuts I assign!


              Thanks again John: most helpful.



              • 4. Re: Scripting Styles keyboard shortcuts
                John Hawkinson Level 5

                Well, I was proposing a slightly different strategy.

                Export one style from the INDD to IDMS, and then delete

                all the extra crap that is not the style definition. That

                leaves you with about 20 lines of XML.


                Then, write your AppleScript to create a 20-line XML file

                containing those literal 20 lines, while adjusting the name

                and shortcut of the style.


                Then your Applescript can place the IDMS snippet file after it

                writes it, and then delete the temporary file. You can then

                modify the attributes of that imported paragraph style

                in our script.


                That's a little bit clunky but it shouldn't keep you from putting the

                shortcuts in your applescript code. You are just dynamically

                generating IDMS/IDML/XML from your applescript.


                You mention maybe you would prefer not to format the style within

                the script? Well, then I guess you have even more options