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

Are these Photoshop script ideas possible?

Community Beginner ,
Jul 11, 2024 Jul 11, 2024

Hello, I'm looking to get into photoshop scripting but was curious if my ideas are even possible to begin with.
What I'd like to make:


- a hotkey for a specific brush
- a hotkey for alternating between two brush flow settings (e.g. press once = brush flow 20%, press twice = 80%, press again = back to 20%)


Thank you!

TOPICS
Scripting
193
Translate
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 2 Correct answers

Community Expert , May 24, 2025 May 24, 2025

@ryank45859795 wrote:

- a hotkey for alternating between two brush flow settings (e.g. press once = brush flow 20%, press twice = 80%, press again = back to 20%)


// set brush tool to either 80% or 20% flow;
// 2025, use it at your own risk;
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
var applicationDesc = executeActionGet(ref);
var theTool = typeIDToStringID(applicationDesc.getEnumerationType(stringIDToTypeID
...
Translate
Community Expert , May 24, 2025 May 24, 2025
quote

- a hotkey for a specific brush

AM code can be used to select a brush by name. 

To avoid problems when the brush is absent one may want to wrap it in a try-clause. 

// =======================================================
var idselect = stringIDToTypeID( "select" );
    var desc4 = new ActionDescriptor();
    var idnull = stringIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idbrush = stringIDToTypeID( "brush" );
        ref1.putName( idbrush, "Hard Round 123
...
Translate
Community Expert ,
May 24, 2025 May 24, 2025

@ryank45859795 wrote:

- a hotkey for alternating between two brush flow settings (e.g. press once = brush flow 20%, press twice = 80%, press again = back to 20%)


// set brush tool to either 80% or 20% flow;
// 2025, use it at your own risk;
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
var applicationDesc = executeActionGet(ref);
var theTool = typeIDToStringID(applicationDesc.getEnumerationType(stringIDToTypeID("tool")));
if (theTool == "paintbrushTool") {
var theCurrentToolOptions = applicationDesc.getObjectValue(stringIDToTypeID("currentToolOptions"));
var theFlow = theCurrentToolOptions.getInteger(stringIDToTypeID("flow"));
switch (theFlow) {
case 80:
setBrushToolFlow(20);
break;
case 20:
setBrushToolFlow(80);
break;
default:
setBrushToolFlow(80);
break;
};
};
////////////////////////////////////
function setBrushToolFlow (theFlow) {
(r = new ActionReference()).putProperty(stringIDToTypeID('property'), p = stringIDToTypeID('currentToolOptions'));
r.putEnumerated(stringIDToTypeID('application'), stringIDToTypeID('ordinal'), stringIDToTypeID('targetEnum'));
var tool = executeActionGet(r).getObjectValue(p);
if (tool.hasKey(stringIDToTypeID('brush'))) {
tool.putUnitDouble( stringIDToTypeID( "flow" ), stringIDToTypeID( "percentUnit" ), theFlow );
(r = new ActionReference()).putClass(stringIDToTypeID(currentTool));
(d = new ActionDescriptor()).putReference(stringIDToTypeID("target"), r);
d.putObject(stringIDToTypeID("to"), stringIDToTypeID("target"), tool);
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
};
};
////////////////////////////////////

 

Translate
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 Expert ,
May 24, 2025 May 24, 2025
LATEST
quote

- a hotkey for a specific brush

AM code can be used to select a brush by name. 

To avoid problems when the brush is absent one may want to wrap it in a try-clause. 

// =======================================================
var idselect = stringIDToTypeID( "select" );
    var desc4 = new ActionDescriptor();
    var idnull = stringIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idbrush = stringIDToTypeID( "brush" );
        ref1.putName( idbrush, "Hard Round 123 1083" );
    desc4.putReference( idnull, ref1 );
executeAction( idselect, desc4, DialogModes.NO );

 

Translate
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