14 Replies Latest reply on Feb 7, 2013 7:46 AM by DavidCôté

    Recording script actions in an action

    Harald Heim Level 1

      Is it possible to record the steps that a script performs (e.g. creating a new layer, switching to a certain layer, applying a filter) in an action? When you activate the record button on the Action panel and run a script, only the script execution is recorded and not the things that the script does. Is there a way to pass the script steps to the Action panel so that it records it?

        • 1. Re: Recording script actions in an action
          c.pfaffenbichler Level 9

          Is there a way to pass the script steps to the Action panel so that it records it?

          I doubt it and don’t see a lot of sense in it, as that would strip conditional clauses etc.

          Why do you ask anyway?

          • 2. Re: Recording script actions in an action
            Harald Heim Level 1

            I am developing a flash panel that allows the users to do various tasks. It would be nice if the steps that are peformed by the panel would be recordable in an action.

             

            As these steps show up in the History panel, I thought it may be possible for the Action panel to capture them.

             

            If there is not way to pass these steps to the Action panel for recording, the only alternative is to make the panel record an action itself, save it as an .atn file and automatically place the .atn file in the Action panel. I had hoped there would be a much easier solution.

            • 3. Re: Recording script actions in an action
              c.pfaffenbichler Level 9

              Like I said I doubt this is an option, but others may know better.

               

              Might it not be easier to create (or maybe download) an atn-file and load it?

              • 4. Re: Recording script actions in an action
                Michael L Hale Level 5

                With a 'normal' javascript you can make it action recordable by adding a <javascriptresource> section to the start of the script. Basically what that section does is set up the name and data types for the options that will appear in the action when recorded. You then read/set app.playbackParameters to play/record the action.

                 

                I am not sure if that would work with a panel. If it can I would think that each panel control would need it's own <javascriptresource> section.

                • 5. Re: Recording script actions in an action
                  c.pfaffenbichler Level 9

                  but others may know better.

                  Indeed they do …

                  • 6. Re: Recording script actions in an action
                    Harald Heim Level 1

                    Right, the <javascriptresource> section allows to record parameters for a script, which are then stored in the action. This would be an option if I would develop a script. Not what I was looking for, but it would be doable.

                     

                    As far as I can tell nothing a panel does is recorded, not even starting the flash panel itself. I thought maybe the executeAction() calls of the panel script could be passed to the action panel, so that it can record them. If it is not possible, it would be a nice feature for a future Photoshop version.

                     

                    Any other idea?

                    • 7. Re: Recording script actions in an action
                      Michael L Hale Level 5

                      The more I think about it I don't think  using a <javascriptresoures> section and setting the app.playbackParameters would work even with a scrpt. Unless the Action panel was in record mode. In other words even if you could pass something to the action it would not be recorded unless the action was in record mode.

                       

                      I don't know of a way to start record mode from a script or force an action to record tasks that are not normally recordable.

                      • 8. Re: Recording script actions in an action
                        Harald Heim Level 1

                        I would expect that the user himself starts the action recording in the Action panel, so that is not a problem.

                         

                        Can my panel script pass the ActionDescriptor that is returned by executeAction with the help of app.playbackParameters to the Action panel? Would the action panel record it then? Would it be possible to record multiple steps that way?

                         

                         

                         

                        • 9. Re: Recording script actions in an action
                          DBarranca Level 4

                          Harald,

                          I don't know if this applies to your case, but couldn't you add listeners to the panel and record what the user does - then try to convert these steps into an action (XTools has various utilities you can look at)?

                          It doesn't look easy, though.

                           

                          Davide

                          • 10. Re: Recording script actions in an action
                            Harald Heim Level 1

                            That was my emergency strategy. i would not even need listeners for that. I just thought there would be some switch to let the Action panel receive the actions of my panel.

                            • 11. Re: Recording script actions in an action
                              DBarranca Level 4

                              Harald,

                              have you been able to get through it? I've posted a similar question (see here), anything new to share?

                              Thanks!

                               

                              Davide

                              • 12. Re: Recording script actions in an action
                                Harald Heim Level 1

                                Davide, I did not try anything new in this direction yet. It is a pity that operatons triggered by a script, panel or plugin cannot be recorded by the Actions panel. Only manually performed operations seem to have that privilege.

                                 

                                But I still have not given up hope that there is a workaround to make it possible anyway. Maybe if the operations are triggered via simulated key shortcuts, they may be recorded by Photoshop. That would probably only be possible via a plugin or if a script calls a function from a .dll file. But not all things can be done that way.

                                 

                                Another option would be to dynamically save a script on the hard drive for each operation and then trigger each script to produce a new recording step. But then these script files need to stay on the harddrive as long as the action is still in use. But I do not know if that would really work.

                                 

                                Maybe it is also possible somehow to inject an event into the scripting system that can be recorded. But so far I have no idea how to do that.

                                • 13. Re: Recording script actions in an action
                                  DBarranca Level 4

                                  Thanks Harald,

                                  I've been trying firing a keydown event, but it's quite a mess and I've basically given up this route.

                                  Another option would be to dynamically save a script on the hard drive for each operation and then trigger each script to produce a new recording step. But then these script files need to stay on the harddrive as long as the action is still in use. But I do not know if that would really work.

                                   

                                  Trigger each script to leave a trace in the Action Palette is what I've been working on these days, but I couldn't make it.

                                  I've also tried to manually build an ActionDescriptor with the proper keys - assigning it to the app.playbackParameters on a script with proper <javascriptresource> (basically what Mike Hale said): even if the Action is in record mode, no way. Alas, it seems that the script called from the Filter menu has some exclusive magic.

                                   

                                  Davide

                                  • 14. Re: Recording script actions in an action
                                    DavidCôté

                                    Hi!

                                     

                                    If you guys come to find some clues on how to do it, please share! Right now, I am trying to figure out how to record some user interaction with the panel for test automation purposes. I think from what I've read here so far that my problem can be solved by coding the action and generating the .atn file, but I'm not comfortable yet to say that I'm following an 100% the suggestions . Anyhow, to know how to let the user record its own action will surely be helpfull in the near future of our extension development.

                                     

                                    Thanks for being active in the community. It's been really helpful so far!