Thursday, 19 February 2015

How To Include A JSX Script In Another JSX Script

To include a JSX script in another JSX script and run any functions you want is is very simple.

To include the script:

#include "path/to/script.jsx"
To run a function from an included script:

#include "path/to/script.jsx"

Copy The Current Selection Bounds To X, Y, Width, Height To AS3 code

This JSX script for Photoshop allows you copy to the clipboard current layer properties to AS3 code in the format:
&selectionBounds.x = &layerx; &selectionBounds.y = &layery; // &selectionBounds.width = &layerwidth; // &selectionBounds.height = &layerheight;

Instructions on how to use this script:

  1. Save the script as SelectionBoundsToAS3.jsx
  2. Open Photoshop
  3. Select a layer in your PSD
  4. Go to File > Scripts > Browse > Select the script file (SelectionBoundsToAS3)

if ( app.documents.length > 0 ) {
preferences.rulerUnits = Units.PIXELS;
var layerRef = app.activeDocument.selection;
var layerName = "selectionBounds";
var x = layerRef.bounds[0].value;
var y = layerRef.bounds[1].value;
var width = layerRef.bounds[2].value - x;
var height = layerRef.bounds[3].value - y;
var clp = "";
clp += "\t\t" + layerName + ".x = " + x +";\r";
clp += "\t\t" + layerName + ".y = " + y +";\r";
clp += "\t\t// " + layerName + ".width = " + width +";\r";
clp += "\t\t// " + layerName + ".height = " + height +";\r";
} else {
 alert("You must have one opened document at least!");
function copyTextToClipboard(txt){
    const keyTextData = app.charIDToTypeID('TxtD');
    const ktextToClipboardStr = app.stringIDToTypeID( "textToClipboard" );
    var textStrDesc = new ActionDescriptor();
    textStrDesc.putString( keyTextData, txt );
    executeAction( ktextToClipboardStr, textStrDesc, DialogModes.NO );

Thursday, 5 December 2013

Useful links to help with Photoshop scripting

Here is a list of some very useful online resources to help people get started coding Photoshop scripts.

Adobe Photoshop Scripting

The official help page for Photoshop CS2, CS3, CS4, CS5, CS6 and CC scripting. It has useful PDF guides, references and samples as well as the Scripting Listener Plug-in for Windows and Mac.

Adobe Forums

The official Photoshop scripting support forum.

Adobe Configurator

A easy to use program which is free to download and helps with the creation of graphic panels and menus which can be linked with Photoshop and InDesign scripts.

PS-Scripts Forum

A very useful Photoshop Scripting Community with helpful members and various different forum sections covering the main topics of scripting. There is also free scripts and tutorial resources available to download.


A useful JavaScript toolkit for Photoshop scripts with lots of ready to use tools and functions.

Introduction To Photoshop Scripting

A scripting tutorial which introduces you to Photoshop scripting and shows how to duplicate and rotate layers.

Creating your own backgrounds with Adobe Photoshop Scripting

A scripting tutorial which shows how to fill the background with 1000 randomly placed numbers.

Powerful Task Automation with Photoshop Scripting

A scripting tutorial which shows how to automate various common tasks via scripting.

Welcome to Photoshop scripts

Welcome to my new Photoshop scripts, snippets and resources blog where i will be posting various useful resources which i have created or found online. Thanks for visiting.