Enclosed is my version of the script.
For those of you who don't have spanish computers, you'll need to change "Fondo" on line 93 to "Background" or whatever it is in your language.
Thanks for the headsup on adjusment layers. I'm gonna make a version of the script whereby you can select all the layers your interested in first , and it will merge them down then do the same thing with that.. that'd be quick too..
Other variations could be all layers in a folder.. I'm not an artist, so I'll just have to keep working up tweaks for my artist as and when she needs them..
Script is in plain text..
========exportLayerWithMask.jsx========
//set the doc and save names
var doc = app.activeDocument;
var Path = app.activeDocument.path;
var Name = decodeURI(app.activeDocument.name).replace(/\.[^\.]+$/, '');
var layerName = app.activeDocument.activeLayer.name.replace(/[:\/\\*\?\"\<\>\|]/g, "_");
var saveFile= new File(Path + "/" + layerName + ".png");
// =======================================================
// create temp layer
var idDplc = charIDToTypeID( "Dplc" );
var desc30 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref17 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref17.putEnumerated( idLyr, idOrdn, idTrgt );
desc30.putReference( idnull, ref17 );
var idNm = charIDToTypeID( "Nm " );
desc30.putString( idNm, """copyTemp""" );
var idVrsn = charIDToTypeID( "Vrsn" );
desc30.putInteger( idVrsn, 5 );
executeAction( idDplc, desc30, DialogModes.NO );
// =======================================================
// apply mask
var idDlt = charIDToTypeID( "Dlt " );
var desc31 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref18 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
var idChnl = charIDToTypeID( "Chnl" );
var idMsk = charIDToTypeID( "Msk " );
ref18.putEnumerated( idChnl, idChnl, idMsk );
desc31.putReference( idnull, ref18 );
var idAply = charIDToTypeID( "Aply" );
desc31.putBoolean( idAply, true );
executeAction( idDlt, desc31, DialogModes.NO );
// =======================================================
//select all
var idsetd = charIDToTypeID( "setd" );
var desc32 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref19 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
var idfsel = charIDToTypeID( "fsel" );
ref19.putProperty( idChnl, idfsel );
desc32.putReference( idnull, ref19 );
var idT = charIDToTypeID( "T " );
var idOrdn = charIDToTypeID( "Ordn" );
var idAl = charIDToTypeID( "Al " );
desc32.putEnumerated( idT, idOrdn, idAl );
executeAction( idsetd, desc32, DialogModes.NO );
// =======================================================
//copy
var idcopy = charIDToTypeID( "copy" );
executeAction( idcopy, undefined, DialogModes.NO );
// =======================================================
//new document
var idMk = charIDToTypeID( "Mk " );
var desc33 = new ActionDescriptor();
var idNw = charIDToTypeID( "Nw " );
var desc34 = new ActionDescriptor();
var idpreset = stringIDToTypeID( "preset" );
desc34.putString( idpreset, """Portapapeles""" );
var idDcmn = charIDToTypeID( "Dcmn" );
desc33.putObject( idNw, idDcmn, desc34 );
executeAction( idMk, desc33, DialogModes.NO );
// =======================================================
//paste
var idpast = charIDToTypeID( "past" );
var desc35 = new ActionDescriptor();
var idAntA = charIDToTypeID( "AntA" );
var idAnnt = charIDToTypeID( "Annt" );
var idAnno = charIDToTypeID( "Anno" );
desc35.putEnumerated( idAntA, idAnnt, idAnno );
executeAction( idpast, desc35, DialogModes.NO );
// =======================================================
//select background layer
var idslct = charIDToTypeID( "slct" );
var desc36 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref20 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
ref20.putName( idLyr, "Fondo" );
desc36.putReference( idnull, ref20 );
var idMkVs = charIDToTypeID( "MkVs" );
desc36.putBoolean( idMkVs, false );
executeAction( idslct, desc36, DialogModes.NO );
// =======================================================
//delete layer
var idDlt = charIDToTypeID( "Dlt " );
var desc37 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref21 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref21.putEnumerated( idLyr, idOrdn, idTrgt );
desc37.putReference( idnull, ref21 );
executeAction( idDlt, desc37, DialogModes.NO );
// =======================================================
//save as
var idsave = charIDToTypeID( "save" );
var desc38 = new ActionDescriptor();
var idAs = charIDToTypeID( "As " );
var desc39 = new ActionDescriptor();
var idPGIT = charIDToTypeID( "PGIT" );
var idPGIT = charIDToTypeID( "PGIT" );
var idPGIN = charIDToTypeID( "PGIN" );
desc39.putEnumerated( idPGIT, idPGIT, idPGIN );
var idPNGf = charIDToTypeID( "PNGf" );
var idPNGf = charIDToTypeID( "PNGf" );
var idPGAd = charIDToTypeID( "PGAd" );
desc39.putEnumerated( idPNGf, idPNGf, idPGAd );
var idCmpr = charIDToTypeID( "Cmpr" );
desc39.putInteger( idCmpr, 9 );
var idPNGF = charIDToTypeID( "PNGF" );
desc38.putObject( idAs, idPNGF, desc39 );
var idIn = charIDToTypeID( "In " );
desc38.putPath( idIn, new File( saveFile) );
var idDocI = charIDToTypeID( "DocI" );
desc38.putInteger( idDocI, 1165 );
var idCpy = charIDToTypeID( "Cpy " );
desc38.putBoolean( idCpy, true );
var idLwCs = charIDToTypeID( "LwCs" );
desc38.putBoolean( idLwCs, true );
var idsaveStage = stringIDToTypeID( "saveStage" );
var idsaveStageType = stringIDToTypeID( "saveStageType" );
var idsaveBegin = stringIDToTypeID( "saveBegin" );
desc38.putEnumerated( idsaveStage, idsaveStageType, idsaveBegin );
executeAction( idsave, desc38, DialogModes.NO );
// =======================================================
var idsave = charIDToTypeID( "save" );
var desc40 = new ActionDescriptor();
var idAs = charIDToTypeID( "As " );
var desc41 = new ActionDescriptor();
var idPGIT = charIDToTypeID( "PGIT" );
var idPGIT = charIDToTypeID( "PGIT" );
var idPGIN = charIDToTypeID( "PGIN" );
desc41.putEnumerated( idPGIT, idPGIT, idPGIN );
var idPNGf = charIDToTypeID( "PNGf" );
var idPNGf = charIDToTypeID( "PNGf" );
var idPGAd = charIDToTypeID( "PGAd" );
desc41.putEnumerated( idPNGf, idPNGf, idPGAd );
var idCmpr = charIDToTypeID( "Cmpr" );
desc41.putInteger( idCmpr, 9 );
var idPNGF = charIDToTypeID( "PNGF" );
desc40.putObject( idAs, idPNGF, desc41 );
var idIn = charIDToTypeID( "In " );
desc40.putPath( idIn, new File( saveFile ) );
var idDocI = charIDToTypeID( "DocI" );
desc40.putInteger( idDocI, 1165 );
var idCpy = charIDToTypeID( "Cpy " );
desc40.putBoolean( idCpy, true );
var idLwCs = charIDToTypeID( "LwCs" );
desc40.putBoolean( idLwCs, true );
var idsaveStage = stringIDToTypeID( "saveStage" );
var idsaveStageType = stringIDToTypeID( "saveStageType" );
var idsaveSucceeded = stringIDToTypeID( "saveSucceeded" );
desc40.putEnumerated( idsaveStage, idsaveStageType, idsaveSucceeded );
executeAction( idsave, desc40, DialogModes.NO );
// =======================================================
//close document
var idCls = charIDToTypeID( "Cls " );
var desc42 = new ActionDescriptor();
var idSvng = charIDToTypeID( "Svng" );
var idYsN = charIDToTypeID( "YsN " );
var idN = charIDToTypeID( "N " );
desc42.putEnumerated( idSvng, idYsN, idN );
executeAction( idCls, desc42, DialogModes.NO );
// =======================================================
//dlete temp layer
var idDlt = charIDToTypeID( "Dlt " );
var desc43 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref22 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref22.putEnumerated( idLyr, idOrdn, idTrgt );
desc43.putReference( idnull, ref22 );
executeAction( idDlt, desc43, DialogModes.NO );
=========endofscript========
ps
code is verbose becuase I recorded it... http://blogs.adobe.com/crawlspace/2006/ ... and_1.html