1 Reply Latest reply on Jul 3, 2014 1:28 PM by JJMack

    JSX and pressed alt key



      I want to use the "Crop and Straighten Photos" plugin in a Photoshop action. But I want to get only one picture. So if I use the plugin manual, I hold the alt key pressed down. Photoshop then produce only one cropped picture.

      But if I record an action with that plugin, the pressed key is not recognized. So I converted the action to a javascript-file and this is the result:


        function step1(enabled, withDialog) {
          if (enabled != undefined && !enabled)
          var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
          executeAction(sTID('CropPhotosAuto0001'), undefined, dialogMode);


      I think, there are two ways for me to let the script do what I want:

      1) Give the "CropPhotosAuto0001"-method-call a param, that tell the plugin, it has to produce only one picture. But I do not found a documentation of this method, so I do not know the syntax of the param.

      2) Insert some code to change the state of the jsx-script: I am not familiar with jsx, but I think, there are some event variables that indicate a pressed key or a pressed mouse button, plugins recognize.


      Hopefully you can help me.

      Thanks a lot!

        • 1. Re: JSX and pressed alt key
          JJMack Most Valuable Participant

          The Plugin has no dialog and parameters are not passed to it as far as I know. You use menu File>Automate>Crop and Straighten there are no parameters you can set. During its processing it must check to state of the Alt key after creating a new document.  If the state is down the plugin terminates ends.  One would need the source code for the plugin to see if is possible to pass parameters. I think its highly unlikely.  Plugins that take parameters normally do so be using a dialog. If the plugin has coded in action support the parameters are recorded into actions steps by the plug-in during the action recording and these get passed to the Plug-in by the action player when played and the Plug-in bypasses displaying its dialog unless the step's dialog is turned on.   The only way I have seen parameters passed to plugins is through a dialog or through an action that has recorded dialog settings.


          What you show is part of a script that looks like X's  Script ActionFileToJavascript created.  Step 1 in your action  used this function. As posted this would fail for sTID  setting is missing.  'CropPhotosAuto0001'  is not a method its a parameter that identifies the automate plugin CropPhotosAuto.8li  the method is executeAction. Action manager code.


          In you action you may be able to add a stop message that would state  Hold down the Alt and click play before the crop and straighten step.


          I just remembered I have also seen scripts pass parameters to a plug-in plug-in the image Processor use the Plug-in Fit image to re-size documents. Again is executeAction method however Parameters are pass via variables.  However FitImage Plug-in has a dialog and parameters can be passed to it.  I do not know if anything can be passed to CropPhotoAuto plug-in.


          // use the fit image automation plug-in to do this work for me

          function FitImage( inWidth, inHeight ) {

            if ( inWidth == undefined || inHeight == undefined ) {

            alert( strWidthAndHeight );



            var desc = new ActionDescriptor();

            var unitPixels = charIDToTypeID( '#Pxl' );

            desc.putUnitDouble( charIDToTypeID( 'Wdth' ), unitPixels, inWidth );

            desc.putUnitDouble( charIDToTypeID( 'Hght' ), unitPixels, inHeight );

            var runtimeEventID = stringIDToTypeID( "3caa3434-cb67-11d1-bc43-0060b0a13dc4" );

            executeAction( runtimeEventID, desc, DialogModes.NO );




          Just examine the scriptlistener code below the top is FitImage You can see the parms beeing passed 600 and 800 etc. The second step is Crop and Straighten nothing is passed via executeAction othere then the plugin id.


          // =======================================================

          var idthreecaathreefourthreefourcbsixsevenoneonedonebcfourthreezerozerosixzerobzeroaonethreed cfour = stringIDToTypeID( "3caa3434-cb67-11d1-bc43-0060b0a13dc4" );

              var desc3 = new ActionDescriptor();

              var idMsge = charIDToTypeID( "Msge" );

              desc3.putString( idMsge, """Fit Image action settings""" );

              var idHght = charIDToTypeID( "Hght" );

              var idPxl = charIDToTypeID( "#Pxl" );

              desc3.putUnitDouble( idHght, idPxl, 600.000000 );

              var idWdth = charIDToTypeID( "Wdth" );

              var idPxl = charIDToTypeID( "#Pxl" );

              desc3.putUnitDouble( idWdth, idPxl, 800.000000 );

              var idlimit = stringIDToTypeID( "limit" );

              desc3.putBoolean( idlimit, true );

          executeAction( idthreecaathreefourthreefourcbsixsevenoneonedonebcfourthreezerozerosixzerobzeroaonethreed cfour, desc3, DialogModes.NO );



          // =======================================================

          var idCropPhotosAutozerozerozeroone = stringIDToTypeID( "CropPhotosAuto0001" );

          executeAction( idCropPhotosAutozerozerozeroone, undefined, DialogModes.NO );