• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Record "Tool Preset" Option to not use "Current Tool only"

Community Beginner ,
Dec 04, 2018 Dec 04, 2018

Copy link to clipboard

Copied

hey guys I can't find a way to record this option in Photoshop. I want my script to uncheck the checkbox in the image

I make Photoshop Extensions for other users and I was wondering if there's a way to add this automatically via Javascript, o the doesn't have to uncheck this option manually before running the script

thanks in advance

TOPICS
Actions and scripting

Views

642

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 04, 2018 Dec 04, 2018

A script can not changet the UI option the not itergace to to that and the Scriptlistener Plug-in records nothing when you do the manually. Therfore it cna not be recorder in an Action so the is noy way to use action manager code in a script to change the ui option.  All you can do in a script is to use action manager to select the tool you want to selet a tool preset for the select the tool preset you want to use.  The code is in my Cycle Tool Presets Package

/* =================================

...

Votes

Translate

Translate
Adobe
Community Expert ,
Dec 04, 2018 Dec 04, 2018

Copy link to clipboard

Copied

A script can not changet the UI option the not itergace to to that and the Scriptlistener Plug-in records nothing when you do the manually. Therfore it cna not be recorder in an Action so the is noy way to use action manager code in a script to change the ui option.  All you can do in a script is to use action manager to select the tool you want to selet a tool preset for the select the tool preset you want to use.  The code is in my Cycle Tool Presets Package

/* =================================================================================

              Cycling Forward and Backward through Sets of Tool Presets

=====================================================================================

2017  John J. McAssey (JJMack)

=====================================================================================

Naming Your Script so that it identify the tool and Presets Set will be helpful.

    Copy this script to a new Name for each set of presets you want to cycle through.

Run that script via shortcut keys. Set two Shortcuts keys

F(n) Forward  Modifier+F(n) Backward

There are three required parameters for the cycling function:

1.) Correct Photoshop Tools Name

2.) Presets Set file name the * part of the *.tpl file

The *.tpl file must reside in the scripts folder

3.) Array of preset names in your desired cycling order

=====================================================================================

Note: This script only deals with Tool Preset files .tpl for tools preset are easily

reset back to Adobe's defaults using the Preset manager. Tool presets may require

other Photoshop add-ons like brush .abr, patterns .pat, swatch .aco, etc files to

also be loaded this script will not load them this script will only load .tpl

files if there is a need too. You must add what your presets require to Photoshop

================================================================================== */

// =================================================== Main function ======================================================== //

function cycleTool(toolName,toolPresetSet,toolPresetNames){ // alert("CycleTool");

if (currentToolName()!=toolName) { // if user is switching tools try to else switch tool preset

try {selectTool(toolName);} // Insure the tool is select so preset can be selected

catch(e) {alert("Unable to Select the Tool "+toolName); return;} // Tool name wrong or unavailable

if (app.toolSupportsBrushes(app.currentTool)) app.runMenuItem(charIDToTypeID(('TglB'))); //Toggle Brush Palette

return; // Just switch to the tools current setting

}

var desc = new ActionDescriptor(); // Set up Photoshop to remember variables

try {var desc = app.getCustomOptions('Cycle'+toolPresetSet);} // Try to get CustomOption for cycling this tool presets set

catch(e){ // Each Photoshop session this should fail first time reset

try {selectToolPreset(toolPresetNames[0]);} // Insure Tool Presets Set has been loaded

catch(e) { // Will fail if tools presets set is not loaded

if (loadToolPresetSet(toolPresetSet)) { // Load Tool presets set

try {selectToolPreset(toolPresetNames[0]);} // Load sets first preset

catch(e) {alert("Was unable to Select the Tools Preset "+toolPresetNames[0]); return;} // Failed to select preset

}

else {alert("Was unable to load Tools Presets Set "+toolPresetSet); return;} // Failed to load tools presets set

}

desc.putInteger(0,0); // This line save the variable while Photoshop is open,

app.putCustomOptions('Cycle'+toolPresetSet,desc,false ); // Initialize presets set CustomOption for cycling

desc = app.getCustomOptions('Cycle'+toolPresetSet); // Get CustomOption Cycle starting point

    }

var presetNumber = desc.getInteger(0); // Get the preset index

if (ScriptUI.environment.keyboardState.ctrlKey||ScriptUI.environment.keyboardState.altKey||

ScriptUI.environment.keyboardState.shiftKey) { // Previous preset if Ctrl or Alt or Shift key is down

presetNumber = presetNumber-2; // Back up two preset for it will be bumped one

if (presetNumber<0){presetNumber=toolPresetNames.length-1;} // Set preset index to the end of the list

}

if (presetNumber<toolPresetNames.length){desc.putInteger(0,presetNumber+1);} // Update preset index number

else {presetNumber=0; desc.putInteger(0,1);} // Reset preset index pointer to the begging of the list

app.putCustomOptions('Cycle'+toolPresetSet,desc,false); // Put Update the Custom option

try {selectToolPreset(toolPresetNames[presetNumber]);} // Set tool with preset

catch(e) {

if (loadToolPresetSet(toolPresetSet)) { // Load Tool presets set Tool presets may have reset

try {selectToolPreset(toolPresetNames[presetNumber]);} // Set tool with preset

catch(e) {alert("Was unable to Select the Tools Preset "+toolPresetNames[presetNumber]); return;} // Failed to select

}

else {alert("Was unable to load Tools Presets Set "+toolPresetSet); return;} // Failed to load tools presets set

}

};

// =================================================== Helper functions ===================================================== //

function selectTool(tool) {

    var desc9 = new ActionDescriptor();

        var ref7 = new ActionReference();

        ref7.putClass( app.stringIDToTypeID(tool) );

    desc9.putReference( app.charIDToTypeID('null'), ref7 );

    executeAction( app.charIDToTypeID('slct'), desc9, DialogModes.NO );

};

function selectToolPreset(PresetName) {

var desc = new ActionDescriptor();

var ref = new ActionReference();

ref.putName( stringIDToTypeID( "toolPreset" ), PresetName );

desc.putReference( charIDToTypeID( "null" ), ref );

executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );

}

function loadToolPresetSet(SetName) {

returncode = true;

var scriptLocation = String(findScript());

var path = scriptLocation.substr(0, scriptLocation.lastIndexOf("/") + 1 ) ;

var SetFile = new File(path + SetName + ".tpl");   // Requited to be in the script's folder

if (!SetFile.exists) { returncode = false; }

else {

var desc = new ActionDescriptor();

var ref = new ActionReference();

ref.putProperty( charIDToTypeID( "Prpr" ), stringIDToTypeID( "toolPreset"  ));

ref.putEnumerated( charIDToTypeID( "capp" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt"  ) );

desc.putReference( charIDToTypeID( "null" ), ref );

desc.putPath( charIDToTypeID( "T   " ), new File( SetFile ) );

desc.putBoolean( charIDToTypeID( "Appe" ), true );

try {executeAction( charIDToTypeID( "setd" ), desc, DialogModes.NO );}

catch(e) { returncode = false; }

}

return returncode ;

}

function findScript() {// Find the location where this script resides

var where = "";

try { FORCEERROR = FORCERRROR;}

catch(err) { where = File(err.fileName);}

return where ;

}

function currentToolName() {

var ref = new ActionReference();

ref.putProperty(stringIDToTypeID("property"), stringIDToTypeID("tool"));

ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

var applicationDesc = executeActionGet(ref);

//alert(typeIDToStringID(applicationDesc.getEnumerationType(stringIDToTypeID("tool"))));

return(typeIDToStringID(applicationDesc.getEnumerationType(stringIDToTypeID("tool"))));

}

/* Photoshop tool names

'moveTool'                     'cloneStampTool'            'typeCreateOrEditTool'            'artboardTool'

'marqueeRectTool'              'patternStampTool'          'typeVerticalCreateOrEditTool'    'perspectiveCropTool'

'marqueeEllipTool'             'historyBrushTool'          'typeCreateMaskTool'              'eyedropperTool'             

'marqueeSingleRowTool'         'artBrushTool'              'typeVerticalCreateMaskTool'      '3DMaterialSelectTool'

'marqueeSingleColumnTool'      'eraserTool'                'pathComponentSelectTool'

'lassoTool'                    'backgroundEraserTool'      'directSelectTool'

'polySelTool'                  'magicEraserTool'           'rectangleTool'

'magneticLassoTool'            'gradientTool'              'roundedRectangleTool'

'quickSelectTool'              'bucketTool'                'ellipseTool'

'magicWandTool'                'blurTool'                  'polygonTool'

'cropTool'                     'sharpenTool'               'lineTool'

'sliceTool'                    'smudgeTool'                'customShapeTool'

'sliceSelectTool'              'dodgeTool'                 'textAnnotTool'

'spotHealingBrushTool'         'burnInTool'                'soundAnnotTool'

'magicStampTool'               'saturationTool'            'eyedropperTool'

'patchSelection'               'penTool'                   'colorSamplerTool'

'redEyeTool'                   'freeformPenTool'           'rulerTool'

'paintbrushTool'               'addKnotTool'               'handTool'

'pencilTool'                   'deleteKnotTool'            'zoomTool'

'colorReplacementBrushTool'    'convertKnotTool'           'wetBrushTool'

*/

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 04, 2018 Dec 04, 2018

Copy link to clipboard

Copied

LATEST

thanks a lot JJMack for the prompt answer, is very cool that also the Tools can be loaded iif in the Scripts folder.
All useful infos!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines