Skip to main content
DBarranca
Legend
October 30, 2016
Answered

ActionManager: Auto-Select layer in the Move tool

  • October 30, 2016
  • 2 replies
  • 1825 views

Hi,

I'm trying to switch true/false the Auto-Select option in the Move Tool.

Which seems to be buried in the "currentToolOptions", as the "AtSl" CharID:

var ref = new ActionReference ();

ref.putEnumerated (stringIDToTypeID ("application"), stringIDToTypeID ("ordinal"), stringIDToTypeID ("targetEnum"));

var appDesc = executeActionGet(ref)

var currentToolOptions = appDesc.getObjectValue (stringIDToTypeID ("currentToolOptions"));

$.writeln(currentToolOptions.getBoolean(charIDToTypeID('AtSl'))); // true or false

I've tried the following (extract the actual currentToolOptions descriptor, then set it in the application), to no avail:

var ref = new ActionReference ();

ref.putEnumerated (stringIDToTypeID ("application"), stringIDToTypeID ("ordinal"), stringIDToTypeID ("targetEnum"));

var appDesc = executeActionGet(ref)

var currentToolOptions = appDesc.getObjectValue (stringIDToTypeID ("currentToolOptions"));

$.writeln(currentToolOptions.getBoolean(charIDToTypeID('AtSl')));

// Setting true

currentToolOptions.putBoolean(charIDToTypeID('AtSl'), true)

var desc = new ActionDescriptor(); 

var ref = new ActionReference();

ref.putEnumerated( stringIDToTypeID( "currentToolOptions" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) ); 

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

desc.putObject( stringIDToTypeID('to'), stringIDToTypeID( "currentToolOptions" ), currentToolOptions ); 

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

General Photoshop error, blabla.

Where am I wrong? The usual suspect who finds solutions to my AM code is Mikaeru69​ 🙂 but anyone contribution is more than welcome.

Thank you!

Davide

This topic has been closed for replies.
Correct answer DBarranca

Tom Ruark​, I didn't know you have a repository on GitHub, immediately starred :-)

I've been able to borrow code from the example you pointed me to, and in fact the solution is much simpler than I thought:

    var d = new ActionDescriptor();

    var r = new ActionReference();

    r.putClass(stringIDToTypeID("moveTool"))

    d.putReference(stringIDToTypeID("null"), r);

    var d2 = new ActionDescriptor();

    d2.putBoolean(charIDToTypeID('AtSl'), true);

    d.putObject(stringIDToTypeID("to"),stringIDToTypeID("null"),d2)

    executeAction(stringIDToTypeID("set"),d,DialogModes.NO)

Thank you very much!!

Davide

2 replies

p2cobra
Participant
May 2, 2019

Everyone is making this too hard:

Select 'move' tool - "V" If you can't find it 'move' and 'artboard' share the V slot in your toolbox.

Check the box to auto-select layer/group.

Un-check the box to 'Ctrl' select layer/group.

pixxxelschubser
Community Expert
Community Expert
May 2, 2019

Hi p2cobra​,

you are a new user. Welcome.

But:

Everyone here knows the manual way.

This is the scripting forum.

Please be sure that you are writing in the right forum and please don't hijack older threads.

Have fun

October 30, 2016

Hi Davide,

As far as I know, you can get the current tool options but unfortunately not set them, or at least I've always failed miserably although I tried many AM code combinations. You best shot indeed is probably to use tool presets...

Re: moveTool options

Re: changing crop tool settings with actiondescriptor code

HTH,

--The usual Mikaeru... ;-)

Tom Ruark
Inspiring
October 31, 2016

Get the SetPaintBrushOpacityAndOthers.jsx found here: GitHub - TomRuark/JavaScripts: All my JavaScripts

Each tool is different for the setting part but all the tools should respond to the get correctly. Let me know if you have trouble with the "set" on a particular tool and I'll try to work up an example.

DBarranca
DBarrancaAuthorCorrect answer
Legend
November 1, 2016

Tom Ruark​, I didn't know you have a repository on GitHub, immediately starred :-)

I've been able to borrow code from the example you pointed me to, and in fact the solution is much simpler than I thought:

    var d = new ActionDescriptor();

    var r = new ActionReference();

    r.putClass(stringIDToTypeID("moveTool"))

    d.putReference(stringIDToTypeID("null"), r);

    var d2 = new ActionDescriptor();

    d2.putBoolean(charIDToTypeID('AtSl'), true);

    d.putObject(stringIDToTypeID("to"),stringIDToTypeID("null"),d2)

    executeAction(stringIDToTypeID("set"),d,DialogModes.NO)

Thank you very much!!

Davide