I ve changed the script and I can even run it horizontally
But when I go to move the horizontal slider I bring the text back
As it was at the beginning
This script changed:
// 2017, use it at your own risk;
#target photoshop
var checksOut = true;
checksOut = checkPhotoshop(checksOut);
// do the operation if everything has checked out;
if (checksOut == true) {
// set the ruler units;
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var myDocument = app.activeDocument;
var oneWidth = myDocument.width;
var theHeight = myDocument.heght;
var thisState = myDocument.activeHistoryState;
var theFirstState = myDocument.activeHistoryState;
var oneWidth = myDocument.width;
var theHeight = myDocument.height;
var dlg = new Window("dialog", "stuff", [500,300,920,500]);
// position;
dlg.scale_1 = dlg.add('panel', [15,15,405,65], 'ORZ');
dlg.scale_1.slider = dlg.scale_1.add('slider', [12,12,300,32]);
dlg.scale_1.slider.minvalue = 0;
dlg.scale_1.slider.maxvalue = oneWidth;
dlg.scale_1.slider.value = activeDocument.activeLayer.bounds[0];
dlg.scale_1.number = dlg.scale_1.add('edittext', [312,12,372,30], 0);
dlg.scale_1.number.text = activeDocument.activeLayer.bounds[0];
dlg.scale_1.slider.onChanging = function ()
{dlg.scale_1.number.text = Math.round(this.value)};
dlg.scale_1.slider.onChange = positionTheLayersORZ;
dlg.scale_1.number.onChange = function () {
while (this.text.indexOf(",") != -1) {this.text = this.text.replace(",", ".")};
while (this.text.indexOf(".") != this.text.lastIndexOf(".")) {this.text = this.text.replace(".", "")};
// checking if entry is numeric, thanks to xbytor;
if (this.text.match(/[^\-\.\d]/)) {
this.text = this.text.replace(/[^\-\.\d]/g, '');
}
if (this.text == "") {this.text = 0};
while (Number (this.text) > oneWidth) {this.text = oneWidth};
while (Number (this.text) < 0) {this.text = 0};
var theNumber = Number(dlg.scale_1.number.text);
dlg.scale_1.slider.value = theNumber;
positionTheLayersORZ()
};
dlg.scale = dlg.add('panel', [15,75,405,125], 'VRT');
dlg.scale.slider = dlg.scale.add('slider', [12,12,300,32]);
dlg.scale.slider.minvalue = 0;
dlg.scale.slider.maxvalue = theHeight;
dlg.scale.slider.value = activeDocument.activeLayer.bounds[1];
dlg.scale.number = dlg.scale.add('edittext', [312,12,372,30], 0);
dlg.scale.number.text = activeDocument.activeLayer.bounds[1];
dlg.scale.slider.onChanging = function () {dlg.scale.number.text = Math.round(this.value)};
dlg.scale.slider.onChange = positionTheLayers;
dlg.scale.number.onChange = function () {
while (this.text.indexOf(",") != -1) {this.text = this.text.replace(",", ".")};
while (this.text.indexOf(".") != this.text.lastIndexOf(".")) {this.text = this.text.replace(".", "")};
// checking if entry is numeric, thanks to xbytor;
if (this.text.match(/[^\-\.\d]/)) {
this.text = this.text.replace(/[^\-\.\d]/g, '');
}
if (this.text == "") {this.text = 0};
while (Number (this.text) > theHeight) {this.text = theHeight};
while (Number (this.text) < 0) {this.text = 0};
var theNumber = Number(dlg.scale.number.text);
dlg.scale.slider.value = theNumber;
positionTheLayers()
};
// buttons for ok and cancel;
dlg.buttons = dlg.add('panel', [15,135,405,185], '');
dlg.buttons.buildBtn = dlg.buttons.add('button', [13,12,185,34], 'OK', {name:'ok'});
dlg.buttons.cancelBtn = dlg.buttons.add('button', [195,12,370,34], 'Cancel', {name:'cancel'});
// show dialog;
dlg.center();
// show dialog;
var myReturn = dlg.show ();
////////////////////////////////////
if (myReturn == 1) {
// select the layers;
dlg.close();
//reselectLayers0 (myDocument, theLayers);
}
else {
// go back in history and select the layers;
myDocument.activeHistoryState = theFirstState;
};
app.preferences.rulerUnits = originalRulerUnits;
};
////////////////////////////////////
////////////////////////////////////
////////////////////////////////////
// thanks to kasyan servetsky;
function checkPhotoshop(checksOut) {
if (app.documents.length == 0) {
alert("no documents are open. please open a document and try again");
checksOut = false
};
var theKinds = ["LayerKind.BLACKANDWHITE",
"LayerKind.BRIGHTNESSCONTRAST",
"LayerKind.CHANNELMIXER",
"LayerKind.COLORBALANCE",
"LayerKind.CURVES",
"LayerKind.EXPOSURE",
"LayerKind.GRADIENTMAP",
"LayerKind.HUESATURATION",
"LayerKind.INVERSION",
"LayerKind.LAYER3D",
"LayerKind.LEVELS",
"LayerKind.PHOTOFILTER",
"LayerKind.POSTERIZE",
"LayerKind.SELECTIVECOLOR",
"LayerKind.THRESHOLD",
"LayerKind.VIBRANCE"];
for (var n = 0; n < theKinds.length; n++) {
if (app.activeDocument.activeLayer.kind == theKinds) {
alert ("layer is ineligible");
checksOut = false;
}
};
return checksOut
};
////// scale the layers //////
function positionTheLayersORZ () {
app.activeDocument.suspendHistory("scale and rotate", "main()");
function main () {
app.activeDocument.activeHistoryState = thisState;
var thePos = Number(dlg.scale_1.number.text);
try {
var idTrnf = charIDToTypeID( "Trnf" );
var desc3 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref2 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref2.putEnumerated( idLyr, idOrdn, idTrgt );
desc3.putReference( idnull, ref2 );
var idFTcs = charIDToTypeID( "FTcs" );
var idQCSt = charIDToTypeID( "QCSt" );
var idQcsa = charIDToTypeID( "Qcsa" );
desc3.putEnumerated( idFTcs, idQCSt, idQcsa );
var idOfst = charIDToTypeID( "Ofst" );
var desc4 = new ActionDescriptor();
var idHrzn = charIDToTypeID( "Hrzn" );
var idPxl = charIDToTypeID( "#Pxl" );
desc4.putUnitDouble( idHrzn, idPxl, (activeDocument.activeLayer.bounds[0] - thePos) * (-1));
var idVrtc = charIDToTypeID( "Vrtc" );
var idPxl = charIDToTypeID( "#Pxl" );
desc4.putUnitDouble( idVrtc, idPxl, 0);
var idOfst = charIDToTypeID( "Ofst" );
desc3.putObject( idOfst, idOfst, desc4 );
executeAction( idTrnf, desc3, DialogModes.NO );
} catch (e) {};
app.refresh();
};
};
////// scale the layers //////
function positionTheLayers () {
app.activeDocument.suspendHistory("scale and rotate", "main()");
function main () {
app.activeDocument.activeHistoryState = thisState;
var thePos = Number(dlg.scale.number.text);
try {
var idTrnf = charIDToTypeID( "Trnf" );
var desc3 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref2 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref2.putEnumerated( idLyr, idOrdn, idTrgt );
desc3.putReference( idnull, ref2 );
var idFTcs = charIDToTypeID( "FTcs" );
var idQCSt = charIDToTypeID( "QCSt" );
var idQcsa = charIDToTypeID( "Qcsa" );
desc3.putEnumerated( idFTcs, idQCSt, idQcsa );
var idOfst = charIDToTypeID( "Ofst" );
var desc4 = new ActionDescriptor();
var idHrzn = charIDToTypeID( "Hrzn" );
var idPxl = charIDToTypeID( "#Pxl" );
desc4.putUnitDouble( idHrzn, idPxl, 0 );
var idVrtc = charIDToTypeID( "Vrtc" );
var idPxl = charIDToTypeID( "#Pxl" );
desc4.putUnitDouble( idVrtc, idPxl, (activeDocument.activeLayer.bounds[1] - thePos) * (-1));
var idOfst = charIDToTypeID( "Ofst" );
desc3.putObject( idOfst, idOfst, desc4 );
executeAction( idTrnf, desc3, DialogModes.NO );
} catch (e) {};
app.refresh();
};
};
... View more