Skip to main content
zia5E08
Known Participant
February 4, 2022
Question

how to stop script if document window cancel problum

  • February 4, 2022
  • 3 replies
  • 364 views

i create a script pSD tempaltes open from specific folder, when i click on cancel on open window then an errer apear 

This topic has been closed for replies.

3 replies

Kukurykus
Legend
February 5, 2022

The script works beside one part (that correctly is "N   ") due to not using </> icon when inserting the code.

Legend
February 4, 2022

Add a check with an if statement

 

var selectedFile = dir.openDlg("Select Image" , "Select:*.nef;*.cr2;*.crw;*.dcs;*.raf;*.arw;*.orf;*.dng;*.psd;*.tif;* .jpg;*.png;*.bmp");

if (selectedFile)
    {
    desc2393.putPath( idnull, new File(selectedFile) );
    var idDocI = charIDToTypeID( "DocI" );
    desc2393.putInteger( idDocI, 1276 );
    executeAction( idOpn, desc2393, DialogModes.NO );
    }

 

zia5E08
zia5E08Author
Known Participant
February 5, 2022

your script working but  specific folder not open  

 

var dir = Folder('D:/CHOHAN PANEL DATA/SEQ PSD FRAMES/5_2');
var selectedFile = dir.openDlg("Select Image" , "Select:*.nef;*.cr2;*.crw;*.dcs;*.raf;*.arw;*.orf;*.dng;*.psd;*.tif;*

 

please solve this. thanks

My English is a little weak. Please i hope u understand me what i say

zia5E08
zia5E08Author
Known Participant
February 4, 2022

script 

 


// =======================================================
var idOpn = charIDToTypeID( "Opn " );
var desc2393 = new ActionDescriptor();
var iddontRecord = stringIDToTypeID( "dontRecord" );
desc2393.putBoolean( iddontRecord, false );
var idforceNotify = stringIDToTypeID( "forceNotify" );
desc2393.putBoolean( idforceNotify, true );
var idnull = charIDToTypeID( "null" );
var dir = Folder('D:/CHOHAN PANEL DATA/SEQ PSD FRAMES/5_2');
var selectedFile = dir.openDlg("Select Image" , "Select:*.nef;*.cr2;*.crw;*.dcs;*.raf;*.arw;*.orf;*.dng;*.psd;*.tif;* .jpg;*.png;*.bmp");
desc2393.putPath( idnull, new File(selectedFile) );
var idDocI = charIDToTypeID( "DocI" );
desc2393.putInteger( idDocI, 1276 );
executeAction( idOpn, desc2393, DialogModes.NO );


// =======================================================
var idselectAllLayers = stringIDToTypeID( "selectAllLayers" );
var desc2395 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref416 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref416.putEnumerated( idLyr, idOrdn, idTrgt );
desc2395.putReference( idnull, ref416 );
executeAction( idselectAllLayers, desc2395, DialogModes.NO );


// =======================================================
var idcopy = charIDToTypeID( "copy" );
executeAction( idcopy, undefined, DialogModes.NO );

 


// =======================================================
var idCls = charIDToTypeID( "Cls " );
var desc2400 = new ActionDescriptor();
var idSvng = charIDToTypeID( "Svng" );
var idYsN = charIDToTypeID( "YsN " );
var idN = charIDToTypeID( "N " );
desc2400.putEnumerated( idSvng, idYsN, idN );
var idDocI = charIDToTypeID( "DocI" );
desc2400.putInteger( idDocI, 1276 );
var idforceNotify = stringIDToTypeID( "forceNotify" );
desc2400.putBoolean( idforceNotify, true );
executeAction( idCls, desc2400, DialogModes.NO );