7 Replies Latest reply on Mar 15, 2018 5:24 PM by Kukurykus

    Image or artboards scrolling in CC2015 ??

    Pedro Cortez Marques Level 3

      I have not upgrade to CC2015 yet. And it seams, I won't considering the many bugs around.

      Well, to be honest, I tried installing it on a PC windows7 SP1 and it just won't start at all not even generating any log files to send to adobe.

       

      But the issue I want to ask is if there are any news on photoshop CC2015 regarding:

       

      1. image scrolling script control?

      2. mouse position listener?

        • 1. Re: Image or artboards scrolling in CC2015 ??
          DBarranca Level 4

          Hi Pedro,

          yes image scrolling is there

          The feature request has been accepted and implemented, thanks to Mr. Thomas Ruark! :-)

          (a bit of excitement after such a long wait is acceptable)

           

          See this example:

           

          var currentZoom, down, gDebug, gString, getZoom, h, l, left, res, right, s2t, setZoomScroll, t, up, w, win;
          
          s2t = function(s) {
            return app.stringIDToTypeID(s);
          };
          
          gDebug = 0;
          gString = "";
          
          $.w = function(str) {
            if (gDebug === 0) {
          
            } else {
              return gString += "" + str + "\n";
            }
          };
          
          /*
          * Retrieve the Zoom %
          * @return {Number} Zoom value (%)
          */
          getZoom = function() {
            var ref;
            ref = new ActionReference();
            ref.putProperty(s2t("property"), s2t("zoom"));
            ref.putEnumerated(s2t("document"), s2t("ordinal"), s2t("targetEnum"));
            return executeActionGet(ref).getUnitDoubleValue(s2t("zoom")) * 100;
          };
          
          /*
          * Set Zoom and Scroll
          * @param {Number} zoom    0..100
          * @param {Number} hScroll In Pixels I think
          * @param {Number} vScroll In Pixels I think
          */
          setZoomScroll = function(zoom, hScroll, vScroll) {
            var desc, ref, toDesc;
            zoom = zoom / 100;
            desc = new ActionDescriptor;
            toDesc = new ActionDescriptor;
            ref = new ActionReference;
            ref.putProperty(s2t('property'), s2t('zoom'));
            ref.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
            desc.putReference(s2t('target'), ref);
            toDesc.putUnitDouble(s2t('zoom'), s2t('percentUnit'), zoom);
            if (hScroll) {
              toDesc.putUnitDouble(s2t('horizontal'), s2t('pixelsUnit'), hScroll * zoom);
            }
            if (vScroll) {
              toDesc.putUnitDouble(s2t('vertical'), s2t('pixelsUnit'), vScroll * zoom);
            }
            desc.putObject(s2t('to'), s2t('zoom'), toDesc);
            executeAction(s2t('set'), desc, DialogModes.NO);
            app.refresh();
          };
          
          res = "dialog { preferredSize: [200,200], orientation: 'column', zoomGroup: Group { orientation: 'row', zoomIn:  Button { text: '+'}, zoomOut: Button { text: '-'}, zoomFit: Button { text: '='} }, spacer: Panel { preferredSize: [100,0] }, panGroup: Group { orientation: 'stack', preferredSize: [180,100], sLeft  : Button { alignment: ['left',  'middle'], text: '←'}, sUp    : Button { alignment: ['center', 'top'],    text: '↑'}, sRight : Button { alignment: ['right',  'middle'], text: '→'}, sDown  : Button { alignment: ['center', 'bottom'], text: '↓'} } }";
          win = new Window(res);
          left = win.panGroup.sLeft;
          right = win.panGroup.sRight;
          up = win.panGroup.sUp;
          down = win.panGroup.sDown;
          app.preferences.rulerUnits = Units.PIXELS;
          currentZoom = getZoom();
          w = app.activeDocument.width.value;
          h = app.activeDocument.height.value;
          l = w / 2;
          t = h / 2;
          
          right.onClick = (function(_this) {
            return function() {
              $.w("l was: " + l);
              l += w / 10;
              $.w("l is: " + l);
              if (l > w) {
                l = w;
                $.w("l is bigger than w (" + w + "): now l is: " + l);
              }
              if (l < 0) {
                $.w("l is less than 0 so now it's set to 0");
                l = 0;
              }
              return setZoomScroll(currentZoom, l, t);
            };
          })(this);
          
          left.onClick = (function(_this) {
            return function() {
              $.w("l was: " + l);
              l -= w / 10;
              $.w("l is: " + l);
              if (l > w) {
                l = w;
                $.w("l is bigger than w (" + w + "): now l is: " + l);
              }
              if (l < 0) {
                $.w("l is less than 0 so now it's set to 0");
                l = 0;
              }
              return setZoomScroll(currentZoom, l, t);
            };
          })(this);
          
          down.onClick = (function(_this) {
            return function() {
              $.w("t was: " + t);
              t += h / 10;
              $.w("t is: " + t);
              if (t > h) {
                t = h;
                $.w("t is bigger than h (" + h + "): now t is: " + t);
              }
              if (t < 0) {
                $.w("t is less than 0 so now it's set to 0");
                t = 0;
              }
              return setZoomScroll(currentZoom, l, t);
            };
          })(this);
          
          
          up.onClick = (function(_this) {
            return function() {
              $.w("t was: " + t);
              t -= h / 10;
              $.w("t is: " + t);
              if (t > h) {
                t = h;
                $.w("t is bigger than h (" + h + "): now t is: " + t);
              }
              if (t < 0) {
                $.w("t is less than 0 so now it's set to 0");
                t = 0;
              }
              return setZoomScroll(currentZoom, l, t);
            };
          })(this);
          
          
          win.show();
          
          win.onClose = function() {
            return $.writeln(gString);
          };
          
          
          
          

           

          I did write this some time ago and I don't actually recall all the details (also, it was originally written in coffeescript, this is the why the JS is kind of fancy) but it is for sure a good start.

           

          I don't know anything regarding the mouse position listener, but if you're into HTML Panel there's this interesting Node module: octalmage/robotjs · GitHub which description says:

           

          Node.js Desktop Automation. Control the mouse, keyboard, and read the screen.

           

          Promising, isn't it?! :-)

           

          Best regards,

           

          Davide Barranca

          ---

          www.davidebarranca.com

          www.cs-extensions.com

          • 2. Re: Image or artboards scrolling in CC2015 ??
            Pedro Cortez Marques Level 3

            Thanks!

            Thanks Adobe. Better late than never.

            "One step to a client, a big step to the man-kind" :-)

             

            I leave you with this great article regarding Adobe efforts to listen to the clients. Very promising!

            It is writen by Charles Pearson a Cultural Anthropologist

             

            Article worth reading: "My Two Years as an Anthropologist on the Photoshop Team"

            https://medium.com/@Mediauras/my-two-years-as-an-anthropologist-on-the-photoshop-team-e700 acb7d3d5

            • 3. Re: Image or artboards scrolling in CC2015 ??
              c.pfaffenbichler Level 9

              I have a hard time grasping the code, so I’d like to ask:

              Is there a way to assess the position of the image within the window and the window dimensions?

              • 4. Re: Image or artboards scrolling in CC2015 ??
                DBarranca Level 4

                Hi Christoph,

                to the best of my recollection I've been implementing and add stuff to this code originally provided by Adobe / Zetta (which is surely more readable).

                 

                zoomPanView(300,0,0)
                
                ///////////////////////////////////////////////////////////////////////////////
                // Function: zoomPanView
                // Usage:  will  modify zoom and  pan of image inside photoshop viewport .
                // Input:  ZoomPercent = Zoom percentage factor,  HpixToRight - distance from left to center view on,  VpixDown - distance from the top to center view on.
                // Return: updated viewport display.
                ///////////////////////////////////////////////////////////////////////////////
                function zoomPanView(ZoomPercent, HpixToRight,VpixDown)
                {
                    // make sure all calcualtions are done in pixels.
                      var ru= app.preferences.rulerUnits;
                    app.preferences.rulerUnits = Units.PIXELS;
                
                    const classProperty                = app.charIDToTypeID('Prpr');
                    const kzoomStr                    = app.stringIDToTypeID("zoom");
                    const classDocument                = app.charIDToTypeID('Dcmn');
                    const typeOrdinal                  = app.charIDToTypeID('Ordn');
                    const enumTarget                  = app.charIDToTypeID('Trgt');
                    const typeTarget                    = app.stringIDToTypeID('target');
                    const keyTo                        = app.charIDToTypeID('T  ');
                    const eventSet                    = app.charIDToTypeID('setd');
                    const enumZoom                    = app.charIDToTypeID('Zm  ');
                    const unitPercent                  = app.charIDToTypeID('#Prc');
                    const keyHorizontal                = app.charIDToTypeID('Hrzn');
                    const keyVertical                  = app.charIDToTypeID('Vrtc');
                
                    var desc = new ActionDescriptor();
                    var ref = new ActionReference();
                    ref.putProperty( classProperty, kzoomStr );
                    ref.putEnumerated( classDocument, typeOrdinal, enumTarget );
                    desc.putReference( typeTarget, ref );
                    var toDesc = new ActionDescriptor();
                    // convert zoom percent to zoom level.
                    var ZoomLevel = ZoomPercent/100;
                    toDesc.putUnitDouble(enumZoom, unitPercent, ZoomLevel);   
                    // horizontal panning
                    toDesc.putUnitDouble(keyHorizontal, unitPercent, (HpixToRight/2)* ZoomLevel); 
                    // vertical panning
                    toDesc.putUnitDouble(keyVertical, unitPercent, (VpixDown/2)* ZoomLevel);
                    desc.putObject( keyTo, kzoomStr, toDesc );
                    executeAction( eventSet, desc, DialogModes.NO );   
                  app.refresh();
                
                  // reset to whatever settings user had when done.
                    app.preferences.rulerUnits = ru;
                }
                

                 

                - Davide

                • 5. Re: Image or artboards scrolling in CC2015 ??
                  c.pfaffenbichler Level 9

                  Thanks!

                  I’ll have to give that a thorough look-see …

                  • 6. Re: Image or artboards scrolling in CC2015 ??
                    c.pfaffenbichler Level 9

                    I cannot discern any way to determine the image’s current position in the window or the window dimension and window position itself.

                    So I can’t figure out how to scroll by the window’s width or height for example or to recreate a certain magnification and image section which might have been useful to recreate "sessions" of opened images.

                     

                    Edit: No that anyone claimed this is possible …

                    • 7. Re: Image or artboards scrolling in CC2015 ??
                      Kukurykus Adobe Community Professional

                      First script doesn't work in Photoshop 19.1.2. It actually display Dialog with arrows, minus, plus and equals sign, but clicking them don't affect document (with layer/background, (un)tabbed, zoomed out/in). Can someone make it works? Thanks!

                       

                      Ps. in the second code you only have to add one space more so where error occurs ('T  ' to 'T   ')