Skip to main content
Peter James Zielinski
Known Participant
May 9, 2022
Answered

Is there a way to assign a keyboard shortcut to the "Aligned" checkbox toggle for the Clone Stamp?

  • May 9, 2022
  • 4 replies
  • 3473 views

Looking for a way to possibly assign a keyboard shortcut to toggle "Aligned" on/off when I'm using my Clone Stamp.  I've scoured the menus and did an exhaustive search of the shortcuts and menu options but maybe I've missed it?  ...or it's not possible?

 

If it's not possible, no big deal. My solution to the problem was to create a series of Brush Presets with all the tool info in them and that's fine...but I use a 32-button device for hotkeys/macros/multiple actions that speeds up my workflow like mad. It'd be great to be able to hit the toggle button with my pinky while continuing to clone uninterrupted. 

 

If anyone has any insight, I'd appreciate it!

 

Currently using 23.3.1 and Beta 23.4.0

This topic has been closed for replies.
Correct answer c.pfaffenbichler

Please try this one … 

// thanks to Oleksii Hirlin;
// switch aligned-setting for clone stamp tool;
// 2022, use it at your own risk;
if (getCurrentTool() == "cloneStampTool") {
var ref = new ActionReference();
ref.putProperty(stringIDToTypeID('property'), stringIDToTypeID("currentToolOptions"));
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
var applicationDesc = executeActionGet(ref);
var currentToolS = applicationDesc.getObjectValue(stringIDToTypeID("currentToolOptions"));
var theAlign = currentToolS.getBoolean(1400139073);
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( stringIDToTypeID( app.currentTool ) );
desc.putReference( stringIDToTypeID( "target" ), ref );
//////
if (theAlign == true) {
currentToolS.putBoolean(1400139073, false)
} else {
currentToolS.putBoolean(1400139073, true)
};
//////
desc.putObject( stringIDToTypeID( "to" ), stringIDToTypeID( "currentToolOptions" ), currentToolS );
executeAction( stringIDToTypeID( "set" ), desc, DialogModes.NO );
};
////////////////////////////////////
function getCurrentTool() {
	var ref = new ActionReference(); 
	ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
	return typeIDToStringID(executeActionGet(ref).getEnumerationType(stringIDToTypeID('tool')));
	};

4 replies

Kukurykus
Legend
May 11, 2022

 

currentTool = 'cloneStampTool'
cTT = charIDToTypeID, sTT = stringIDToTypeID;
(r1 = new ActionReference()).putProperty(sTT('property'), t = sTT('tool'))
r1.putClass(sTT('application')); typeIDToStringID((d1 = executeActionGet(r1))
.getEnumerationType(t))&&((r2=new ActionReference()).putClass(sTT(currentTool)),
cto = (d2 = executeActionGet(r1)).getObjectValue(sTT('currentToolOptions')),
d2.putBoolean(algn = cTT('StmA'), !cto.getBoolean(algn)),
d1.putReference(nul = sTT('null'), r2),
d1.putObject(sTT('to'), nul, d2),
executeAction(sTT('set'), d1))

 

Peter James Zielinski
Known Participant
May 11, 2022

An even quicker response when switching between toggle states. Thanks for this!

c.pfaffenbichler
Community Expert
c.pfaffenbichlerCommunity ExpertCorrect answer
Community Expert
May 10, 2022

Please try this one … 

// thanks to Oleksii Hirlin;
// switch aligned-setting for clone stamp tool;
// 2022, use it at your own risk;
if (getCurrentTool() == "cloneStampTool") {
var ref = new ActionReference();
ref.putProperty(stringIDToTypeID('property'), stringIDToTypeID("currentToolOptions"));
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
var applicationDesc = executeActionGet(ref);
var currentToolS = applicationDesc.getObjectValue(stringIDToTypeID("currentToolOptions"));
var theAlign = currentToolS.getBoolean(1400139073);
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( stringIDToTypeID( app.currentTool ) );
desc.putReference( stringIDToTypeID( "target" ), ref );
//////
if (theAlign == true) {
currentToolS.putBoolean(1400139073, false)
} else {
currentToolS.putBoolean(1400139073, true)
};
//////
desc.putObject( stringIDToTypeID( "to" ), stringIDToTypeID( "currentToolOptions" ), currentToolS );
executeAction( stringIDToTypeID( "set" ), desc, DialogModes.NO );
};
////////////////////////////////////
function getCurrentTool() {
	var ref = new ActionReference(); 
	ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
	return typeIDToStringID(executeActionGet(ref).getEnumerationType(stringIDToTypeID('tool')));
	};
Peter James Zielinski
Known Participant
May 10, 2022

Winner winner chicken dinner! 

 

This did it. I'm not sure what differed from the original (went back and tried and it still doesn't work). But the above version instantly worked...was able to record it into an Action and then turn it into a one-button press on my Stream Deck. 

 

Thank you so much for your work and all your help. Beyond appreciated. 🙂 

Stephen Marsh
Community Expert
Community Expert
May 10, 2022

@Peter James Zielinski – is there a specific reason to record the script into an Action? I haven't used a Stream Deck. Keyboard shortcuts can be applied directly to installed scripts without having to put them into an action for use with an F-Key.

c.pfaffenbichler
Community Expert
Community Expert
May 10, 2022

You could try this Script. 

Edit: Removed the Script because it did not work as intended

 

 

Peter James Zielinski
Known Participant
May 10, 2022

This is giving me hope!  Right off the bat, the above script isn't working but this is probably user error...I know nothing of scripting outside of poking around in a .JSX file and getting it to the proper directory.  Is the snippet you posted above missing a function or anything to run it / end it? 

 

Decided to do a few tests and went down a rabbit hole of the author mentioned inside the script. I was able to use his Switch Sample Mode script successfully and to great effect. (and so excited I found this through you, so thank you!)

 

Appreciate your time and patience. 

c.pfaffenbichler
Community Expert
Community Expert
May 10, 2022

What error message do you get? 

Works fine here for the Clone Stamp Tool. 

Bojan Živković11378569
Community Expert
Community Expert
May 10, 2022

I do not know for any option to assign keyboard shortcut nor is possible using Photoshop action to record as action step as far as I know. Maybe script can do the trick. Script can be run using shortcut but... you need script in  first place. @Stephen Marsh @c.pfaffenbichler @Kukurykus 

Stephen Marsh
Community Expert
Community Expert
May 10, 2022

Not that I am aware of, however, saving a tool preset would be my suggestion. One can then assign a F-key action keyboard shortcut or play the action from a script (or directly script the tool preset) with a more flexible shortcut.