[Photoshop] About the JavaScript layer lock

  • 1
  • Problem
  • Updated 4 months ago
  • (Edited)
Windows 10 Pro

Photoshop CC 19.0

Image layer in JavaScript, image pixels, location, overall, of locking down all ON to process after the

Because is was all rock in the layers Panel on OFF in the

Other transparency, image pixels, and position locks are all OFF I.

Want something here (I'd like to down the whole lock does not affect the lock image pixels, position, transparency) is.

Write the history.

We want to create a script to set the lock status of the selected layer in JavaScript and layer sets.

Then create a function such as the following,

// Function to set the lock status of the State-of-the-ordinary (image layer)

function LockCtlNormalLayer (NrlLayer, trPxLockSts, PxLockSts, PosLockSts, AllLockSts) {

// Start of processing

NrlLayer.transparentPixelsLocked = trPxLockSts; // Set the lock status of the transparency

NrlLayer.pixelsLocked = PxLockSts; // Set the lock status of the image pixels

Rllayer.positiolocked = PosLockSts; // Set the lock status of the position

NrlLayer.allLocked = AllLockSts; // Set the lock status of the entire

}

Image layer kept loading in an array named LayerList in advance to following in the above function

LockCtlNormalLayer (LayerList [0], true, true, true, true);

On transparency, image pixels, location, overall, the did all the lock state to ON.

Is the following code immediately after processing,

alert ("trPx:" + LayerList [0].transparentPixelsLocked + "\nPx:" + LayerList [0].pixelsLocked + "\nPos:" + LayerList [0].positionLocked + " nAll: "+ LayerList [0].allLocked);

The lock state of the image layer was confirmed,

trPx: true (transparent lock ON)

PX: true (ON the lock image pixels)

POS: true (position lock ON)

All: true (whole rock ON)

Had become.

Then made further processing according to the layers panel, layer the whole lock on since I was OFF to the

The other I have turned OFF all transparency, image pixels, position locking is (here in a mystery to solve).

For the same image layer on the layers panel or "lock layers" in, on the menu

(1) lock ON transparency

(2) ON the lock image pixels

(3) ON position locks

(4) ON the whole lock

The order ((1) → (4)), if after locking in the layers panel lock on the whole you OFF

Other transparency, image pixels, and position locks ON that remained.

The above function is for the same image layers

LockCtlNormalLayer (LayerList [0], true, true, true, false);

As a transparency, image pixels, position, for if the lock state to ON then went to turn OFF the lock on the whole

To see in the layers panel, and was ON the lock image pixels, position, transparency.

On the layers panel or "lock the layer" of of the can on the menu but not JavaScript? There is the question.

Processing time with JavaScript turn on whole lock, something within the Photoshop bug has also begun going on?.

Please inform me if there anyone here who knows who.

Best regards.
Photo of KFGX001

KFGX001

  • 3 Posts
  • 0 Reply Likes
  • help

Posted 4 months ago

  • 1
Photo of Max Johnson

Max Johnson, Champion

  • 400 Posts
  • 173 Reply Likes
Sorry I can't be of more help, but I am on my phone traveling.

You may need to use the Action Manager scripting in your Javascript. Look up how to use the "script listener" plugin to capture all of your photoshop actions in a log. Then go to photoshop and manually toggle every kind of lock. You will get different Javascript in the log that will be hard to read but does work.
Photo of KFGX001

KFGX001

  • 3 Posts
  • 0 Reply Likes
Dear Mr.Max Johnson

Thank you very much.
We verified using "script listener" plug-in.
First, for the image layer, we perform lock switching processing on the layer panel and immediately after acquiring log contents from "Scripting Listener JS.log"
I created JavaScript code.
Then, against the image layer (transparent part, image pixel, position, whole, all locked state is turned OFF)
We executed the created JavaScript code to turn on all the locked state of transparent part, image pixel, position, whole.
Immediately after seeing the layer panel, the whole lock of the image layer was turned on, so it turned off,
All other transparent parts, image pixels, and position lock are all OFF.

I will write more detailed content.

[Detailed verification content]
The content of the "Scripting Listener JS.log" file was cleared with the image layer (the transparent part, the image pixel, the position, the whole locked state of all have been turned off) selected.
After that, for the same image layer, on the layer panel,

Lock on transparency ON → Image pixel lock ON → Position lock ON → Overall lock ON → Overall lock OFF

In this order.
Here, the transparent part, the image pixel, and the lock of the position were all kept ON.

When checking the contents of the "ScriptingListenerJS.log" file at this point,

// =======================================================
var idapplyLocking = stringIDToTypeID( "applyLocking" );
    var desc1016 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref520 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref520.putEnumerated( idLyr, idOrdn, idTrgt );
    desc1016.putReference( idnull, ref520 );
    var idlayerLocking = stringIDToTypeID( "layerLocking" );
        var desc1017 = new ActionDescriptor();
        var idprotectTransparency = stringIDToTypeID( "protectTransparency" );
        desc1017.putBoolean( idprotectTransparency, true );
    var idlayerLocking = stringIDToTypeID( "layerLocking" );
    desc1016.putObject( idlayerLocking, idlayerLocking, desc1017 );
executeAction( idapplyLocking, desc1016, DialogModes.NO );

// =======================================================
var idapplyLocking = stringIDToTypeID( "applyLocking" );
    var desc1018 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref521 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref521.putEnumerated( idLyr, idOrdn, idTrgt );
    desc1018.putReference( idnull, ref521 );
    var idlayerLocking = stringIDToTypeID( "layerLocking" );
        var desc1019 = new ActionDescriptor();
        var idprotectTransparency = stringIDToTypeID( "protectTransparency" );
        desc1019.putBoolean( idprotectTransparency, true );
        var idprotectComposite = stringIDToTypeID( "protectComposite" );
        desc1019.putBoolean( idprotectComposite, true );
    var idlayerLocking = stringIDToTypeID( "layerLocking" );
    desc1018.putObject( idlayerLocking, idlayerLocking, desc1019 );
executeAction( idapplyLocking, desc1018, DialogModes.NO );

// =======================================================
var idapplyLocking = stringIDToTypeID( "applyLocking" );
    var desc1020 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref522 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref522.putEnumerated( idLyr, idOrdn, idTrgt );
    desc1020.putReference( idnull, ref522 );
    var idlayerLocking = stringIDToTypeID( "layerLocking" );
        var desc1021 = new ActionDescriptor();
        var idprotectTransparency = stringIDToTypeID( "protectTransparency" );
        desc1021.putBoolean( idprotectTransparency, true );
        var idprotectComposite = stringIDToTypeID( "protectComposite" );
        desc1021.putBoolean( idprotectComposite, true );
        var idprotectPosition = stringIDToTypeID( "protectPosition" );
        desc1021.putBoolean( idprotectPosition, true );
    var idlayerLocking = stringIDToTypeID( "layerLocking" );
    desc1020.putObject( idlayerLocking, idlayerLocking, desc1021 );
executeAction( idapplyLocking, desc1020, DialogModes.NO );

// =======================================================
var idapplyLocking = stringIDToTypeID( "applyLocking" );
    var desc1022 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref523 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref523.putEnumerated( idLyr, idOrdn, idTrgt );
    desc1022.putReference( idnull, ref523 );
    var idlayerLocking = stringIDToTypeID( "layerLocking" );
        var desc1023 = new ActionDescriptor();
        var idprotectAll = stringIDToTypeID( "protectAll" );
        desc1023.putBoolean( idprotectAll, true );
    var idlayerLocking = stringIDToTypeID( "layerLocking" );
    desc1022.putObject( idlayerLocking, idlayerLocking, desc1023 );
executeAction( idapplyLocking, desc1022, DialogModes.NO );

// =======================================================
var idapplyLocking = stringIDToTypeID( "applyLocking" );
    var desc1024 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref524 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref524.putEnumerated( idLyr, idOrdn, idTrgt );
    desc1024.putReference( idnull, ref524 );
    var idlayerLocking = stringIDToTypeID( "layerLocking" );
        var desc1025 = new ActionDescriptor();
        var idprotectTransparency = stringIDToTypeID( "protectTransparency" );
        desc1025.putBoolean( idprotectTransparency, true );
        var idprotectComposite = stringIDToTypeID( "protectComposite" );
        desc1025.putBoolean( idprotectComposite, true );
        var idprotectPosition = stringIDToTypeID( "protectPosition" );
        desc1025.putBoolean( idprotectPosition, true );
    var idlayerLocking = stringIDToTypeID( "layerLocking" );
    desc1024.putObject( idlayerLocking, idlayerLocking, desc1025 );
executeAction( idapplyLocking, desc1024, DialogModes.NO );

It was.
Therefore, using this content, the following function

// Function to set lock state of ordinary layer (image layer)
function LockCtlNormalLayer(NrlLayer){
// =======================================================
var idapplyLocking = stringIDToTypeID( "applyLocking" );
    var desc1016 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref520 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref520.putEnumerated( idLyr, idOrdn, idTrgt );
    desc1016.putReference( idnull, ref520 );
    var idlayerLocking = stringIDToTypeID( "layerLocking" );
        var desc1017 = new ActionDescriptor();
        var idprotectTransparency = stringIDToTypeID( "protectTransparency" );
        desc1017.putBoolean( idprotectTransparency, true );
    var idlayerLocking = stringIDToTypeID( "layerLocking" );
    desc1016.putObject( idlayerLocking, idlayerLocking, desc1017 );
executeAction( idapplyLocking, desc1016, DialogModes.NO );

// =======================================================
var idapplyLocking = stringIDToTypeID( "applyLocking" );
    var desc1018 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref521 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref521.putEnumerated( idLyr, idOrdn, idTrgt );
    desc1018.putReference( idnull, ref521 );
    var idlayerLocking = stringIDToTypeID( "layerLocking" );
        var desc1019 = new ActionDescriptor();
        var idprotectTransparency = stringIDToTypeID( "protectTransparency" );
        desc1019.putBoolean( idprotectTransparency, true );
        var idprotectComposite = stringIDToTypeID( "protectComposite" );
        desc1019.putBoolean( idprotectComposite, true );
    var idlayerLocking = stringIDToTypeID( "layerLocking" );
    desc1018.putObject( idlayerLocking, idlayerLocking, desc1019 );
executeAction( idapplyLocking, desc1018, DialogModes.NO );

// =======================================================
var idapplyLocking = stringIDToTypeID( "applyLocking" );
    var desc1020 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref522 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref522.putEnumerated( idLyr, idOrdn, idTrgt );
    desc1020.putReference( idnull, ref522 );
    var idlayerLocking = stringIDToTypeID( "layerLocking" );
        var desc1021 = new ActionDescriptor();
        var idprotectTransparency = stringIDToTypeID( "protectTransparency" );
        desc1021.putBoolean( idprotectTransparency, true );
        var idprotectComposite = stringIDToTypeID( "protectComposite" );
        desc1021.putBoolean( idprotectComposite, true );
        var idprotectPosition = stringIDToTypeID( "protectPosition" );
        desc1021.putBoolean( idprotectPosition, true );
    var idlayerLocking = stringIDToTypeID( "layerLocking" );
    desc1020.putObject( idlayerLocking, idlayerLocking, desc1021 );
executeAction( idapplyLocking, desc1020, DialogModes.NO );

// =======================================================
var idapplyLocking = stringIDToTypeID( "applyLocking" );
    var desc1022 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref523 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref523.putEnumerated( idLyr, idOrdn, idTrgt );
    desc1022.putReference( idnull, ref523 );
    var idlayerLocking = stringIDToTypeID( "layerLocking" );
        var desc1023 = new ActionDescriptor();
        var idprotectAll = stringIDToTypeID( "protectAll" );
        desc1023.putBoolean( idprotectAll, true );
    var idlayerLocking = stringIDToTypeID( "layerLocking" );
    desc1022.putObject( idlayerLocking, idlayerLocking, desc1023 );
executeAction( idapplyLocking, desc1022, DialogModes.NO );
}

I made it.
After that, against the image layer (transparency part, image pixel, position, whole, locked state is all set to OFF) previously loaded in the array called LayerList,
In the above function, the following JavaScript processing

LockCtlNormalLayer (LayerList [0]);

, All the locked states of transparent part, image pixel, position, whole, are turned ON.

Immediately after processing, the next code

alert("trPx : " + LayerList[0].transparentPixelsLocked + "\nPx : " + LayerList[0].pixelsLocked + "\nPos : " + LayerList[0].positionLocked + "\nAll : " + LayerList[0].allLocked);

I confirmed the locked state of the image layer with,

trPx: true (transparent part lock ON)
Px: true (image pixel lock on)
Pos: true (position lock on)
All: true (whole lock ON)

It was displayed.
After that, when looking at the layer panel, the layer which processed the previous process was turned off as the whole lock was turned on,
All other transparent parts, image pixels, and position locks are all turned off.

From this result, we expect to have a difference between the two actions of locking on Photoshop and locking on JavaScript.
Is there any solution?

Thank you.
Photo of Max Johnson

Max Johnson, Champion

  • 400 Posts
  • 173 Reply Likes
Thank you for the very complete testing and report! I do not know if there is a solution to this, I am sorry. Sounds like a bug in the panel display.
Photo of KFGX001

KFGX001

  • 3 Posts
  • 0 Reply Likes
Dear Mr.Max Johnson

Thank you very much.
If you understand something again, I would be happy if you could contact us.
I will also search for other solutions.