Get script name and write to variable
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
- Christian Scheuer @chrscheuer2021-01-16 14:00:12.149Z
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
Benjamin Hörbe @Benjamin_Horbe
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
BenjaminChristian Scheuer @chrscheuer2021-01-16 14:22:18.624Z
Hi Benjamin
With the Presets & Templates feature you can do (almost) exactly what you're describing. Have you checked them out?
Christian Scheuer @chrscheuer2021-01-16 14:23:31.594Z
See here for an example of how it looks:
Christian Scheuer @chrscheuer2021-01-16 14:26:11.187Z
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)
- In reply tochrscheuer⬆:
Benjamin Hörbe @Benjamin_Horbe
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… - In reply tochrscheuer⬆:
Benjamin Hörbe @Benjamin_Horbe
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?
Christian Scheuer @chrscheuer2021-01-16 14:51:27.017Z
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.
Benjamin Hörbe @Benjamin_Horbe
It looks exactly like the way I implemented it.
- In reply tochrscheuer⬆:
Christian Scheuer @chrscheuer2021-01-16 14:52:28.764Z
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: