Ghoul Fool
Engaged
Ghoul Fool
Engaged
Activity
‎Mar 18, 2024
03:17 AM
6 Upvotes
I want to toggle on and off a layer by name and add it to a keypress via an action. Go me! var srcDoc = app.activeDocument;
var layerName = "my lovely layer";
srcDoc.activeLayer = srcDoc.artLayers.getByName(layerName);
var vis = srcDoc.activeLayer.visible;
srcDoc.activeLayer.visible = !vis; So far so good. However, I'm a completist and I want to go back to the originally selected layer before hand. Adding this at the start var currentLayer = srcDoc.activeLayer; and then using that reference to go back to it : srcDoc.activeLayer = currentLayer; Does not work as expected. My script-fu may be weak this morning. -I get mixed results depending on what layer is initially selected and wherther it is visible or not. Any ideas where I'm going wrong?? Answers, as always, on a postcard...
... View more
‎Mar 04, 2024
05:53 AM
3 Upvotes
Anyone know why a small white border would appear on a PSD whilst working on it??? Might be a video card thing; might be a "feature". It does not reappear when you create Window --> New window see screenshot. Image on left (new window) image on right with small white border around canvas both are 128 x 128 image filled with blue pixels - nothing else It is not a set pixel border as it remains the same size when you zoom in/out.
... View more
‎Feb 23, 2024
08:04 AM
I've not re-booted but had to restart Indesign, (obviously) and reused my original script - which worked fine - no crash. Weird.
... View more
‎Feb 23, 2024
07:20 AM
That'd just tell me I need to pass an array to align instead of the selection.
... View more
‎Feb 23, 2024
06:16 AM
7 Upvotes
I was hoping to write a tiny script to align the current selected image to the page: // DOES NOT WORK!!! USE AT YOUR OWN RISK
var srcDoc = app.activeDocument;
var alignTo = AlignDistributeBounds.PAGE_BOUNDS;
var sel = srcDoc.selection;
srcDoc.align ( sel, AlignOptions.VERTICAL_CENTERS, alignTo);
srcDoc.align ( sel, AlignOptions.HORIZONTAL_CENTERS, alignTo); But InDesigned crashed - but I can't think where I'm going wrong. DON'T use the script in it's current form Answers on a postcard, please.
... View more
‎Feb 15, 2024
05:53 AM
1 Upvote
Looks like the only "word" it understands is "KIND". - I threw a list of four letter words at it! - Which sounds ruder that it was :D.
... View more
‎Feb 12, 2024
02:14 AM
Thanks for that, c.pfaffenbichler! Looks as though I still need help from a grown-up The snap values is when M == 17, i == 4; but it seems to report it being enabled as true regardless of when it's on or off. So might not have the correct values. See screenshot
... View more
‎Feb 10, 2024
07:07 AM
Sorry, should have been more specific: I get the following error: Error 8500: The requested property does not exist. Line 8 -> if (thisOne.getString(stringIDToTypeID("name")) == "Snap") { - So it doesn't even make it to the alert.
... View more
‎Feb 10, 2024
01:18 AM
I'm glad you find it curious too! There's no explicit unit set up in the script - as I use pixels so assume that's been set and not changed. Secondly, the images size is an odd 200 dpi, 256 x 224 pixels (w & h) Thirrdly resizing the image to 72 dpi, 256 x 224 pixels (w & h) - the script works fine.
... View more
‎Feb 09, 2024
11:19 AM
Units are pixels. Even without the "value" I get an object that's "244 px" and yet alert( app.activeDocument.height.value == 224) is false.
... View more
‎Feb 09, 2024
09:07 AM
2 Upvotes
This is a bit backward: var imageHeight = app.activeDocument.height.value;
if (imageHeight == 224)
{
// do stuff
} Didn't work for once - I assumed that image dimensions were ints, but there we go... Casting it to an int worked: if (parseInt(imageHeight) == 224)
{
// do stuff
} Case closed. But! Just out on curiousity, how do you get the float value of app.activeDocument.height??? - it always seems to report it as in int. Assuming that's what's going wrong. I tried casting it as float and multiplying it by 1,000,000.
... View more
‎Feb 09, 2024
08:21 AM
1 Upvote
You mayhave been outputting code for your own sanity but var theResults = new Array; Doesn't get used.
... View more
‎Feb 09, 2024
06:45 AM
1 Upvote
Works in PS2020, sadly, doesn't work on older versions like 19. 😞
... View more
‎Feb 08, 2024
05:23 AM
Let's try this again... ...Apart from being derailed by bots or manually setting the status is it possible to get the current state of snap & smart guides from AM code?
... View more
‎Jan 31, 2024
06:01 AM
6 Upvotes
I can create a Windows dialog box to select a folder (to process .png images) with this var filterFiles = "PNG:*.png"; // I am windows
var inFolder = Folder.selectDialog("Please select FOLDER to process", filterFiles);
if (inFolder != null)
{
var fileList = inFolder.getFiles(/\.(png)$/i);
} But... how do I get the script to show the dialog that shows all files in it. Like this:
... View more
‎Jan 17, 2024
01:00 PM
Thanks for the tip, Davide. Looks like I need to start saving up for your book. Well... not today, but at some point, this old carcass will have to learn UXP. Not today But when that eventful day happens, I'll break free from the tradition of "Hello world!" and have something different like "Hello Adobe". Only much, much, much ruder.
... View more
‎Jan 17, 2024
11:34 AM
Rightly, or wrongly let us assume that UXP is the future... An immediate (interim/bridging) solution would be a (Hail Mary) UXP script that can read a classic .jsx and run it as normal - kind of a wrapper for the original. That's got to be possible, surely?
... View more
‎Jan 17, 2024
06:03 AM
1 Upvote
But in terms of legacy scripts (like Load Files into Stack.jsx - for example ), will they continue to work or will everything have to be re-written for future versions?
... View more
‎Jan 12, 2024
01:12 AM
That is also a possibility as well. Just to give it some context. I'm working on a destructive script which wil clear out any unwanted (hidden) layers. Naturally if a layer is deleted it won't exist. Which got me thinking... How you easily determine if a layer (like a variable) still exists.
... View more
‎Jan 11, 2024
09:03 AM
2 Upvotes
Is there a in-built way in Photoshop scripting to return if a layer exists or not? Bearing in mind that there may be duplicate layer names so getByName isn't what I'm after. function does_layer_exist(id)
{
var originalSelectedLayer = app.activeDocument.activeLayer;
try
{
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putIdentifier(charIDToTypeID('Lyr '), id);
desc1.putReference(charIDToTypeID('null'), ref1);
executeAction(charIDToTypeID('slct'), desc1, DialogModes.NO);
app.activeDocument.activeLayervar = originalSelectedLayer;
return true;
}
catch(eek)
{
return false;
}
} This works, but I'm just wondering if there is an in-built method to call. Curious, me, you see.
... View more
‎Jan 08, 2024
09:02 AM
1 Upvote
D'oh! Thank, man.
... View more
‎Jan 08, 2024
07:40 AM
2 Upvotes
Hi. Out of interest I'm trying to set some options when running an action via a script, specifically suppressing the action dialog via script. - Not displayDialogs = DialogModes.NO var theFiles = ["D:\\temp\\jp.jpg"];
// MAIN SCRIPT CODE TO DO STUFF...
var act = "make_layer"
var actset = "my_action_set";
var batchOptions = new BatchOptions();
batchOptions.overrideOpen = false;
batchOptions.overrideSave = false;
// app.doAction(act, actset);
app.batch (theFiles, act, actset, batchOptions) I get the error illegal argument on app.batch (theFiles, act, actset, batchOptions); - not very helpful. Not sure where I'm going wrong as app.doAction(act, actset); works fine. Any ideas??
... View more
‎Nov 24, 2023
07:06 AM
Thanks, that might work - but I can write a script for this 🙂
... View more
‎Nov 24, 2023
04:10 AM
What would you like to do next - after you found them? Well... I've got to tell the images that they've been very, very naughty! Not it's more of a visual inspection. It's really important that some images are the correct size and I don't want to go to print if that occurs. So if I can flag that down first, I'll no what's what.
... View more
‎Nov 23, 2023
08:57 AM
11 Upvotes
Is there a quick way (with Javascript) to detect if a placed image in InDesign has been scaled (by error or accident) after it has been imported and placed? The image properties diesn't seem to help at this point. Sort of like this, but you know, better: function has_this_been_accidentally_scaled()
{
var scaled = active_image.transform.scale()
if (scaled != 100) return true;// Yes, it's too big/small
else return false; // No, it's at 100% scale
}
... View more
‎Nov 23, 2023
04:28 AM
1 Upvote
And if anyone is after those elusive magic numbers then this will help: var myShapeOperation = "Subtract Front Shape";
var myShapeID = get_shape_operation_numbers(myShapeOperation);
//alert(myShapeID)
change_selected_path_shape_operation(myShapeID);
alert(myShapeOperation);
function get_shape_operation_numbers(str)
{
var num;
switch (str)
{
case "Combine Shapes":
num = 1097098272; // phEnumAdd -> 1097098272 -> "Add " add
break;
case "Subtract Front Shape":
num = 1398961266; // phEnumSubtract -> 1398961266 -> "Sbtr" subtract
break;
case "Intersect Shape Areas":
num = 1231975538; // phEventIntersect -> 1231975538 -> "Intr" interfaceIconFrameDimmed
break;
case "Exclude Overlapping Shapes":
num = 1231975511; // phEventIntersectWith -> 1231975511 -> "IntW" interfaceWhite
break;
default:
num = 1097098272;
}
return num;
}
... View more
‎Nov 15, 2023
03:17 AM
5 Upvotes
I can check to see if a parent (group) of a Photoshop layer is visible or not with: if (theParent.visible == false)
{
// do something? Like switch it on?
theParent.visible = true;
} And you can find the name of that parent group with alert(theParent.name); // Group 1 If it's a layer that's just on it's own the parent name will be the name of the document. Err ok. And parent.visible will be null. Can it be safe to assume if if the parent === null it's an "orphan layer" or is there a better way of determining that? - Got you all thinking now 😄
... View more
‎Nov 09, 2023
07:15 AM
4 Upvotes
I came across this post of GDSE and now, it nearly being the end of 2023, can anyone confirm or deny if this (unsourced) statement "...Action manager won't be supported in newer versions of Photoshop." is true or not?? Is this a random rumour? Or is it anything that Action Manager coding fans should be concerned about? Clarity with an explantion is due. The truth is out there with a side order of cookies...
... View more
‎Nov 09, 2023
12:50 AM
5 Upvotes
I'm trying to change the shape operation on a path via a script in Photoshop. Oddly though, using the relevant ScriptListener code results in error. // SL code ERROR
// =======================================================
var idinvokeCommand = stringIDToTypeID( "invokeCommand" );
var desc3112 = new ActionDescriptor();
var idcommandID = stringIDToTypeID( "commandID" );
desc3112.putInteger( idcommandID, 3404 );
var idkcanDispatchWhileModal = stringIDToTypeID( "kcanDispatchWhileModal" );
desc3112.putBoolean( idkcanDispatchWhileModal, true );
executeAction( idinvokeCommand, desc3112, DialogModes.NO ); and my code below is error free, but ultimately doesn't work: var srcDoc = app.activeDocument;
var pathitem = srcDoc.pathItems.getByName("My path");
pathitem.select();
// pathitem.operation = ShapeOperation.SHAPEADD;
var lineSubPathArray = new SubPathInfo();
lineSubPathArray.operation = ShapeOperation.SHAPEADD; // SHAPEADD SHAPESUBTRACT SHAPEXOR SHAPEINTERSECT
alert(lineSubPathArray.operation) Not sure where I'm going wrong; unless the subpath operation needs to be done on each path point?? Any ideas.
... View more