Skip to main content
Known Participant
December 24, 2023
Answered

Photoshop Layer change Event ?

  • December 24, 2023
  • 2 replies
  • 1397 views

Basically, I'm trying to make an action run every time i select a layer/change from a layer to another through the Script Events Manager on PS CC 2013, but I don't see it in the "Photoshop Event:" dropdown menu. There's an option to add an event but I don't know if this is even possible or how could I look for it, so any help would be massively appreciated.

 

The reason I want to do this is so that every time I change a layer and undo the first brush stroke i paint, it takes me back to the previous layer which is annoying and could lead to painting on the wrong layer. My idea would be to make it so that the quick mask mode is quickly toggled on and then back off through an action, every time i change layers, to prevent this photoshop behavior. Since entering and then exiting quick mask mode is stored on the history panel, I would stay in the current selected layer regardless if I undo the first brush stroke. I know they fixed this odd behaviour in current versions but currently I can't update so I'm trying to work around it with this theorical method.

If there's a better way to do this though, I'm all ears. I want it to be as seamless as possible with a very minuscule performance impact and easy to do for someone who doesnt know how to script.

I attached an image to illustrate my point

This topic has been closed for replies.
Correct answer r-bin

Exit Photoshop.

Find this in the Script Events Manager.xml file

....

<7>
<name>Export Document</name>
<value>Expr</value>
<valueClass></valueClass>
</7>
<8>
<name>Everything</name>
<value>All </value>
<valueClass></valueClass>
</8>
<9>
<name>Select Layer</name>
<value>select</value>
<valueClass>layer</valueClass>
</9>
</events>

....

 

Add what is indicated in red.

Save the file, launch Photoshop and reassign the event.

The script will only respond to the selection of a layer and not to the selection of a tool, and so on.

 

2 replies

Legend
December 24, 2023

In a simplified version, you can do this

 

And assign such a script

 

if (app.documents.length) app.activeDocument.suspendHistory("Select", "");

 

 

UPD. In the screenshot, the values in the lines are mixed up. But in this case it works due to a Photoshop glitch.

grunge616Author
Known Participant
December 24, 2023

(my bad, I didn't see your comment before)

This worked, but is there a way to undo multiple steps in the same layer? I'm having the issue that when Photoshop detects i undo the second step, it basically "selects" the layer again, running the script and rendering unusable, since it doesn't let me undo any more steps other than the first one. As far as performance and everything else, this is great

r-binCorrect answer
Legend
December 24, 2023

Exit Photoshop.

Find this in the Script Events Manager.xml file

....

<7>
<name>Export Document</name>
<value>Expr</value>
<valueClass></valueClass>
</7>
<8>
<name>Everything</name>
<value>All </value>
<valueClass></valueClass>
</8>
<9>
<name>Select Layer</name>
<value>select</value>
<valueClass>layer</valueClass>
</9>
</events>

....

 

Add what is indicated in red.

Save the file, launch Photoshop and reassign the event.

The script will only respond to the selection of a layer and not to the selection of a tool, and so on.

 

Stephen Marsh
Community Expert
Community Expert
December 24, 2023

More on the SEM here:

 

https://prepression.blogspot.com/2021/10/photoshop-script-events-manager.html

 

You can use the ScriptingListener plugin to see if an event is triggered, not all of them are listed in Appendix A: Event ID Codes.

 

I'll take a look later when I have time.

grunge616Author
Known Participant
December 24, 2023

Thank you, I'll be waiting for you asnwer. Appreciate it.

Stephen Marsh
Community Expert
Community Expert
December 24, 2023

@grunge616 

 

Event Name:

Whatever you want, such as Select Layer

 

Descriptive Label (case sensitive, lowercase):

select