No internet connection
  1. Home
  2. How to

Controlling Keyboard Maestro with Soundflow

By @briannaas
    2020-02-29 17:05:02.577Z2020-02-29 17:38:43.847Z

    Hi,

    I would like to be able to send a command from Soundflow to execute a macro in Keyboard Maestro. I think I could use Script, JXA or Apple Script to do this, but I'm not really sure how.

    Ideally this could be used on a multi-computer synced setup, I'm not sure if apple scripts have to be located on a different specific locations on the directory of each computer.

    Any help would be appreciated!

    Solved in post #8, click to view
    • 17 replies
    1. Hi Brian

      I don't have KM installed here, but I think you're right that it has an AppleScript trigger. I think they have a drop down menu where you select "from AppleSCript" for example.

      To run any AppleScript in SoundFlow, use the "Execute AppleScript" action in a macro:

      Either fill out the "Script" field with the code, or the "Path" field containing a path to an AppleScript file on disk (not both).
      This should give you the integration.

      1. Note, if they have other means to connect rather than AppleScript, please send us a screenshot of the possibilities. AppleScript is a very slow technology, so we might be able to point you in a direction of something that will prove more performant.

        1. In reply tochrscheuer:
          B@briannaas
            2020-02-29 18:10:27.267Z

            Thanks Christian. Yeah I actually tried using this exact method and it didn't work. It didn't trigger the script. Also I don't think solution would work for me because the location of the specific Apple Script would be different depending on which computer I'm using, and the point of this is to have a synced setup.

            Can I use the "Script" for this?

            1. Hm.. Ok yea you should be able to copy/paste the script code in there. Tbh though I'm not sure if it right now will handle multi-line scripts, so we might need to adapt them somehow.

              But again I'm pretty sure we can come up with a better integration than via AppleScript.

              Can you show me a screenshot of the KM trigger popup menu? (Only because I don't have KM right here)

              1. B@briannaas
                  2020-02-29 18:16:59.142Z

                  Yeah sure. This is a test macro using Javascript.

                  1. Okay, I installed a trial - it works if I do it like this:

                    1. If you want even more speed, I think using the "Or by URL" in KM and then using the "Open File" action in SF would also work and potentially is faster:

                      Reply2 LikesSolution
                      1. B@briannaas
                          2020-02-29 19:06:38.122Z

                          Ah perfect. That works. Thanks Christian

                          1. Awesome - thanks for verifying :)

                          2. In reply tochrscheuer:
                            JJon Lipman @Jon_Lipman
                              2022-02-06 07:06:52.425Z

                              Hi Christian, I'm trying to use this technique to trigger some of the KM macros I have built - how do I get the macro identifier - in the example above you have listed "067a4625-4a1e-47d7-b658-b1a5037c1e95" - is this string referencing a KM macro?

                              My macros are described simply by name (Reverse Radium Slot 1 for example) using the macro name as I have it did not work.

                              Please let me know

                              Thanks!

                              Jon

                              1. Hi Jon,

                                See my note above. In KM, go to the trigger section and find the "Or by URL" place. That will give you the URL we're using in the example.

                        • In reply tochrscheuer:

                          FWIW - I've found that if you paste an apple script into the Execute AppleScript Script field it doesn't work unless you escape all of the line returns via \n.
                          The better method is to enter "script" into the Script field, convert the macro action into a script, then replace script: property withe the AppleScript enclosed in back ticks like this script which toggles the mute state of the Mac's system volume:

                          sf.system.execAppleScript({
                              script: `set curVolume to get volume settings
                          if output muted of curVolume is false then
                          	set volume with output muted
                          else
                          	set volume without output muted
                          end if`,
                          });
                          
                      2. In reply tochrscheuer:
                        Chad Wahlbrink @Chad2020-03-30 15:27:44.220Z

                        I'm curious if this is possible in reverse. Are you able to trigger or run a Soundflow macro via apple script or within keyboard maestro somehow?

                        Before I dove into Soundflow, I was recently messing with designing custom panels for the Mac OS Accessibility Keyboard and using a luna display to trigger them from my iPad.

                        https://userautomation.com/article/blog0003.html - Workflow from Sal Soghoian who helped invent Apple Script and Apple's Automator.

                        With that set up I was able to trigger either an apple script on it's own or an apple script triggering Keyboard Maestro. I am thinking that stream deck and Soundflow together is probably enough of a solution that I can abandon this idea, but the custom panel workflow was nice in that it allowed me to have as many buttons as I want and no monthly subscription to Stream Deck.

                        I'm hopeful that the iOS companion app for Soundflow could replace this and allow for a similarly custom panel? It's mainly just frustrating that Streamdeck's iPad app is a ported iPhone version - they could give us a lot more buttons to work with on that platform.

                        1. Hi Chad.

                          Yes you can run SoundFlow scripts either via web triggers or via shell scripts.
                          But if you're just trying to set up a surface that you're using Luna display to trigger - why don't you design Surfaces directly in SoundFlow? To create a surface, click "+ New" and choose "Surface".
                          SoundFlow surfaces run on macOS as well, all the SoundFlow apps you see like the Video Converter are SoundFlow surfaces, so they're capable of quite advanced things. Once our iOS and Android app is out, you'll be able to trigger them directly from those devices, but since you're already using Luna, it would make a lot of sense to start with designing the surfaces and using them on macOS.

                          1. I think though that this part of the discussion is better suited for a new thread - but I'd be happy to point you in the direction of how to set up your first surface.

                            1. In reply tochrscheuer:
                              Chad Wahlbrink @Chad2020-03-30 15:58:54.166Z

                              Hey Christian!

                              I would definitely be interested in the web triggers & Shell Script options, but I'm happy to move that to a new thread if necessary.

                              I'll poke around the panel creation a bit more and let you know if I need help with that. That actually could work well with the Luna and would work even better with the iOS app versions I'm sure. The main issue I had with the Luna display set up was that I had to use KB Maestro to move my mouse back to the main screen after each action (after pressing a button on the iPad) - but I'm sure I could figure that out if I do go that route.

                              1. What I meant was to separate controlling SoundFlow from other software, from the discussion of how to develop touchable surfaces that can control SoundFlow commands - since these are two different issues with two different recommended approaches.

                                The quick response to how to control SoundFlow from other software, check this documentation article:
                                https://soundflow.org/docs/reference/cli

                                The discussion on touch surfaces is what I thought would be best suited for another thread, since we can then more freely talk about the benefits of designing your surfaces directly in SoundFlow.