Skip to main content
DBarranca
Legend
August 30, 2012
Question

Image scrolling

  • August 30, 2012
  • 1 reply
  • 1186 views

Hi,

I've a modal ScriptUI dialog with buttons that zoom in and zoom out using this kind of code:

var s2t= function (s) { return app.stringIDToTypeID(s) }

var zoomIn= function() {

  var d, r;

  d = new ActionDescriptor();

  r = new ActionReference();

  r.putEnumerated(s2t('menuItemClass'), s2t('menuItemType'), s2t('zoomIn'));

  d.putReference(s2t('target'), r);

  executeAction(s2t('select'), d, DialogModes.NO);

  return app.refresh();

};

Now, my problem is that I can't pan the image - the window is modal. Is there a way to implement such a control via script (scroll-left, scroll-right, etc)?

Thanks in advance,

Davide

This topic has been closed for replies.

1 reply

DBarranca
DBarrancaAuthor
Legend
March 30, 2015

I bump my own topic after 2 years - has anybody found a way to center the image's view on PS CC2014?

Thank you!

Davide Barranca

---

www.davidebarranca.com

www.cs-extensions.com

Pedro Cortez Marques
Legend
April 8, 2015

Hi David

I have manage to have results only on windows7 regarding the LEFT<>RIGHT scroll (with some limitations)

I imagine there is also on OSX some kind of key behavior to do the same

Hope it helps.

// tested vbscript below on windows7

// fit on Screen center

app.runMenuItem(app.stringIDToTypeID ("fitOnScreen"));

// after read the % of zoom when is fitOnScreen it assumes this is your 100%, and now you can set the new zoom

setZoomLevel( getZoomLevel(), 152); // for example 112 will be 112% (if related to 100% = fitToScreen)

// how to drag image over scrool

// with some limitations, I have tested successfully to use vbscript on PC Windows7

var vbsTemp = File(Folder.temp +"/vbsTemp.vbs"); // creates a bat file at temp folder

vbsTemp.open("w")

vbsTemp.writeln('Dim appRef, WshShell');

vbsTemp.writeln('Set appRef = CreateObject("Photoshop.Application")');

vbsTemp.writeln('appRef.bringToFront');

vbsTemp.writeln('appRef.visible = true');

vbsTemp.writeln('Set WshShell = WScript.CreateObject("WScript.Shell")');

vbsTemp.writeln('WScript.Sleep 400');

// choose one or more of this ( For SHIFT prefix with +  ||  For CTRL  prefix with ^  ||  For ALT   prefix with % )

//~ vbsTemp.writeln('WshShell.SendKeys("{HOME}")'); // inside image TOP CENTER

//~ vbsTemp.writeln('WshShell.SendKeys("{END}")'); // inside image BOTTOM CENTER

//~ vbsTemp.writeln('WshShell.SendKeys("{PGDN}")'); // BOTTOM direction [until out-bound limit] (major steps) the total of keys needed depends on the amount of hidden image (zoom related)

//~ vbsTemp.writeln('WshShell.SendKeys("{PGUP}")'); // TOP direction [until out-bound limit] (major steps) total of keys needed depends on the amount of hidden image (zoom related)

//~ vbsTemp.writeln('WshShell.SendKeys("^{PGUP}")'); // activates the scrool drag right (major steps) =  CTRL+{PGUP}

//~ vbsTemp.writeln('WshShell.SendKeys("^{PGDN}")'); // activates the scrool drag left  (major steps) = CTRL+{PGDN}

vbsTemp.writeln('WshShell.SendKeys("^+{PGUP 32}")'); // minor steps scrool drag right {PGUP [number of minor steps to drag]} =  CTRL+Shift+{PGUP}  x N times

//~ vbsTemp.writeln('WshShell.SendKeys("^+{PGDN 32}")'); // minor steps scrool drag left {PGDN [number of minor steps to drag]} =  CTRL+Shift+{PGDN}  x N times

vbsTemp.close();

vbsTemp.execute();

function getZoomLevel(){

var ref = new ActionReference();

ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

var desc = executeActionGet(ref);

return Number(desc.getDouble(stringIDToTypeID('zoom'))*100).toFixed(1);

};

function setZoomLevel( getZoomLevelValue , percent ) {

    zoom = getZoomLevelValue * (percent/100);

    if(zoom < 1 ) zoom =1;

   var ref = new ActionReference();

   ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

   var getScrRes = executeActionGet(ref).getObjectValue(stringIDToTypeID('unitsPrefs')).getUnitDoubleValue(stringIDToTypeID('newDocPresetScreenResolution'))/72;

   var docRes = activeDocument.resolution;

   activeDocument.resizeImage( undefined, undefined, getScrRes/(zoom/100), ResampleMethod.NONE );

   var desc = new ActionDescriptor();

   ref = null;

   ref = new ActionReference();

   ref.putEnumerated( charIDToTypeID( "Mn  " ), charIDToTypeID( "MnIt" ), charIDToTypeID( 'PrnS' ) );

   desc.putReference( charIDToTypeID( "null" ), ref );

   executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );

   activeDocument.resizeImage( undefined, undefined, docRes, ResampleMethod.NONE );

}