Select Crop tool and Tool preset but do nothing

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

Mcquiff

Select Crop tool and Tool preset but do nothing

Post by Mcquiff »

I thought this would be simple,

I have about 10 different crop settings for different ratios.

At the moment when I want to crop an image I have to select the crop tool, then the tool preset.

I would like to be able to convert that little action into a script so that I can assign them a hot key, but I can't seam to figure out how?

Any suggestions on how the script can be written to select the crop tool and then the preset so I can then draw out the crop?

Many Thanks

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

txuku

Select Crop tool and Tool preset but do nothing

Post by txuku »

Bonjour Mcquiff

You can use the ScriptingListenerJS.log :

Code: Select all//Selectionner l outil Recadrage
// =======================================================
var idslct = charIDToTypeID( "slct" );
    var desc21 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref12 = new ActionReference();
        var idcropTool = stringIDToTypeID( "cropTool" );
        ref12.putClass( idcropTool );
    desc21.putReference( idnull, ref12 );
    var iddontRecord = stringIDToTypeID( "dontRecord" );
    desc21.putBoolean( iddontRecord, true );
    var idforceNotify = stringIDToTypeID( "forceNotify" );
    desc21.putBoolean( idforceNotify, true );
executeAction( idslct, desc21, DialogModes.NO );


//Selectionner le nom du ratio de l outil Recadrage
// =======================================================
var idslct = charIDToTypeID( "slct" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref4 = new ActionReference();
        var idtoolPreset = stringIDToTypeID( "toolPreset" );
        ref4.putName( idtoolPreset, "Recadrage 5 po x 7 po 300 ppp" );// nom du ratio
    desc7.putReference( idnull, ref4 );
executeAction( idslct, desc7, DialogModes.NO );
Mcquiff

Select Crop tool and Tool preset but do nothing

Post by Mcquiff »

I assume this is a recorder that records what you press? and then writes the script?

I tried running it but I get an error.

Error 8800: General Photoshop error occurred. This functionality may not be available in this version of Photoshop.
- The command “Select” is not currently available.
Line: 26
-> executeAction( idslct, desc7, DialogModes.NO );

?? I'm running CS6 if that makes any difference.
txuku

Select Crop tool and Tool preset but do nothing

Post by txuku »

Mcquiff wrote:I assume this is a recorder that records what you press? and then writes the script?
.......................

Yes and you can download the plugin HERE


Mcquiff wrote:......................I tried running it but I get an error.

Error 8800: General Photoshop error occurred. This functionality may not be available in this version of Photoshop.
- The command “Select” is not currently available.
Line: 26
-> executeAction( idslct, desc7, DialogModes.NO );

..............................

You have to put the English name of the ratio line 21 !
Mcquiff

Select Crop tool and Tool preset but do nothing

Post by Mcquiff »

Still struggling.

The code below works, and selects the tool preset (so in fact it works) but i'm trying to do as you have done and put the ratio in place of the tool preset like within yours but it still doesn't work.

"Recadrage 5 po x 7 po 300 ppp" Not sure how this should be written, google direct translation in cropping, but i'm sure thats not how photoshop would use it?



Code: Select allvar idslct = charIDToTypeID( "slct" );
    var desc13 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref8 = new ActionReference();
        var idcropTool = stringIDToTypeID( "cropTool" );
        ref8.putClass( idcropTool );
    desc13.putReference( idnull, ref8 );
    var iddontRecord = stringIDToTypeID( "dontRecord" );
    desc13.putBoolean( iddontRecord, true );
    var idforceNotify = stringIDToTypeID( "forceNotify" );
    desc13.putBoolean( idforceNotify, true );
executeAction( idslct, desc13, DialogModes.NO );

// =======================================================
var idslct = charIDToTypeID( "slct" );
    var desc14 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref9 = new ActionReference();
        var idtoolPreset = stringIDToTypeID( "toolPreset" );
        ref9.putName( idtoolPreset, "CropSetA" );
    desc14.putReference( idnull, ref9 );
executeAction( idslct, desc14, DialogModes.NO );
txuku

Select Crop tool and Tool preset but do nothing

Post by txuku »

A picture is better :

Mcquiff

Select Crop tool and Tool preset but do nothing

Post by Mcquiff »

Ahhhhh! ok get it now, I thought you were manually keying in the Crop details in the top menu bar, in which case I was doing right from the last post.

Many Thanks All working ok now!



Matt
txuku

Select Crop tool and Tool preset but do nothing

Post by txuku »

Mcquiff

Select Crop tool and Tool preset but do nothing

Post by Mcquiff »

I have this working can I get a little more technical and get it to drop the crop tool box over the whole image from the center, (as it is in CS6)but can then be resized after?. Short of buying CS6
txuku

Select Crop tool and Tool preset but do nothing

Post by txuku »

I do not know how ...............