13 Replies Latest reply on Jan 20, 2016 1:45 AM by tssee@imgof.com

    script to zoom e pan view

    Level 1

      my problem is this:

      when I opened a panel script can not do zoom in zoom out

      where can I get something like

       

      Schermata 2016-01-11 alle 12.38.49 copia.png

        • 1. Re: script to zoom e pan view
          JJMack Most Valuable Participant

          Why would you want a script with a dialog like that? They are available via menu View.  All have shortcut keys.  You could add an extension panel like that which would allow to to use Photoshop while the panel is being displayed.  However a Script with a dialog like would only let you do those things till you use the exit button to terminate the script. You can not do any other operation in Photoshop till the script terminates. When a script is running its in control of Photoshop the script would need to do the scrolling and zooming you want to do, or the script need to put you into to some interactive mode like and interactive transform operation.  I do that in my interactive collage populating script. When a plug-in or built in feature is used in a script  and the script does not bypassed its dialog  other Photoshop features like scrolling and zooming may be useable when the current operation dialog is active..

           

          I know when a scripts used and interactive Transform step that Photoshop scrolling and zooming is possible till the transform is committed or canceled.  What is possible is controlled by Photoshop.  What is not possible will be grayed out in Photoshop UI.

          • 2. Re: script to zoom e pan view
            pixxxel schubser MVP & Adobe Community Professional

            Hi tssee@imgof.com,

            do you looking for something like this?

            app.bringToFront();
            runMenuItem(app.charIDToTypeID("FtOn"));
            alert("fit on screen - done");
            runMenuItem(app.charIDToTypeID("ZmIn"));
            alert("zoom in - done");
            runMenuItem(app.charIDToTypeID("ZmOt"));
            alert("zoom out - done");
            

             

            Have fun

             

            • 3. Re: script to zoom e pan view
              Level 1

              The problem and this

              if I open another panel type this and I want to enlarge the image or rideurre there any way to do it

              This below an example.

               

              Schermata 2016-01-12 alle 10.08.14.png

               

              I want to know how to do zoom in or zoom out with opacity window open?

              • 4. Re: script to zoom e pan view
                JJMack Most Valuable Participant

                As I wrote the script is in control. When the Dialog you show is being displayed by the script. The script is waiting on your interaction with the dialog. Photoshop has given control to it script processor and your script is waiting for your interaction with the dialog.  You would need to add additional buttons to the dialog for the display functions you want: Fit on display, zoom in, zoom out, view actual pixels.  The script code to perform these operations has been posted for you and the layeropacity script has been posted for you.  You need to add in the zoom code and add buttons into the dialog for the display options to the layeropacity script.

                 

                The Dialog will also need to be changed to be able to handle a document with many layers. For the dialog will not fit on screen the way it is currently coded whem a document has more then a few layers..

                Capture.jpg

                Capture.jpg

                • 5. Re: script to zoom e pan view
                  Level 1

                  JJ Mack Just what I was looking for

                  unfortunately como I said earlier I'm just starting scripting and I did not quite clear whether embarking on this hobby

                  I am on this forum to learn but I find it difficult to communicate because they do not speak English

                  I thank all of you for the great help

                  I would be very grateful if you can get the code for the buttons that you entered in the panel opacity.

                  Thanks again to all and excuse my lack of experience.

                  • 6. Re: script to zoom e pan view
                    JJMack Most Valuable Participant

                    If  you want to learn or hack like I do I'll give you a start. The Panel and one button.  You add the code before the OK and Cancel panel. You need to add the other three buttons on your own.

                     

                      //////////////////////////////

                      // build Display Function buttons

                      dlg.displayFunc = dlg.add('panel', [12,495,308,550], "");

                     

                      dlg.displayFunc.fitBtn = dlg.displayFunc.add('button', [10,10,72,40], 'Fit On', {name:'fiton'});

                      dlg.displayFunc.fitBtn.onClick = function () {

                             runMenuItem(app.charIDToTypeID("FtOn"));  

                      }

                    • 7. Re: script to zoom e pan view
                      Level 1

                      Thanks thanks thanks

                      you are a generous person

                      now I know what to do

                      without your code I would have never succeeded.

                      • 8. Re: script to zoom e pan view
                        JJMack Most Valuable Participant

                        We are here to help users wanting to learn.  Good show....

                        • 9. Re: script to zoom e pan view
                          Level 1

                          JJMack

                          I know I'm asking a lot but your help are helping me a lot.

                          Let me know if you can put  button  hand

                          'cause when I enlarge the zoom to 100% have problems when moving the image.

                          • 10. Re: script to zoom e pan view
                            JJMack Most Valuable Participant

                            I can not think of a easy way off hand to program in a function to provide be an interactive pan when the image is scaled larger the one display.

                             

                            Panning (the hand tool and scroll bars) are manual tool there are no shortcut controls to nudge the pan in any direction.  Its a grab and drag operation or click operation nothing is recorded for that type of operation. Photoshop need to be in control.

                             

                            Puting Photoshop into and interactive transform you could pan the document but you could also move a layer location over the canvas. So you may be able add a button function to add a temp layer with a pixel two and put the script into an interactive transform. Holding the space bar would enable hand tool  panning. Hitting the enter key would commit the transform and pan and then the function remove  the temp layer it added. ESC could also be used to cancel any transform done and panning would not be canceled

                            • 11. Re: script to zoom e pan view
                              Level 1

                              Always kind now I try and see if I can

                              thank you

                              • 12. Re: script to zoom e pan view
                                JJMack Most Valuable Participant

                                I did a quick test in the button functuof for zoom to actual I added three lines to alow panning using the space bar hand tool shortcut during an interactive  free transform.

                                 

                                I did not add a temp layer to make sure there was an active layer targeted and a the delete of that temp layer.

                                 

                                As long as there is a layer targeted and the  interactive free transform is canceled with ESC the panning will work and no layer will be moved.

                                 

                                I add the try, catch and refresh

                                 

                                dlg.displayFunc.actualBtn = dlg.displayFunc.add('button', [77,10,140,40], 'Actual Px', {name:'actualpx'});

                                  dlg.displayFunc.actualBtn.onClick = function () {

                                  runMenuItem(app.charIDToTypeID("ActP"));

                                  try { runMenuItem(app.charIDToTypeID("FrTr")); }

                                  catch (e) {}

                                  app.refresh();

                                  }

                                • 13. Re: script to zoom e pan view
                                  Level 1

                                  This morning I got up and I found this great gift

                                  it works perfectly

                                  personally I would never be able to do this

                                  JJMack thank you very much