• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

how can I trigger the execution of my plugin from another thread?

New Here ,
Jul 13, 2015 Jul 13, 2015

Copy link to clipboard

Copied

Hi,

I have the following problem:

My photoshop automation plugin should execute some javascript code. It should run in the background and only start executing the javascript if it was triggered from another application.

At the moment I have a separate thread running to wait for external commands, and when I receive one I trigger the kPSPhotoshopCaller/kPSDoIt message action to execute the javascript in main thread, but unfortunately it stays in the current thread. Is there any Idle function I can use to wait for external commands or some other way to trigger the execution of the pluginMain in main thread?

I would be very grateful for every hint!

Cheers.

TOPICS
SDK

Views

527

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
New Here ,
Jul 13, 2015 Jul 13, 2015

Copy link to clipboard

Copied

what worked now was to use the "idle" event. I saw the solution on this discussion here.

Can we know whether PS is idle?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 13, 2015 Jul 13, 2015

Copy link to clipboard

Copied

LATEST

I'm not too sure why you are using this approach to run some javascript code on an external event. Let's get clear on a few points here

1) Why doesn't this "another application" simply run PS with the javascript your plugin has to execute? Do you really need this plugin whose job it is to run javascript at all? I obviously could be missing something here from the picture, but usually plugins's job is to do something much more complex (think complicated C++ logic) than to trigger Javascript code on an external event

2) Assuming there is something else going on here and your plugin runs js as part of something more complex, why do need threads to being with? This external application could simply call your plugin by invoking PS with a tiny js file as a parameter that simply invokes your automation plugin. Your plugin would then be triggered whenever PS has a chance to dispatch the call, and you can do all the work you need including scripting right there. No threading or even idling seems to be necessary for this type of workflow.

3) Last to keep in mind, PS is NOT an MT-safe environment, so talking to PS SDK from the same binary but different threads is not a very good idea. You could of course mutex access to PS SDK so that only a single thread can access it at a time, but it's not a trivial task coding-wise, and again, chances are you'd be using a sledgehammer to crack a nut..

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines