Skip to main content
Participant
April 24, 2014
Question

How can I send events with a script ?

  • April 24, 2014
  • 1 reply
  • 1405 views

Hello all,

It seems actions performed by scripts do not trigger events.

By events I mean those you can listen to by registering a notifier :

app.notifiers.add( "setd", new File("my_color_change_listener.jsx"), "Clr ");

The line above will make the specified script be notified when foreground (or background) color is modified.

But if I change foreground color using a script, for example :

app.foregroundColor = myColor;

Then no event will be sent. It is I believe the same with all events (changing layer, opening a document...)

So how can I send a event using a script ?

Thanks in advance,

Yannick

This topic has been closed for replies.

1 reply

JJMack
Community Expert
Community Expert
April 25, 2014

I do not think its possible events are only triggered from top level user action not from an action, script or plug-in. Most likely to prevent endless recursion,  If you want to trigger something why not simply do the something the action or script.

JJMack
Participant
April 25, 2014

Well to disable them by default is one thing, but you should be able to send events if you want to. Endless recursion happens only if you change color in a script that listens to color changes, which you'll admit is pretty silly

I see at least two reasons for using events instead of calling the action directly :

1. The most important, it allows for communicating between plugins

2. reacting to an event can make your code a lot cleaner. If I want to do something when color is changed, I do not want to think about it each time I change color in a script.

JJMack
Community Expert
Community Expert
April 26, 2014

All I can write is what I see in Adobe scripting guide. Have no idea of what Adobe is trying to convay other then scripts code does not generate notifications. Written in an Adobe way to confuse their users. For the way its written  seems to leave the door open exceptions.

Photoshop Scripting guide page 49

"NOTE: Notification generally does not take effect on events that occur inside of a script, because these events are embedded with in an "AdobeScriptAutomation Scripts" event"

Then in Photoshop JavaScript Reference page 136

"Note: Events that occur within scripts do not generally trigger notifiers, because they occur inside a "play

script" event"

JJMack