Touch Portal

I had posted a question elsewhere but I've since solved the issue and thought I'd log it here under a better title for others that may also be looking for a solution. The question was, how to trigger a KM macro using touch portal, directly, without using Touch Portal to simulate a keystroke defined by KM. The reason being that there are only a limited number of keystrokes available in some complex applications which have many reserved already.

I tried the web service, but ultimately used a script. I created a script called and set it to chmod 755 in my home dir. It was coded as follows:

osascript -e 'tell application "Keyboard Maestro Engine" to do script "'$1'"'

$1 is the argument passed to the script.

The KM macro is set up with the trigger "or by shell script" and you select which option you want to use, then in Touch Portal set that up to use the trigger "Run Bash Script" which can be found under "Run & Open". Choose the script you made, and pass it the argument (script name or script ID) specified/chosen in KM.

It's not terribly convoluted, and the upside is that Touch Portal costs a lot less than hardware Stream Deck, and is far more configuarble. The downside is some extra programming. I really like the very high definition images and much more dense key trigger visuals that can be achieved in TP on ipad compared to SD. My iPad is quite old and won't run SD mobile.

I'm not familiar with Touch Portal but from what I've gleaned, wouldn't you be able to get Touch Portal to call Keyboard Maestro macros using URLs?

trigger:URL [Keyboard Maestro Wiki]

using the keyboard maestro web server was a bit laggy. Maybe half a second, but still noticeable. Touch Portal does not seem to have the ability to send a non http:// type url.

If you can call a shell script, rather than using AppleScript, use a shell script, like so:


/usr/bin/open "kmtrigger://macro=52273413-AA38-4AA6-A7D8-6EA09B5710D1"

exit 0

You can find the URLs for your Macros by looking at the "Trigger" area at the top of the macro. Click on the dropdown menu and choose "Or by URL" as shown here:

I like the UUID option because if I rename my macros it won't break the script.


Thanks. I wonder if you missed the fact that I was posting a solution? My solution uses a bash script and passes arguments to it so that you can use a single script (appending the info needed to call a specific macro as the argument).

The reason being that there are only a limited number of keystrokes available in some complex applications which have many reserved already.

I know you have found a solution you are happy with - but in case it helps others who want a very simple solution -
I use a keystroke trigger to connect "Better Touch Tool" to my macros and since Keyboard Maestro can have several triggers for the same macro I make an extra Keystroke trigger that involves as many keys as possible. In other words I use a keystroke that would be so awkward to actually press that it is definitely not going to use up any already defined keyboard shortcuts.
⌃⌥⇧⌘ followed by a letter or number. That gives me at least 38 possible new keystrokes - way more than I have macros for any one app.

1 Like

Great suggestion and I have been using the very same technique in InDesign (the app that is overloaded with shortcuts already!). I hadn't thought of using multiple inputs in this way, a good one to log away in the mind and really shows how flexible KM is. I should add that I'm really grateful for this and also for tjluoma's input because I'm learning a lot!

I did miss that.

I do think that using the Keyboard Maestro URLs would be faster than using AppleScript, but I think it's always useful to know more than one way to do something.

1 Like

I've tried to learn applescript a few times but it never takes, that's the main reason I avoided having anything to do with it here and used bash.

Sorry to hear that. There are some good AppleScript learning resources, but few from Apple.
I can say that one of the best things you can do to learn AppleScript is to get Script Debugger 7 . SD7 is especially helpful in exploring and learning the scripting models of various apps, as well as the GUI elements of any window.

I would also say that while AppleScript is great at giving you access to an app's scripting model, the language itself is not the greatest. Those of us who have programmed in other languages find it hard to learn. If you are in that group, then you may prefer using JavaScript for Automation (JXA), which gives you the same access to Apple Events, but uses JavaScript as it's core language. For more info see:
JXA Resources

Maybe this will help:

Learning AppleScript

If you are new to AppleScript and are interested in learning more, then I'd suggest you take a look at:

  1. AppleScript: Beginner's Tutorial
  2. Script Debugger 7 -- a full IDE for developing AppleScript.
    SD7 now comes with a 20-day free trial, and then will gracefully downgrade to the FREE SD7 Lite (which is still much better than Script Editor).

You can get lots of AppleScript help here in this forum, and in the Script Debugger Forum.

1 Like

Umm… except that you haven't.

Here's what you posted as your bash solution:

osascript -e 'tell application "Keyboard Maestro Engine" to do script "'$1'"'

osascript is how you use AppleScript in a shell script (bash, zsh, etc).


tell application "Keyboard Maestro Engine" to do script "'$1'"

is an AppleScript command for Keyboard Maestro which you are sending through bash.

That is why I said that you haven't avoid AppleScript, you're using AppleScript via bash. And that's fine, if that's what you want to do, it should work.

However, AppleScript has a reputation for being somewhat slower than other options (whether that actually matters in this instance is debatable, and I would not be surprised to find that your solution and mine were both equally speedy).

It is possible to do this without osascript/AppleScript by using the kmtrigger URL and the open command, which is why I suggested:


/usr/bin/open "kmtrigger://macro=52273413-AA38-4AA6-A7D8-6EA09B5710D1"

exit 0

That is a different solution which is just using shell commands/bash, and no AppleScript.

I apologize for any confusion that I may have caused. I was not intending to suggest that your solution was a “bad” one, simply that there was another way to do it -- which should work equally as well, and possibly a bit quicker/more efficiently.

1 Like

No need to apologise, I'm learning a lot and this is one of the liveliest and most positive little forums I've visited. I'm stoked we're all chatting about it :slight_smile:

I hadn't realised osascript was applescript in disguise! I'll try and use your suggestion and mod it a little later for arguments (can't be writing hundreds of separate scripts obv.). I'm learning just as much in the misunderstandings as elsewhere!

I think you just about hit the nail on the head there! I'll check out Debugger, TYVM

1 Like

I know that it has been true in my life that I often learn more from my mistakes than anything else :smiley:

This and the Mac Power Users forums are two of the best little communities on the Internet, as far as I'm concerned.

Created an account on this forum just to say thank you for this post!
I was really interested with the potential of Touch Portal but it didn't work properly in the software I wanted to trigger macros from.
Your above script is the perfect work around to get Keyboard Maestro (which is much more stable and robust) to do all the heavy lifting. Now I can design the ipad controller i'v been after for years!

Thanks so much!


Glad to hear that helped. Here's a couple of screengrabs in case it helps someone else in another year!

The triggering option in KM


And how it's handled in TP

1 Like

Thank you all who contributed to this thread. As a TouchPortal user it was very informative.
I am curious why the Devs have created a plug-in for Streamdeck but nothing for TouchPortal? Is there a way to request something like this? I would expect there is a demand.

They have a forum, but from what I've seen it's mostly gamers, so maybe that's why there's no integration with KM yet.