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

Scripting: can i select (only select) specific command / action in the actions palette?

Guide ,
Dec 14, 2019 Dec 14, 2019

There is a script that is recorded (and runs by user) in the action palette. As a result of its work, the script launches another action. Another action (sometimes) has a "stop" command.

I need to make that the cursor in the action palette set on the command after the stop, and does not return to the command from which the script was run (last variant - is normal photoshop behavior). I can get the index of the command on which the stop occurred, I can continue the action from it, but this option is not suitable for the me in that script. Is there a known method that allows to set focus on a specific command / action in the actions palette?

 

This sample does not work (the "select" command cannot be executed)

 

function s2t(s) {return stringIDToTypeID(s)}

var desc = new ActionDescriptor()
var ref = new ActionReference()

ref.putName(s2t("action"), "test atn" )
ref.putName(s2t("actionSet"), "test set" )
desc.putReference(s2t("target"), ref )
executeAction(s2t ("select"), desc)

 

 

TOPICS
Actions and scripting
2.3K
Translate
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

People's Champ , Dec 14, 2019 Dec 14, 2019

"duplicate" then "delete"

 

Translate
Adobe
Community Expert ,
Dec 14, 2019 Dec 14, 2019

An Action can have two type of stop messages.  A stop message that stop the action  or a message  with an option to continue the actions execution not stop just pause the execution to give the user some information  needed to perform some interactive step to come or stop to put the user back in control.   Stop an actions so Photoshop UI will be in control so the user can perform some Steps.  If an action that has a stop step  has steps after the stop step the user can click Play to continue the Actions execution.  I would think that type of Action would not work if executed by a script unless it the last thing the script does.  For the Script is running Photoshop it has taken over control of Photoshop. Photoshop UI is not controlling Photoshop Adobe Scripting Plug-in is running.     If an Action stops that a script executes Adobe Scripting Plug-in would most likely regain control from Photoshop Action player and continue its processing. The user would not have the opportunity to use Photoshop's UI to perform any steps. before clicking Play to continue the action. If the next thing the script does is end its execution  the user will be in control to do Photoshop steps and click Play to continue the action

JJMack
Translate
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 14, 2019 Dec 14, 2019

The meaning of my script is that it searches and launches an action, depending on the name of the document / specific layer. That is, problems with hard-coded action names simply do not arise - they are determined dynamically during the script.

2019-12-14_19-02-08.pngexpand image

If you run the script from the automation menu, it is executed outside the context of the action panel (that is, when the action is executed, the command cursor stops after the stop command and the user can continue the action with a hotkey or play button). However, in this case, I have to show the script interface every time so that users can specify the launch parameters they need.

2019-12-14_19-02-50.pngexpand image

 

To avoid displaying the interface, users write it to the action panel as a separate operation - in this case, Photoshop considers the action from which the script is run as “parent” in the action chain and, if there is a stop command (completely stopping execution), returns the cursor to the action from which the script was run.

2019-12-14_19-03-23.pngexpand image

So far, I have recommended that users break down the actions into separate steps and not use the stop command. However, I am trying to find a solution to this problem.

Translate
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 Expert ,
Dec 14, 2019 Dec 14, 2019

Have you checked out xtools from ps-scripts.com? I'm  not sure if there will be anything that helps, but I thought that xbytor, the creator of the tools, managed to break down actions into scripting components. But I could be wrong about that.

Translate
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 14, 2019 Dec 14, 2019

Yes, I looked through examples of the xbytor and his stdlib, but I did not find methods to solve this problem.

 

In this moment, I changed the script operation algorithm - after starting the action, it evaluates the result of its execution: since the "stop" always throws an exception, I get the number of the command that stopped, if the name of the previous command is localize ("$$$ / Actions / Event / Stop "), then I remember its position and at the next start of the script I continue from this point. This is not exactly what I wanted, but it allows users to give a working solution.

Translate
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 Expert ,
Dec 14, 2019 Dec 14, 2019

I write Scripts that actions run Action run twice these script basically have two functions  the script does one function in the first run and the second function in the second run based on what was done on the first run. If the action has a stop before the second run the user must click play again to continue the action so the script is  gets executed the second time.. 

 

It sound like if your script select an action to run and  that action has a stop. The script gets control  for a stop with an exception it can catch and note where it is in its execution. Then terminate so the user can carry out the Action part the stop was set up for then the user needs to click Play to continue the action execution.  When the Action ends  It seems your script need to be run as second time so it will see  that its execution was halted in the previous run because of an Actions stop which the script recorded so it can resume its processing which was cut short the previous execution.

 

The Script can not be a batch process if it does an action with interactive steps and if the interaction involves a Stop it gets ugly for the script  It needs to instruct the user to run the script again after the action stop part and the action is continue and done.   It seems I was correct thinking that script would get control with an  Action Stop.  The script has no Idea what the stop is for so there no choice but to terminate so the user can perform the stop and the continue the action. Its ugly.  

 

Actions are not run from and automation menu or outside  action panels per say.  There is a action Player function.  The Player can be used interactively From the Action Palette.   A Stop  end execution of the Action and the next step in the action is highlighted in the actions Palette so the action can be resumed using the Actions palette's play button.   When the Action Player ends it execution control returns to whatever started it. If started via the Action Palette Play button control returns to Photoshop UI.  If started via a script doaction control would return to the script. A script can not continue and action it can not click the Play  button and even if it could  it would do  nothing because script is in control not Photoshop's UI. 

 

If a script could set focus highlight an actions step how would the script know which step to highlight. There can be many set steps and more than one stop step.  If it knows the step number what happens if someone edits the  action and add steps before that step. A stop should hightlight set focus on the next action step in the action played.

JJMack
Translate
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 Expert ,
Dec 14, 2019 Dec 14, 2019

Script that use actions are also hard to maintain and distribute for more then one file is involved. If the action is edited the script may no longer work for the document may be changed in a way that effect the scripts execution.  The Action Set name and action name is hard coded int the script. The action set and correct action need to be on all machine the use the script. I have never tried using an action with a stop step with Image Processor.  You should be able to test to see if what I think is correct.

JJMack
Translate
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 Expert ,
Dec 14, 2019 Dec 14, 2019

I agree with JJ. I think it would be much better to convert the actions to scripts, so that you have more control.

Translate
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
People's Champ ,
Dec 14, 2019 Dec 14, 2019

"duplicate" then "delete"

 

Translate
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 16, 2019 Dec 16, 2019

Genious! It works!

 

function s2t(s) {return stringIDToTypeID(s)}

selectCommand ("Test set", "Test atn", 1)

function selectCommand(setName, atnName, cmdIdx)
{
  try {
      var desc = new ActionDescriptor()
      var ref = new ActionReference()

      ref.putIndex ( s2t("command"),  cmdIdx)
      ref.putName( s2t("action"), atnName )
      ref.putName(s2t("actionSet"), setName )
      desc.putReference(s2t("target"), ref )

      executeAction( s2t("duplicate"), desc)
      executeAction( s2t("delete"), desc)

      return true
  }
  catch (e) {return fasle}
}

 

 

 

 

Translate
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 Expert ,
Dec 17, 2019 Dec 17, 2019
LATEST

r-bin is very good and knows how to code Action Manager code well and often come to my rescue. Action Manager code is more a black box to me. All  I can do is hack a little on the code Adobe's Scriptlistener Plug-in records.  What go into  action descriptor and reference object is something foreign to me. Therefore  using get "executeActionGet("  is above my pay grade.  Any "executeActionGet" found in my script code is most likely thanks to b-bin a great asset is he or she.  Any javascript I do is a hack for I do not know it well regular expressions and action manager code is above me   At 79  that not going to change I have forgotten more than I know and will not retain what  I now learn.

JJMack
Translate
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