Skip to main content
abeb6401
Participating Frequently
January 30, 2018
Answered

JSX: Is there a way to get app.opendialog full path?

  • January 30, 2018
  • 3 replies
  • 1261 views

Hi guys. Is there a way to get the full path of a selected image via the open dialog or using any other method? I'd like to save the path in the extension so that it can be set to the path of the textures folder. The path always opens in the last path used in photoshop at this moment. Basically, I just want to capture the file path that is selected in the extension and set it temporarily until I reset it in the extension function.

Here's what I got:

fyi: getafilepathtoJS("getfilepath",selectedfile); ---- is an add listener in the main.js that captures the path but it only shows the filename.

function step1(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Back'));

    desc1.putReference(cTID('null'), ref1);

    desc1.putBoolean(cTID('MkVs'), false);

    var list1 = new ActionList();

    list1.putInteger(1);

    desc1.putList(cTID('LyrI'), list1);

    executeAction(cTID('slct'), desc1, dialogMode);

  };

  // Select

    function step2(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

        var idPlc = charIDToTypeID( "Plc " );

        var desc11 = new ActionDescriptor(); 

        var idnull = charIDToTypeID( "null" );

        var selectedFile = app.openDialog();

                   

        //return file path

        getafilepathtoJS("getfilepath",selectedfile);

       

        desc11.putPath( idnull, new File(selectedFile) );

        var idFTcs = charIDToTypeID( "FTcs" );

        var idQCSt = charIDToTypeID( "QCSt" );  

        var idQcsa = charIDToTypeID( "Qcsa" );

        desc11.putEnumerated( idFTcs, idQCSt, idQcsa );

        var idOfst = charIDToTypeID( "Ofst" );    

        var desc12 = new ActionDescriptor();    

        var idHrzn = charIDToTypeID( "Hrzn" );   

        var idPxl = charIDToTypeID( "#Pxl" );     

        desc12.putUnitDouble( idHrzn, idPxl, 0.000000 );    

        var idVrtc = charIDToTypeID( "Vrtc" );   

        var idPxl = charIDToTypeID( "#Pxl" );   

        desc12.putUnitDouble( idVrtc, idPxl, 0.000000 );

        var idOfst = charIDToTypeID( "Ofst" );

        desc11.putObject( idOfst, idOfst, desc12 );

        executeAction( idPlc, desc11, DialogModes.NO );

        };

       step1();

       step2();       

};

This topic has been closed for replies.
Correct answer EFinnegan

Maybe the answer in this other thread could help point you in the right direction? There are components about the file path.  But since you're working with the .jsx, I'm not sure if that's useful or not.

3 replies

abeb6401
abeb6401Author
Participating Frequently
February 7, 2018

Thanks for your help! Those helped a little. I decided to add an input box to paste the path and then set it and save it with localstorage since I'll need a button to clear it if needed anyway. The input box is more functional and works on mac as well.

Thanx a mil for your assistance!

Ten A
Community Expert
Community Expert
January 30, 2018

Here is a sample extension you can reference how to get folder path and keep it in localstorage.

CreativeSuiteSDK_Experimentals/net.sytes.chuwa.jsxlauncher at master · ten-A/CreativeSuiteSDK_Experimentals · GitHub

EFinnegan
EFinneganCorrect answer
Inspiring
January 30, 2018

Maybe the answer in this other thread could help point you in the right direction? There are components about the file path.  But since you're working with the .jsx, I'm not sure if that's useful or not.