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

how do I get the name of the action that was started from within my javascript?

Community Beginner ,
Dec 08, 2016 Dec 08, 2016

Copy link to clipboard

Copied

Hello,

I want to create an action called 'test1' and record it playing a script called 'generic.jsx'.

I want the script to know that it was started by 'test1' and thus, do XYZ.

I want to create another action called 'test2' and have it play the same script called 'generic.jsx'.

From within that same script, being a generic one, I want to to now know that it was started by action 'test2' and do ABC.

How can I have my javascript know the name of the action that launched it?

Thanks in advance!

---

Shai

TOPICS
Actions and scripting

Views

1.5K

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

correct answers 1 Correct answer

Guide , Dec 24, 2016 Dec 24, 2016

There is some code for getting the current action here...

How to get current selected action.

Votes

Translate

Translate
Adobe
Dec 08, 2016 Dec 08, 2016

Copy link to clipboard

Copied

Moving to Photoshop Scripting​

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
Explorer ,
Dec 09, 2016 Dec 09, 2016

Copy link to clipboard

Copied

Why not just have the one script ask the user what it should do? Why do actions need to determine the script behaviour?

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
Community Beginner ,
Dec 09, 2016 Dec 09, 2016

Copy link to clipboard

Copied

Hello and thanks for replying.

The action I've got runs the javascript. The action is called from either Lightroom or Bridge and is suppose to handle multiple (batch) jobs so there shouldn't be any interactivity with the user.

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
Community Beginner ,
Dec 18, 2016 Dec 18, 2016

Copy link to clipboard

Copied

anyone?

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
Guide ,
Dec 19, 2016 Dec 19, 2016

Copy link to clipboard

Copied

You would need to get your actions to create a Flag file, this is any name you want. Then your generic jsx would look for the flag files and then know what action is was. make sure the generic jsx removes the flag file.

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
Community Beginner ,
Dec 24, 2016 Dec 24, 2016

Copy link to clipboard

Copied

Hello SuperMerlin,

Thanks for the response.

What you're saying is, create a .jsx, copied multiple times, per action. Having another small .jsx per action, that would create a flag file 'abc' or 'xyz', which is hard-coded into it, would be the same as having the script that I'm writing, copied multiple times per action and just calling it differently and hard-code the 'abc' or 'xyz' code I need it to do. Am I wrong?

I still think that I need to either have the javascript "know' what action started it (or is currently running) or be able to pass arguments from the recorded action to the javascript.

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
Guide ,
Dec 24, 2016 Dec 24, 2016

Copy link to clipboard

Copied

There is some code for getting the current action here...

How to get current selected action.

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
Community Beginner ,
Dec 24, 2016 Dec 24, 2016

Copy link to clipboard

Copied

Brilliant mate, thank you!

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
Engaged ,
Dec 01, 2017 Dec 01, 2017

Copy link to clipboard

Copied

LATEST

The "flag file" idea was an interesting one. It would look like this:

  1. Action1 invokes Stub1.jsx which places "FromAction1" in "marker.file" and then invokes MAIN.jsx.
  2. MAIN.jsx inspects maker.file and acts accordingly.

Rather than creating a separate file, however,

  1. Action1.jsx can: add a transparent layer to the current active document called "FromAction1" and invoke MAIN.jsx.
  2. MAIN.jsx looks at the current active layer and uses its name to do the function for Action1.

Another idea:

  1. Action1 can directly update something in the current document.info (Record the File -> File Info) operation. E.g. update the Instructions data in the Origin field. (A recorded action step looks like this:
    PS_Action_FileInfoChange.png
  2. Invoke MAIN.jsx which retrieves the information from the active document:   `app.activeDocument.info.instructions`

    In the ExtendScript Tool, you can do this: `$.writeln(app.activeDocument.info.instructions)`

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