Copy link to clipboard
Copied
Hello personal greetings to all:
Is there any possibility to select tools via scripts? I need to add the command a few buttons on a panel HTML5. I tried to create actions for each of them but some of them does not work actions:
Are they:
• Pen Tool
• Freeform Pen Tool
• Add Anchor Point Tool
• Delete Anchor Point Tool
--------------------------------------------
• Rectangular Marquee Tool
• Elliptical Marquee Tool
---------------------------------------------
• Polygonal Lasso Tool
• Magnetic Lasso Tool
Hope these help....
.../////// Pentool
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( app.stringIDToTypeID('penTool') );
desc.putReference( app.charIDToTypeID('null'), ref );
executeAction( app.charIDToTypeID('slct'), desc, DialogModes.NO );
////////freeform pentool
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( app.stringIDToTypeID('freeformPenTool') );
desc.putReference( app.charIDToTypeID('null'), ref );
executeAction( app.charID
Copy link to clipboard
Copied
Have you tried using ScriptingListener.plugin to record the selection of the Tools in question?
Copy link to clipboard
Copied
This function gives the current tool.
function findCurrentTool(){
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var cTool = typeIDToStringID(executeActionGet(ref).getEnumerationType(stringIDToTypeID('tool')));
return cTool;
};
This function will select the tool.
function selectTool(tool) {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( app.stringIDToTypeID(tool) );
desc.putReference( app.charIDToTypeID('null'), ref );
executeAction( app.charIDToTypeID('slct'), desc, DialogModes.NO );
};
Copy link to clipboard
Copied
I add this command JSX, Native Extension Bulder 3
$ ._ = {Ext_frm09
run: function () {
/ ********** Replace sample code below with your own JSX code ********** /
selectTool (tool) function {
var desc = new ActionDescriptor ();
var ref = new ActionReference ();
ref.putClass (app.stringIDToTypeID (tool));
desc.putReference (app.charIDToTypeID ('null'), ref);
ExecuteAction (app.charIDToTypeID ('SLCT'), desc, DialogModes.NO);
};
/ ************************************************* *********************** /
return appName;
},
};
Before I had put the code generated by ScriptingListener.plugin
I did a test here and in both situations aparceu me the following message image:
Copy link to clipboard
Copied
You have 'SLCT" in uppercase this is incorrect it should be lowercase.
As an example.
#target photoshop;
alert(findCurrentTool());
selectTool('sliceSelectTool');
function findCurrentTool(){
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var cTool = typeIDToStringID(executeActionGet(ref).getEnumerationType(stringIDToTypeID('tool')));
return cTool;
};
function selectTool(tool) {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( app.stringIDToTypeID(tool) );
desc.putReference( app.charIDToTypeID('null'), ref );
executeAction( app.charIDToTypeID('slct'), desc, DialogModes.NO );
};
Copy link to clipboard
Copied
SuperMerlin You as always very atensioso thank you!
Forgive my lack of knowledge about programming. JSX is too compricado for me. To simplify I just wanted to know the scripts of each of these tools for me sitados. Example: What is the command to call the pen tool? For you to understand my question when I want some script any Photoshop menu, we refer to Adobe Configurator and select a particular menu and identify your code (script) through the attributes of the menu in question and that selected scripit I add to arquivo.jsx model generated by Builder extension. Thank you!
This is only an example to better understand my question, the scripts I need are some tools.
Copy link to clipboard
Copied
Hope these help....
/////// Pentool
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( app.stringIDToTypeID('penTool') );
desc.putReference( app.charIDToTypeID('null'), ref );
executeAction( app.charIDToTypeID('slct'), desc, DialogModes.NO );
////////freeform pentool
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( app.stringIDToTypeID('freeformPenTool') );
desc.putReference( app.charIDToTypeID('null'), ref );
executeAction( app.charIDToTypeID('slct'), desc, DialogModes.NO );
//////////Add anchor point tool
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( app.stringIDToTypeID('addKnotTool') );
desc.putReference( app.charIDToTypeID('null'), ref );
executeAction( app.charIDToTypeID('slct'), desc, DialogModes.NO );
//////////Delete anchor point tool
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( app.stringIDToTypeID('deleteKnotTool') );
desc.putReference( app.charIDToTypeID('null'), ref );
executeAction( app.charIDToTypeID('slct'), desc, DialogModes.NO );
//////////rectangular marquee tool
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( app.stringIDToTypeID('marqueeRectTool') );
desc.putReference( app.charIDToTypeID('null'), ref );
executeAction( app.charIDToTypeID('slct'), desc, DialogModes.NO );
//////////Elliptical Marquee Tool
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( app.stringIDToTypeID('marqueeEllipTool') );
desc.putReference( app.charIDToTypeID('null'), ref );
executeAction( app.charIDToTypeID('slct'), desc, DialogModes.NO );
//////////Polygonal Lasso Tool
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( app.stringIDToTypeID('polySelTool') );
desc.putReference( app.charIDToTypeID('null'), ref );
executeAction( app.charIDToTypeID('slct'), desc, DialogModes.NO );
//////////Magnetic Lasso Tool
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( app.stringIDToTypeID('magneticLassoTool') );
desc.putReference( app.charIDToTypeID('null'), ref );
executeAction( app.charIDToTypeID('slct'), desc, DialogModes.NO );
Copy link to clipboard
Copied
Now yes, perfect!
Vc is the greatest!
Again thank you my brother .. A big hug.
Copy link to clipboard
Copied
Please could you send me some I forgot. Lasso tool, gradient tool and Custom shape tool.
In the future I will add new tools on other projects, it would be possible adiquir a list with only the id so that I can replace only the script ??
Thank you!
Copy link to clipboard
Copied
////Lasso tool
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( app.stringIDToTypeID('lassoTool') );
desc.putReference( app.charIDToTypeID('null'), ref );
executeAction( app.charIDToTypeID('slct'), desc, DialogModes.NO );
////gradient tool
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( app.stringIDToTypeID('gradientTool') );
desc.putReference( app.charIDToTypeID('null'), ref );
executeAction( app.charIDToTypeID('slct'), desc, DialogModes.NO );
////Custom shape tool
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( app.stringIDToTypeID('customShapeTool') );
desc.putReference( app.charIDToTypeID('null'), ref );
executeAction( app.charIDToTypeID('slct'), desc, DialogModes.NO );
///////////////////////////////////////////////
/////This will give you the tool name of the selected tool
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
alert(typeIDToStringID(executeActionGet(ref).getEnumerationType(stringIDToTypeID('tool'))));
Copy link to clipboard
Copied
SuperMerlin, thanks again! A hug.
Copy link to clipboard
Copied
This may help too, from the archive of the PS-Scripts forum I personally miss so much:
ps-scripts.com • View topic - Select tool list
HTH,
--Mikaeru
Copy link to clipboard
Copied
Mikaeru 69, thank you for sharing the link! Always I add my favorite ferrementas in my panels and this will help me a lot. A hug my friend.