KM not pasting slash-character

I'm trying to do some lightweight macro to insert copyright into the files I produce. I have a shortcut that formats todays date to only be the year in four digits and then I use that in a text field I want to paste in to my application (Sibelius). Sibelius uses this $something\ code as tokens so I want to input my name as such.

However, when pasting from the macro, KM doesn't input the first -sign. My guess is it's because it comes right after a variable but I don't know what to make of it.

As you can see I've tried inserting an extra space after System Clipboard but it doesn't help. I also tried copying the token from Sibelius in to the macro in case I had used the wrong character but it didn't help either.

Any explanations and possible workarounds?
CleanShot 2024-02-22 at 14.27.31

When the missing \ is in from of the $ only the value will be shown and not the token itself.

Try changing the problematic single \ to a double \ so that it escapes itself.

Also, you don't need to use the Apple Shortcut and clipboard to get the current year as four digits. You can make your Macro with one single Keyboard Maestro Insert text by pasting Action:

3 Likes

Didn't think to put an extra slash in. Worked perfectly – thanks!

Also: I had a suspicion that KM could format the date, but didn't know how. This is way easier. Double thanks!

3 Likes

Hi, @thomasbryla.

Like many programming languages, Keyboard Maestro uses the \ as an escape operator; thus one can use \\ to yield \.

For more information, including another approach, see this page of the wiki:

https://wiki.keyboardmaestro.com/action/Insert_Text

3 Likes

This makes sense now :slight_smile: I don't know any programming languages so this idea of an escape operator is new to me. Thank you!

2 Likes