The issue I'm running into is that these links use a lot of percentage signs, which is the same syntax that KM uses, so those links get messed up (since KM is trying to interpret these percentage signs as variables). Is there some sort of way around this?
For example, a base "create new task with X text" would look like this for the URL scheme:
The three percent signs there screw stuff up. Any ideas? Thanks!
I hate to bump an old topic, but has anyone gotten this working? I have the exact same URL working in the Shortcuts app, but when I try to run it on my Mac, Keyboard Maestro tells me it's an invalid URL. I've tried setting the action gear for the URL action to both process text normally and process nothing, and both result in the same error.
No worries about bumping the old topic; people do that all the time here. As for your question, it's hard to say what might be going on without seeing the URL in question. Can you share it here, along with the macro you're using to try to open it?
Like OP, I am trying to pass variables into the Things 3 URL scheme to function as a template. I've successfully made a similar workflow using Shortcuts for my iOS devices. I've also been able to create an Alfred workflow, but I much prefer the interface of KBM.
Here's the full macro.
Note: I can copy that same URL onto my iOS device or open it via Google Chrome on my Mac and it works just fine minus passing the actual variables, so there doesn't seem to be an actual issue with the URL but KBM thinks there is.
Also, I've done some testing and KBM seems to have no problem with the first part of the URL. As soon as I enter %Variable%Title% the Open URL text turns orange to report an error.
Thanks for sharing. As you suspected, KM is indeed getting mixed up with the % signs used for variables and the ones used in percent encoding for URLs. The way I'd go about resolving this is to assemble the URL in a KM variable first, run a filter on the entire URL to percent encode it, then open the encoded URL variable:
This also has the advantage of making it easier to change the resulting to-do item, since you can edit the title, checklist, notes, and other fields in plain text without worrying about hard-URL encoding everything.
Note that Keyboard Maestro itself does not care anything about the format of the URL, however the URL is stored within a system NSURL object, and NSURL will only allow valid URLs, so it is NSURL that is rejecting the URL as invalid.
Also note that if you are processing text tokens (as controlled by the gear menu in the action), then you must deal with the fact that % is special to Keyboard Maestro, and so where you want an explicit % sign in the URL you need to double it, so eg:
@gglick’s solution is a better solution, since all the % tokens in the Set Variable action are intended for Keyboard Maestro to process, and all the percent tokens needed in the URL are created by the Filter action.
Sorry for such a late reply on this. The end of the year got away from me with completing my Masters and the holidays. This is exactly what I needed. Thank you so much. Seeing it broken down this way helped me port over all my existing Omnifocus templates and I'm back in business with Things. My workflow and frustration levels thank you!
@gglick Thank you so much for posting this macro. I have one question. I used it as is to better understand how it works and it doesn't separate the checklist items into individual items, just one large item with all the lines (See screenshot). I tried adding a %0A at the end of each line --- getting that from the URL building for things and it just pastes it into the checklist.
Is there anything obvious that I am missing? I appreciate it.
I'm glad you found it useful, or at least will once it's working as expected for you. Unfortunately, I'm afraid I don't know what to tell you, as the macro continues to work as expected for me without %0A, which should be added automatically by the filter action. I don't suppose quitting and relaunching Things changes anything?
Hey there, okay, so you mentioned "should be automatically filtered" do I tried deleting the line breaks and then reinserting them. I imported the macro and for some reason, KM stripped the line breaks. Re-adding them worked and now it worked. Thanks for the tip, and thanks for the great script.
I tried your macro, but when I try it, I receive this message from Things 3: The URL scheme cannot be empty and must be set to "things:"
Perhaps I'm missing something, since I'm new to Keyboard Maestro....
Welcome to the forum. You're not missing anything, it's just that the way KM's URL percent encode filter changed between version 8, when that macro was originally posted, and version 9, which came out several months later. If you're new to KM you're almost certainly using version 9, so this updated version should work with that: