4 Replies Latest reply on Aug 22, 2014 12:32 PM by pixxxel schubser

    Adjust tracking (character spacing) of selected text

    kevinljohnston

      I am looking for a script that will allow me to apply a specific tracking value to selected text in InDesign. I'm not even an amateur in scripting.

       

      I found the following script in the referenced article: Script:  Adjust tracking (character spacing) of text

       

      /*

      <javascriptresource>

      <name>Character Tracking...</name>

      <enableinfo>true</enableinfo>

      <menu>automate</menu>

      <about>Adjust the kerning.</about>

      <category>Typography</category>

      </javascriptresource>

      */

       

      if (app.documents.length > 0) {

          var targettext = app.activeDocument.activeLayer.textItem;

          targettext.tracking = parseInt(prompt("Select the tracking value", 0));

      }

       

      This looks like it's approximately what I would like to do. Two problems, I think it is just designed for Photoshop(?), and secondly, I want to use it for only selected text, not the entire page. Also,I would like to apply the script to a keyboard shortcut (I assume that's possible).

       

      Can anyone assist in this? Sorry to ask, but I've got a large two-column document with large amounts of tracking to do and looking for shortcuts for clicking or typing in the tracking drop-down box.


      Many thanks!

        • 1. Re: Adjust tracking (character spacing) of selected text
          pixxxel schubser Level 5

          For InDesign?

           

          Why you need a script? This is always built in and works with selected text!

          InDesign Help | Default keyboard shortcuts

           

          Have fun

           

          • 2. Re: Adjust tracking (character spacing) of selected text
            [Jongware] Most Valuable Participant

            Your sample does indeed not look like it's using InDesign's version of the DOM (Document Object Model). Fortunately, if you already selected some text, it's dead easy:

             

            app.selection[0].tracking = 100;
            

             

            where you can set the "100" to any value that is valid for tracking. For added nicenessness, if you really have to set this value a lot, assign a hotkey to this script: open the Keyboard Shortcut Editor, scroll down to Scripts, and select yours, then set some key combo.

             

            See Adobe InDesign CS5.5 (7.5) Object Model JS: Text for tracking, and a lot more properties you can immediately assign.

            • 3. Re: Adjust tracking (character spacing) of selected text
              kevinljohnston Level 1

              Thanks to both Plxxxel and Jongware!

               

              Both of your answers were helpful - I have combined use of both.

               

              Plxxxel - I was aware there was a shortcut (Alt+Left Arrow, Alt+Right Arrow) for incrementing tracking by the amount set in Edit, Preferences, Units & Increments, Kerning & Tracking.  What I didn't realize was that Ctrl+Alt+Right Arrow, Ctrl+Alt+Left Arrow increments/decrements that setting by 5 times. So, for my usage, I have set Tracking at 1.  Then I use the Crtl+Alt arrow combinations for rougher (5 incr.) spacing and Alt arrow combinations for fine (1 incr.) tuning. That actually is the practical solution for me.

               

              Jongware - Thanks for your scripting solution! Your answer was correct according to what I asked in my original question.

              I found it can be more useful if I adapt it to increment additional tracking amounts:

               

                   /*

                   <javascriptresource>

                   <name>Character Tracking. Increase</name>

                   <enableinfo>true</enableinfo>

                   <menu>automate</menu>

                   <about>Adjust the kerning.</about>

                   <category>Typography</category>

                   </javascriptresource>

                   */

                   app.selection[0].tracking = app.selection[0].tracking + 10;

               

                   [Similar script for Character Tracking.Decrease.]

               

              So assigning these scripts to keyboard shortcuts like Alt+1, Q, I have:

               

                   Alt +  arrow = increment by 1

                   Ctrl+Alt + arrow = increment by 5

                   Alt 1/Q = increment by 10

               

              Actually, my needs are sufficiently met by just using the built-in Alt and Ctrl+Alt arrow combinations, but thought I would document the simple script alternative in case anyone could make use of it.

               

              I think I have graduated to becoming an amateur.

               

              Thanks again to both of you for your help!

              • 4. Re: Adjust tracking (character spacing) of selected text
                pixxxel schubser Level 5

                Hi kevinljohnston,

                glad to help you.

                 

                And I'm with you. Using both answers is a good practice.

                Have fun

                 

                 

                @all admins, why isn't there no possibility to mark any answers as helpful. IMHO it is always a hard decision to say which answer is really correct. That was much better before the Jive update!