No internet connection
  1. Home
  2. How to

Get script name and write to variable

By Benjamin Hörbe @Benjamin_Horbe
    2021-01-16 13:53:13.689Z

    Dear fellow Soundflowians,

    I'm still pretty new to javascript. Is there a way to let a script know its own name?
    Thanks for any hints.

    Benjamin

    • 10 replies
    1. Hi Benjamin

      No, you currently can't do that.
      However, you can pass arguments/parameters to a script using Templates & Presets.

      To learn how to work with Templates & Presets, please see this webinar:

      https://www.facebook.com/soundflow.org/videos/633065107406660

      1. Benjamin Hörbe @Benjamin_Horbe
          2021-01-16 14:05:32.841Z

          That is a pity. I was thinking to optimize my "Trigger Keyboard Maestro Action" package that I published a few days ago. It would be great to just create a new preset with the name of KM action and that the script automatically reads its name and uses it to trigger the corresponding action in KM.

          Another option( at least for my demands) would be to get the Action name from an iPad surface button name. is that possible?

          Best
          Benjamin

          1. Hi Benjamin

            With the Presets & Templates feature you can do (almost) exactly what you're describing. Have you checked them out?

            1. See here for an example of how it looks:

              1. The benefit of working this way is that you can add as many template properties as you want (one being the action name, but there could be other information you want to pass on).

                Also, you only have one script - so when/if you need to change anything in the implementation, all presets will get the benefits from it (including users of your package)

                1. In reply tochrscheuer:
                  Benjamin Hörbe @Benjamin_Horbe
                    2021-01-16 14:29:47.709Z

                    Yes, that is what I did in my script. But you still have to paste the KM action name twice: Into the preset name and into the action Name field.
                    Would be good to just paste it once. But actually that it is not so important. Just spending the afternoon playing around with some code.
                    Thank you very much…

                    1. In reply tochrscheuer:
                      Benjamin Hörbe @Benjamin_Horbe
                        2021-01-16 14:35:01.552Z

                        One more question. The Template in your screen shot is apparently a similar KM action trigger. Is it from the store? Before I started to script one myself i was searching for a way to trigger KM actions but could not find any. Did I miss something?

                        1. Ah, no sorry for the confusion. I just named an empty template script the way I'd imagine you'd name yours - just to show it off :) I didn't actually implement it.

                          1. Benjamin Hörbe @Benjamin_Horbe
                              2021-01-16 14:52:23.340Z

                              It looks exactly like the way I implemented it.

                              1. In reply tochrscheuer:

                                By the way, if you're looking for inspiration as to how to run KM scripts from SF, then this thread has more info on different implementations: