Is it possible to change Brush Mode via Scripting?

Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General

Moderators: Tom, Kukurykus

Dukal
Posts: 1
Joined: Mon Aug 01, 2016 5:54 pm

Is it possible to change Brush Mode via Scripting?

Post by Dukal »

I found pretty useful to use any PS Brush as an Eraser just changing its Mode to Clear,
the adventage over changing to the Eraser Tool is that this way the same Brush I'm actually using is transformed into an eraser,
but I couldn't find a way to assign that Brush Mode to a Shortcut Key.
Changing the Brush Mode isn't recorded in an Action
and I couldn't even make it work using the ScriptListener.
so... is it possible?

Thx in advance.
User avatar
txuku
Posts: 136
Joined: Thu Jan 01, 1970 12:00 am

Re: Is it possible to change Brush Mode via Scripting?

Post by txuku »

Bonjour

I have three scripts that may be suitable for you :

SelectOutil.jsx

Code: Select all

//SelectOutil.jsx

selectTool('moveTool');

selectTool('artBrushTool'); //magicStampTool

//selectTool('marqueeRectTool');
//selectTool('marqueeEllipTool');
//selectTool('marqueeSingleRowTool');
//selectTool('marqueeSingleColumnTool');
//selectTool('lassoTool');
//selectTool('polySelTool');
//selectTool('magneticLassoTool');
//selectTool('quickSelectTool');
//selectTool('magicWandTool');
//selectTool('cropTool');
//selectTool('sliceTool');
//selectTool('sliceSelectTool');
//selectTool('spotHealingBrushTool');
//selectTool('magicStampTool');
//selectTool('patchSelection');
//selectTool('redEyeTool');
//selectTool('paintbrushTool');
//selectTool('pencilTool');
//selectTool('colorReplacementBrushTool');
//selectTool('cloneStampTool');
//selectTool('patternStampTool');
//selectTool('historyBrushTool');
//selectTool('artBrushTool');
//selectTool('eraserTool');
//selectTool('backgroundEraserTool');
//selectTool('magicEraserTool');
//selectTool('gradientTool');
//selectTool('bucketTool');
//selectTool('blurTool');
//selectTool('sharpenTool');
//selectTool('smudgeTool');
//selectTool('dodgeTool');
//selectTool('burnInTool');
//selectTool('saturationTool');
//selectTool('penTool');
//selectTool('freeformPenTool');
//selectTool('addKnotTool');
//selectTool('deleteKnotTool');
//selectTool('convertKnotTool');
//selectTool('typeCreateOrEditTool');
//selectTool('typeVerticalCreateOrEditTool');
//selectTool('typeCreateMaskTool');
//selectTool('typeVerticalCreateMaskTool');
//selectTool('pathComponentSelectTool');
//selectTool('directSelectTool');
//selectTool('rectangleTool');
//selectTool('roundedRectangleTool');
//selectTool('ellipseTool');
//selectTool('polygonTool');
//selectTool('lineTool');
//selectTool('customShapeTool');
//selectTool('textAnnotTool');
//selectTool('soundAnnotTool');
//selectTool('eyedropperTool');
//selectTool('colorSamplerTool');
//selectTool('rulerTool');
//selectTool('handTool');
//selectTool('zoomTool');


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 );
}
ChercheOutil.jsx

Code: Select all

//Chris Whitaker
//www.Funkybunnies3d.com
//
//simply cycle through a few important tools,
//you can edit this by checking the list of tools at the bottom
//
//PaulMR did most of this work, I just set it up to cycle through... which was only a few lines, so big thanks to him!

if (findCurrentTool() == 'paintbrushTool')
selectTool('eraserTool');
else if (findCurrentTool() == 'eraserTool')
selectTool('paintbrushTool');
//you can add more cases here if you want a bigger list to cycle through



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 findCurrentTool(){
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var cTool = typeIDToStringID( executeActionGet(ref).getEnumerationType(stringIDToTypeID('tool')) );
//alert(cTool)
return cTool;
};

/*
var cTool1 = "";
findCurrentTool(cTool1)
alert(findCurrentTool(cTool1))
*/
var cTool1 = findCurrentTool();
alert( cTool1 );
ChercheOutil_FR.jsx

Code: Select all

//ChercheOutil_FR.jsx

//Chris Whitaker
//www.Funkybunnies3d.com
//
//simply cycle through a few important tools,
//you can edit this by checking the list of tools at the bottom
//
//PaulMR did most of this work, I just set it up to cycle through... which was only a few lines, so big thanks to him!

/* .................. */

//Simplifie par moi : trouver l outil en cours

function findCurrentTool(){
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var cTool = typeIDToStringID( executeActionGet(ref).getEnumerationType(stringIDToTypeID('tool')) );
return cTool;
};

var cToolAngl = findCurrentTool();
//alert( cToolFranc );
var cToolFranc = cToolAngl //cToolFranc


switch ( cToolFranc )
{

case 'moveTool':
cToolFranc = 'Outil Deplacement';
break;

default:
cToolFranc = 'Outil INDEFINI';

case 'marqueeRectTool':
cToolFranc = 'Outil Rectangle de selection';
break;

case 'marqueeEllipTool':
cToolFranc = 'Outil Ellipse de selection';
break;

case 'marqueeSingleRowTool':
cToolFranc = 'Outil Rectangle de selection 1 rangee';
break;

case 'marqueeSingleColumnTool':
cToolFranc = 'marqueeSingleColumnTool';
break;

case 'lassoTool':
cToolFranc = 'Outil Lasso';
break;

case 'polySelTool':
cToolFranc = 'Outil Lasso polygonal';
break;

case 'magneticLassoTool':
cToolFranc = 'Outil Lasso magnetique';
break;

case 'quickSelectTool':
cToolFranc = 'Outil Selection rapide';
break;

case 'magicWandTool':
cToolFranc = 'Outil Baguette magique';
break;

case 'cropTool':
cToolFranc = 'Outil Recadrage';
break;

case 'sliceTool':
cToolFranc = 'Outil Tranche';
break;

case 'sliceSelectTool':
cToolFranc = 'Outil Selection de tranche';
break;

case 'eyedropperTool':
cToolFranc = 'Outil Pipette';
break;

case 'colorSamplerTool':
cToolFranc = 'Outil Echantillonnage de couleur';
break;

case 'rulerTool':
cToolFranc = 'Outil Regle';
break;

case 'textAnnotTool':
cToolFranc = 'Outil Annotation';
break;

case 'countTool':
cToolFranc = 'Outil Comptage';
break;

case 'spotHealingBrushTool':
cToolFranc = 'Outil Correcteur localise';
break;

case 'magicStampTool':
cToolFranc = 'Outil Correcteur';
break;

case 'patchSelection':
cToolFranc = 'Outil Piece';
break;

case 'redEyeTool':
cToolFranc = 'Outil Œil rouge';
break;

case 'paintbrushTool':
cToolFranc = 'Outil Pinceau';
break;

case 'pencilTool':
cToolFranc = 'Outil Crayon';
break;

case 'colorReplacementBrushTool':
cToolFranc = 'Outil Remplacement de couleur';
break;

case 'wetBrushTool':
cToolFranc = 'Outil Pinceau melangeur';
break;

case 'cloneStampTool':
cToolFranc = 'Outil Tampon de duplication';
break;

case 'patternStampTool':
cToolFranc = 'Outil Tampon de motif';
break;

case 'historyBrushTool':
cToolFranc = 'Outil Forme d historique';
break;

case 'artBrushTool':
cToolFranc = 'Outil Forme d historique artistique';
break;

case 'eraserTool':
cToolFranc = 'Outil Gomme';
break;

case 'backgroundEraserTool':
cToolFranc = 'Outil Gomme d arriere-plan';
break;

case 'magicEraserTool':
cToolFranc = 'Outil Gomme magique';
break;

case 'gradientTool':
cToolFranc = 'Outil Degrade';
break;

case 'bucketTool':
cToolFranc = 'Outil Pot de peinture';
break;

case 'blurTool':
cToolFranc = 'Outil Goutte d eau';
break;

case 'sharpenTool':
cToolFranc = 'Outil Nettete';
break;

case 'smudgeTool':
cToolFranc = 'Outil Doigt';
break;

case 'dodgeTool':
cToolFranc = 'Outil Densite -';
break;

case 'burnInTool':
cToolFranc = 'Outil Densite +';
break;

case 'saturationTool':
cToolFranc = 'Outil Eponge';
break;

case 'penTool':
cToolFranc = 'Outil Plume';
break;

case 'freeformPenTool':
cToolFranc = 'Outil Plume libre';
break;

case 'addKnotTool':
cToolFranc = 'Outil Ajout de point d ancrage' ;
break;

case 'deleteKnotTool':
cToolFranc = 'Outil Suppression de point d ancrage';
break;

case 'convertKnotTool':
cToolFranc = 'Outil Conversion de point';
break;

case 'typeCreateOrEditTool':
cToolFranc = 'Outil Texte horizontal';
break;

case 'typeVerticalCreateOrEditTool':
cToolFranc = 'Outil Texte vertical';
break;

case 'typeCreateMaskTool':
cToolFranc = 'Outil Masque de texte horizontal';
break;

case 'typeVerticalCreateMaskTool':
cToolFranc = 'Outil Masque de texte vertical';
break;

case 'pathComponentSelectTool':
cToolFranc = 'Outil Selection de trace';
break;

case 'directSelectTool':
cToolFranc = 'Outil Selection directe';
break;

case 'rectangleTool':
cToolFranc = 'Outil Rectangle';
break;

case 'roundedRectangleTool':
cToolFranc = 'Outil Rectangle arrondi';
break;

case 'ellipseTool':
cToolFranc = 'Outil Ellipse';
break;

case 'polygonTool':
cToolFranc = 'Outil Polygone';
break;

case 'lineTool':
cToolFranc = 'Outil Trait';
break;

case 'customShapeTool':
cToolFranc = 'Outil Forme personnalisee';
break;

case 'soundAnnotTool':
cToolFranc = 'Outil Annotation audio';
break;

case 'handTool':
cToolFranc = 'Outil Main';
break;

case 'rotateTool':
cToolFranc = 'Outil Rotation de l affichage';
break;

case 'zoomTool':
cToolFranc = 'Outil Zoom';
break;



}

alert( cToolAngl );
alert( cToolFranc );

//selectTool('moveTool'); = 'Outil Deplacement'
//selectTool('marqueeRectTool'); = 'Outil Rectangle de selection'
//selectTool('marqueeEllipTool'); = 'Outil Ellipse de selection'
//selectTool('marqueeSingleRowTool'); = 'Outil Rectangle de selection 1 rangee'
//selectTool('marqueeSingleColumnTool'); = 'Outil Rectangle de selection 1 colonne'
//selectTool('lassoTool'); = 'Outil Lasso'
//selectTool('polySelTool'); = 'Outil Lasso polygonal'
//selectTool('magneticLassoTool'); = 'Outil Lasso magnetique'
//selectTool('quickSelectTool'); = 'Outil Selection rapide'
//selectTool('magicWandTool'); = 'Outil Baguette magique'
//selectTool('cropTool'); = 'Outil Recadrage'
//selectTool('sliceTool'); = 'Outil Tranche'
//selectTool('sliceSelectTool'); = 'Outil Selection de tranche'
//selectTool('eyedropperTool'); = 'Outil Pipette'
//selectTool('colorSamplerTool'); = 'Outil Echantillonnage de couleur'
//selectTool('rulerTool'); = 'Outil Regle'
//selectTool('textAnnotTool'); = 'Outil Annotation'
//selectTool('countTool'); = 'Outil Comptage'
//selectTool('spotHealingBrushTool'); = 'Outil Correcteur localise'
//selectTool('magicStampTool'); = 'Outil Correcteur'
//selectTool('patchSelection'); = 'Outil Piece'
//selectTool('redEyeTool'); = 'Outil Œil rouge'
//selectTool('paintbrushTool'); = 'Outil Pinceau'
//selectTool('pencilTool'); = 'Outil Crayon'
//selectTool('colorReplacementBrushTool'); = 'Outil Remplacement de couleur'
//selectTool('wetBrushTool'); = 'Outil Pinceau melangeur'
//selectTool('cloneStampTool'); = 'Outil Tampon de duplication'
//selectTool('patternStampTool'); = 'Outil Tampon de motif'
//selectTool('historyBrushTool'); = 'Outil Forme d historique'
//selectTool('artBrushTool'); = 'Outil Forme d historique artistique'
//selectTool('eraserTool'); = 'Outil Gomme'
//selectTool('backgroundEraserTool'); = 'Outil Gomme d arriere-plan'
//selectTool('magicEraserTool'); = 'Outil Gomme magique'
//selectTool('gradientTool'); = 'Outil Degrade'
//selectTool('bucketTool'); = 'Outil Pot de peinture'
//selectTool('blurTool'); = 'Outil Goutte d eau'
//selectTool('sharpenTool'); = 'Outil Nettete'
//selectTool('smudgeTool'); = 'Outil Doigt'
//selectTool('dodgeTool'); = 'Outil Densite -'
//selectTool('burnInTool'); = 'Outil Densite +'
//selectTool('saturationTool'); = 'Outil Eponge'
//selectTool('penTool'); = 'Outil Plume'
//selectTool('freeformPenTool'); = 'Outil Plume libre'
//selectTool('addKnotTool'); = 'Outil Ajout de point d ancrage'
//selectTool('deleteKnotTool'); = 'Outil Suppression de point d ancrage'
//selectTool('convertKnotTool'); = 'Outil Conversion de point'
//selectTool('typeCreateOrEditTool'); = 'Outil Texte horizontal'
//selectTool('typeVerticalCreateOrEditTool'); = 'Outil Texte vertical'
//selectTool('typeCreateMaskTool'); = 'Outil Masque de texte horizontal'
//selectTool('typeVerticalCreateMaskTool'); = 'Outil Masque de texte vertical'
//selectTool('pathComponentSelectTool'); = 'Outil Selection de trace'
//selectTool('directSelectTool'); = 'Outil Selection directe'
//selectTool('rectangleTool'); = 'Outil Rectangle'
//selectTool('roundedRectangleTool'); = 'Outil Rectangle arrondi'
//selectTool('ellipseTool'); = 'Outil Ellipse'
//selectTool('polygonTool'); = 'Outil Polygone'
//selectTool('lineTool'); = 'Outil Trait'
//selectTool('customShapeTool'); = 'Outil Forme personnalisee'
//selectTool('soundAnnotTool'); = 'Outil Annotation audio' // n existe pas dans version
//selectTool('handTool'); = 'Outil Main'
//selectTool('rotateTool'); = 'Outil Rotation de l affichage'
//selectTool('zoomTool'); = 'Outil Zoom'
I do not know who is the author ..............

Paul MR Mike Hale ???

Look at Chris Whitaker - www.Funkybunnies3d.com