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
... View more