URL Remote Trigger and Multi-Line Parameters

Anyone managed to figure out how to send a multi-line parameter from an iOS shortcut to Keyboard Maestro?

KM sees the %TriggerValue% as only 1.

Did you try using %0D%0A which is the normal URL encoding for CR and LF?

1 Like

I may be doing it all wrong, but I tried this:

...and as you can see, no dice.

The URL Encode should work just fine without any manual replacements.

I think the value you're passing to the URL is the original Text box, instead of the output of the URL Encode action.

I set one up the same way to test, and by default my variable is called "URL Encoded Text".

(I blame Apple's inscrutably "friendly" layout that tries so hard to avoid variable names!)

1 Like

That was it!

1 Like

Hey @noisneil I might be confused as to what you’re attempting to accomplish, but the following works for me.

Shortcut Screenshot (click to expand/collapse)

Macro Screenshot (click to expand/collapse)

Trigger Value Screenshot (click to expand/collapse)

Hey Chris. That's not gonna work for iOS, unfortunately.

Ok so for context, I was intrigued by @Airy's iPhone-to-KM OCR idea, and I wondered if there might be another way of going about it that didn't have to involve iCloud.

I can get the text from multiple photos using the first two actions, but when it comes to returning them as a parameter to KM, it goes a bit squiffy if there's more than a single line.

Download the shortcut here.

1 Like

Well of course it won’t. I mainly use Shortcuts on macOS so I didn’t even think about how there’s no KM compatibility on iOS :laughing:

1 Like

Ahh, I see what you're trying to do. Yup, I shoulda spotted your variable error. If you get it all working, be sure to let us know.

1 Like

It's awfully frustrating, as it works great for one-liners. A bit like my sense of humour.

2 Likes

I had no joy with multi-line parameters, so here's another idea that uses Universal Clipboard instead:

Click here to download Shortcut

iPhone OCR.kmmacros (41 KB)

Macro screenshot

The shortcut copies the extracted text to the Universal Clipboard and sends the first line of it as a parameter when triggering the Keyboard Maestro macro remotely. This line is then used in a conditional pause, to wait until the start of the system clipboard's content matches it, before displaying the clipboard.

It works nicely for multi-line text. The only issue is that, although the shortcut successfully extracts text from multiple photos at once, for some reason, only the first photo's text seems to be copied across. Trying to get my head around that.

It would be great if we could fix that part, as without it you may as well just manually extract text from images to the clipboard on iOS.

It gets weirder...

If I check my clipboard contents (using Alfred, in my case), I can see both pieces of extracted text, and I can paste them as one. However, when Keyboard Maestro accesses %SystemClipboard%, only the second line is there!

This tells me that the shortcut is working just fine, and the problem is on Keyboard Maestro's end.

I like that approach better than my approach. The user would take all the photos first, then select them, then run the macro. Very good idea.

By that, I think you mean the website trigger.keyboardmaestro.com, not the Engine or Editor.

Actually, no. The clipboard is being set correctly via the Universal Clipboard, so it's an issue with %SystemClipboard% not reporting the current full clipboard contents, which is a Keyboard Maestro thing. I don't know enough about how KM reads the clipboard to say what's happening, but something's certainly amiss.

Given the above example:

⌘V pastes:

CREATINE
15.34

%SystemClipboard% displays:

15.34

At this point, the shortcut isn't a factor. I'm simply comparing the actual current clipboard contents to what %SystemClipboard% shows me.