Launch Macro from iOS Device

Looking for a way to run a Macro on my Mac but triggered from my iOS device, is this possible? This is handy for shutting down a Mac/locking it, etc.

I guess it's a remote web trigger, is there a tutorial somewhere for this?

Hi @bocciaman, in this post you will find a way to trigger a KM macro via a shortcut SSH action on the Mac.

In the video you will find at minute 1:20 an instruction for the SSH action.
Please note that this only works on the same network.

Another possibility would be the triggering via an iCloud Drive action:

Simply save a text file in a separate folder (iCloud Drive / Siri Shortcuts) and monitor it with a KM macro to trigger your actions on the Mac.

MacAlarm

1 Like

Why not use the Keyboard Maestro Control app that’s in the App Store? It gives access to all your macros. Just saying.

I just downloaded the app but will try shortcuts as well.

I used the KM app yesterday but now all my Macros are available via the app. is there a way to designate a group or specific Macro only to appear on the iOS app?

By the way, everyone the app is no longer updating.

When I want to launch a KM macro from my iOS device, I set up a remote trigger for the macro:

morning music

Then I create an iOS Shortcut that does a HTTP GET using the URL from the remote trigger that I copied from the KM macro.

IMG_1881 ×0.5

This has been working flawlessly for me. I use this often to allow me to trigger KM macros from anywhere using Siri and HomePods placed around the house. It also allows me to mix HomeKit device control with KM macros.

5 Likes

Thank you! I just used this and it worked perfectly. I will likely be using it for several more macros.

1 Like

OMG, I finally got around to trying this trigger via iOS. It worked like a charm. Thank you, so much!

Glad it is working for you. I have a bunch of home automation macros in KM what I fire from shortcuts and Siri. It allows me to perform really complex HA sequences that are either impossible to perform in shortcuts or would be super difficult.

1 Like

Touch Portal iOS & iPadOS has a Keyboard Maestro plugin. Use it, and you can run macro like Stream Deck!

1 Like

I have a KM macro that uses an Applescript to use a text file of Random Signatures to place a sig at the end of an email. On my Mac, I've always just used a keystroke (=rs) to trigger and it works just fine. I used the examples above and I can get Siri to run the Shortcut on my Mac and that works as expected. But, on my iPhone, Siri will run the Shortcut and tell me it's Done, but no text is placed where the cursor is, say in Messages. Do I need to add something to get this working on the iPhone/iPad?

Keyboard Maestro macros won't run on the iPhone or iPad, they only run on the Mac.

Did you follow the whole thread? It does seem there is a way to execute KM macros from iOS.

Sorry, I read this as that you wanted to automate entering the text in the Messages App on your iPhone.

From my understanding, as long as the Shortcuts are in sync across your devices, it should be the same Shortcut that gets run on the iPhone and that will trigger the Keyboard Maestro Macro on the Mac.

This is the Apple Shortcut that works for me (run from either Mac or iPhone)

@Zabobon, yes, the KM macro uses an Applescript to pull a Random Signature from a text file. When I trigger the macro, either by =rs or by running the Shortcut via Siri, the random signature is pasted where ever the cursor is in a document or message or email (which is really the only place I need it.) If I go back to the Mac, even quite a bit of time later, the random signature text is still on the Mac clipboard as I can CMD-V and paste it again and again.

I have Handoff on for both the Mac and my iPhone and they use the same AppleID. But when I place my finger at the end of an email where the random signature would go, I do not get the option to Paste when holding my finger down. That's the missing part of this for me. Ideas?

So, you want to create a random signature and be able to paste this on your iPhone?

I don't think using an Apple Shortcut to remotely trigger a Keyboard Maestro macro, which places that signature on the Mac clipboard and then using Handoff to paste this on the iPhone is going to work (at least not consistently). It might be tripping up at the moment because the way the AppleScript puts the signature on the Mac Clipboard doesn't trigger Handoff in the same way as if you manually copy something on the Mac with ⌘C.

To get something reliable you might be better off making a new Apple Shortcut that does all of what you want (i.e. chooses a random signature from a list and puts that on the iPhone clipboard, ready to paste). I did a quick search and it looks like Apple Shortcuts is able to pick a random piece of text from a choice.

For a Keyboard Maestro solution, it feels like this is a specific enough task that you might get more answers if you start a new thread and ask for help or ideas for this task.

@Zabobon Thank you! For my needs, the KM macro running the Applescript has worked very well for years so I think leaving well enough alone is the right thing.

Now, it's a question of translating the Applescript to a Shortcut, then have "Hey, Siri" run the Shortcut at the end of an email and I'm set. I'm not a coder so it's likely some kind soul on macscripter.net helped me with all that code. Since this is a KM forum, I'll see if I can find a Shortcuts site and get some help there. You've started me on the path with your last post and I can tell you how much I really appreciate that.

@Zabobon Thanks so very much for setting me down the better path. With some help from another group, I got the Shortcut put together so now I can use the KM macro on my Mac and the Shortcut on my iDevices.

1 Like