26 Replies Latest reply: Feb 13, 2013 3:26 AM by [Jongware] RSS

    changing preset zoom increments

    Fritz Hansen

      Is it possible to change the preset zoom increments (ID CS5)? For a lot of my work, I find 225% or 250% is an optimum magnification for me. I can get it there manually by typing in my desired magnification, but it would be so much easier to just click the zoom tool (or, especially the keyboard shortcut) and get increments of 25 or 50 rather than 100.

        • 1. Re: changing preset zoom increments
          Peter Spier ACP/MVPs

          The only way to customize zoom values is through scripting ( if you search, you should be able to find Dave Saunders' script to set the zoom for an accurate 100% view, which you can modify to have any percentage of your choosing). You can then assign a keyboard shortcut to the script, but you'd need a separate script/shortcut for each percentage you choose -- the Cmd (Ctrl) +/- shortcuts to zoom in or out won't use the custom values.

          • 2. Re: changing preset zoom increments
            [Ariel] Community Member

            Peter, It should be possible to redefine those shortcut keys to run a

            script (well, 2 different scripts, I guess) which will either increase

            or decrease the the zoom to a set of predefined values.

            • 3. Re: changing preset zoom increments
              John Hawkinson Community Member

              Everybody's right!

               

              It's a one-line script to set the zoom percentage of the active window. If you want to bind them to discrete keys, i.e. Cmd-1, Cmd-2, Cmd-4, you'll need 3 or 4 different scripts, one for each percentage.

               

              But yes, you could redefine the Cmd +/- shortcuts to a slightly more complicated script that checks the current value of the zoom for the active window and then increases or decreases it according to a rule of your own choosing.

               

              It's not feasible to use these methods to change the behavior the actual zoom tool, though, only the keyboard shortcuts. Honestly, I usually just use the marquee zoom feature to drag a box around what I want. That way I get near perfect zooming every time.

              • 4. Re: changing preset zoom increments
                [Ariel] Community Member

                Here's my attempt at a script to do this:

                 

                /*

                Custom Zoom Percentages

                An InDesign CS4 script (c) Ariel Walden, FreelanceBookDesign.com, 2011

                To use: Add, remove or change the list of numbers between square

                brackets (zooms = ) to whichever zoom percentages you like.

                IMPORTANT:

                (1) Make sure your zoom percentages are in ascending order!

                (2) Make sure they are separated by a comma!

                */

                 

                try{

                     zooms = ;

                     theWindow = app.activeWindow;

                     reset = true;

                     currentZoom = theWindow.zoomPercentage;

                     for (i=0; i<zooms.length; i++){

                         if (currentZoom < zooms[i]){

                             newZoom = zooms[i];

                             reset = false;

                             break;

                         }

                     }

                     if (reset) newZoom = zooms[0];

                     theWindow.zoomPercentage = newZoom;

                }

                catch(e){}

                 

                I work on CS4, so it's tested on that. Does it work in other versions?

                 

                The script will cycle through the predefined zoom percentages, and when

                it reaches the end it will jump back to the smallest. This will save the

                need for two scripts (one to go up and one to go down) for some people.

                 

                Thanks,

                Ariel

                • 5. Re: changing preset zoom increments
                  John Hawkinson Community Member

                  Ariel: Something horrible horrible has happened to the arrays in your post. Did you use the email interface? [I hope so, because otherwise there's a very serious new bug in the new version of the forum]: All of your arrays, in brackets, turned into URLs, to which the base URL for this thread was prepended. Can you edit your post online to fix them?

                   

                  Incidently, I would suggest that instead of listing "IMPORTANT: (1) Make sure your zoom percentages are in ascending order!" that you just use:

                   

                   

                  zooms = [20,40,60,100,160,260,420,680].sort();
                  

                   

                  so that it is a non-issue.

                  • 7. Re: changing preset zoom increments
                    [Ariel] Community Member

                    (Incidentally, if anyone would like to PM me about the script -- and get

                    an answer before tomorrow(!) -- I'm only reachable on bookraft (at)

                    googlemail.com right now.)

                    • 8. Re: changing preset zoom increments
                      Peter Spier ACP/MVPs

                      Ariel, another empty post in response to John....

                       

                      I suspect it's quotes in your emails and Jive playing games.

                      • 9. Re: changing preset zoom increments
                        John Hawkinson Community Member

                        OK, I corresponded with Ariel offline, and s/he writes:

                         

                        Oh dear, sorry about the arrays. I did send this in by email, and I won't

                        have access to the web until tomorrow to fix it. If you feel like

                        reposting a corrected version meanwhile go ahead.

                         

                        I wonder if there's a way of adding tags to an email response to get the

                        forum to format something as javascript (similar to the online option)?

                         

                        Good catch about using sort()!

                         

                        Ariel

                         

                        Upon request, I repost the revised script:

                         

                        /*
                        Custom Zoom Percentages
                        An InDesign CS4 script (c) Ariel Walden, FreelanceBookDesign.com, 2011
                        To use: Add, remove or change the list of numbers between square brackets
                        (zooms = [x, y, z, etc.]) to whichever zoom percentages you like.
                        IMPORTANT: Make sure they are separated by a comma!
                        */
                          
                        try{
                            zooms = [20,40,60,100,160,260,420,680].sort();
                            theWindow = app.activeWindow;
                            reset = true;
                            currentZoom = theWindow.zoomPercentage;
                            for (i=0; i<zooms.length; i++){
                                if (currentZoom < zooms[i]){
                                    newZoom = zooms[i];
                                    reset = false;
                                    break;
                                }   
                            }   
                            if (reset) newZoom = zooms[0];
                            theWindow.zoomPercentage = newZoom;
                        }   
                        catch(e){}
                        
                        • 10. Re: changing preset zoom increments
                          Peter Spier ACP/MVPs

                          Thanks, John.

                           

                          And Ariel is a He as far as I know.

                          • 11. Re: changing preset zoom increments
                            [Ariel] Community Member

                            Thanks, John.

                             

                            Ariel, esq.

                            • 12. Re: changing preset zoom increments
                              Fritz Hansen Community Member

                              Thanks to all who responded. The scripting route seems a bit much for my needs, but I may try it. Setting the maginfication manually would be fine if my Apple wireless "super" mouse wouldn't be so sensitive and suddenly zoom way out or way in just because I happened to brush my fingers the wrong way with the option key held down.

                              • 13. Re: changing preset zoom increments
                                John Hawkinson Community Member

                                Fritz:

                                 

                                The scripting route seems a bit much for my needs, but I may try it.

                                Since Ariel took the time to actually write the script for you, I strongly encourage you to try it! All the hard work is done, you just need to install it. (Save it as customZoomPercentages.jsx as a plain text file, not RTF, in a text editor, such as Notepad or TextEdit, and follow the instructions at http://www.danrodney.com/scripts/directions-installingscripts.html. Then bind it to a key in Edit > Keyboard Shortcuts under Scripts.

                                 

                                (I know if I wrote a script for someone, I'd be kind of bummed if they didn't even try it!)

                                • 14. Re: changing preset zoom increments
                                  Fritz Hansen Community Member

                                  Just reviewing some of my posts and saw this. I completely agree with you and will indeed try it. Thanks for the polite nudge. I may even learn something about scripting. And apologies to Ariel for appearing dismissive of her efforts.

                                  • 15. Re: changing preset zoom increments
                                    Peter Spier ACP/MVPs

                                    Ariel, like former Israeli Prime Minister Ariel Sharon, is a man, for future reference.

                                    • 16. Re: changing preset zoom increments
                                      Fritz Hansen Community Member

                                      OK. Noted. My further apologies to Ariel.

                                      • 17. Re: changing preset zoom increments
                                        bttrflygrl Community Member

                                        Does this script work for Photoshop CS5 as well? I've never used scripts, but I have a need for a very specific preset zoom value or a quick shortcut to take me to an odd zoom level (38.5%) Thanks!

                                         

                                         

                                        Debbie

                                        • 18. Re: changing preset zoom increments
                                          [Jongware] MVP

                                          Debbie, there are some similarities between scripting for InDesign and for Photoshop, but only because both use the same language (Javascript). But there are vast differences in the Document Object Model -- the 'words' that you use to interrogate and command InDesign and Photoshop.

                                          The chance that this very same script, written especially for InDesign, works for Photoshop as well is extremely minimal. Even if it does, it'd be by pure chance alone, rather than by design or intention.

                                           

                                          But you could ask in the Photoshop scripting forum if there is something similar, or even if Ariël's script can be re-worked for PS.

                                          • 19. Re: changing preset zoom increments
                                            getho Community Member

                                            just stumbled on this old thread (I found the default zooms must've changed between cs5 and cs6 because I take screen shots of a layout I regularly do and they are now eiither too big or too small).  In Cs6 on windows I couldn't get the script to work - either zooming with the zoom tool or with keyboard (ctrl +/_).  the script is insale din the application folder. When I run the script it jumps the active document to 99% soom.

                                            • 20. Re: changing preset zoom increments
                                              John Hawkinson Community Member

                                              Did you try the version of the script I posted in post #9? Note that the script does not change the behavior of the zoom tool, nor of Ctrl+-/-.  You'll need to run the script (double click) it to change the zoom. Run it repeatedly to cycle through the set of zooms.

                                               

                                              Assuming that works, than you can use Edit > Keyboard Shortcuts to set a key to tun the script (and that could be Ctrl + if you like).

                                               

                                              In CS6, the standard of comparisons for zooms changed. 100% zoom now factors into account your screen's physical size, so it looks larger than it did in CS5 (substantially so).

                                              • 21. Re: changing preset zoom increments
                                                getho Community Member

                                                Hi John,

                                                sorry for delay there - christmas happened! thanks for the info re cs6 sizing - I was wondering what had changed

                                                yes just double checked its the right version.

                                                 

                                                double clicking the script in the user folder of the script panel still makes it jump to 99%, subsequent double clicks dont do anything.

                                                 

                                                I found this page: http://indesignsecrets.com/custom-zoommagnification-settings-in-indesign.php

                                                 

                                                So I tried chaging the do something bit to:  app.layoutWindows[0].zoomPercentage = newZoom;

                                                 

                                                And a few other hacks (I dont really know what I'm doing), and I stuck an alert in to report the value of newzoom.  It kept reporting 100. So I took out the  if (currentZoom < zooms[i]) test and it cycled through all the available values (but seemingly randomly) before ending at 680.  ACtually the sort is sorting them like this:

                                                 

                                                100,160,20,260,40,420,60,680

                                                 

                                                So its sorting them sort of alphabetically!  And it explains why it is zooming to 100 first.

                                                • 22. Re: changing preset zoom increments
                                                  John Hawkinson Community Member

                                                  100,160,20,260,40,420,60,680

                                                   

                                                  So its sorting them sort of alphabetically!  And it explains why it is zooming to 100 first.

                                                  How embarassing!

                                                   

                                                  Indeed, JavaScript's sort is lexicographic not numeric.

                                                  You could fix this with

                                                   

                                                  [20,40,60,100,160,260,420,680].sort(function(a,b) { return a-b; });
                                                  

                                                   

                                                  but it might not be worth the trouble...

                                                  • 23. Re: changing preset zoom increments
                                                    getho Community Member

                                                    Hi John

                                                    does this actually work for you though - because when I said it was cycling through the values it was only in an alert that I inserted, it sill wouldn't zoom at all.

                                                    • 24. Re: changing preset zoom increments
                                                      [Jongware] MVP

                                                      Just in case you changed a bit too much in Ariël's original script, here is the amended version (it appears to me it works as it's supposed to):

                                                       

                                                      /*
                                                      Custom Zoom Percentages
                                                      An InDesign CS4 script (c) Ariel Walden, FreelanceBookDesign.com, 2011
                                                      To use: Add, remove or change the list of numbers between square brackets
                                                      (zooms = [x, y, z, etc.]) to whichever zoom percentages you like.
                                                      IMPORTANT: Make sure they are separated by a comma!
                                                      */
                                                        
                                                      try{
                                                          zooms = [20,40,60,100,160,260,420,680].sort(function(a,b) { return a-b; });
                                                          theWindow = app.activeWindow;
                                                          reset = true;
                                                          currentZoom = theWindow.zoomPercentage;
                                                          for (i=0; i<zooms.length; i++){
                                                              if (currentZoom < zooms[i]){
                                                                  newZoom = zooms[i];
                                                                  reset = false;
                                                                  break;
                                                              }   
                                                          }   
                                                          if (reset) newZoom = zooms[0];
                                                          theWindow.zoomPercentage = newZoom;
                                                      }   
                                                      catch(e){}
                                                      
                                                      • 25. Re: changing preset zoom increments
                                                        getho Community Member

                                                        thanks

                                                        on cs6 it works for 4 goes, then stops!? Just tried changing the values and it now only zooms the first increment.

                                                        AH I see whats happening  - with the default values its zooming 20,40,60,99.  AS soon as it hits a non-round zoom value its crapping out.

                                                         

                                                         

                                                        ah well its frustrating but I've found this little script which is doing what I need:

                                                         

                                                        try {app.layoutWindows[0].zoom(ZoomOptions.FIT_PAGE);

                                                            app.layoutWindows[0].zoomPercentage = Number(app.activeScript.name.match(/\d+/)[0]);} catch (e) {};

                                                         

                                                        it zooms the amount in the name of the script: eg zoom65.jsx

                                                        • 26. Re: changing preset zoom increments
                                                          [Jongware] MVP

                                                          Getho, that's really strange. It works on CS4, even with 'non-round' values such as 99% and 101%. I cannot imagine it would work any different for CS6 -- but I'll try it at home tonight, where I have CS6 installed.

                                                           

                                                          getho wrote:

                                                           

                                                          .. it zooms the amount in the name of the script: eg zoom65.jsx

                                                           

                                                          Yeah, one of my brighter ideas