Skip to content
David King edited this page Sep 26, 2025 · 18 revisions

Contents

About

There's a bit of a trick to using Unicode characters in AutoKey scripts and phrases without first putting them onto the clipboard. The syntax varies slightly depending on whether you're printing one or more Unicode characters or interspersing the Unicode characters with single characters. Emojis also pose their own unique challenges and have their own requirements. Below are some examples.

Unicode characters in phrases:

You can use the key-combination that creates a Unicode character inside of a phrase and it will be converted to a Unicode character. No quotes are needed around it and spaces or plus signs should be used after the key-combinations.

Important rules to keep in mind:

  • You should use the key-combination that creates a Unicode character for these (a press of the Ctrl key, Shift key, u, and the Unicode character-code done by stringing them together with plus signs).
  • This will only work on Unicode character-codes that use the base-ten positional numeral system (that contain all digits and no letters).
  • This will display any Unicode character that has only four digits in its Unicode character-code.
  • This will not display the result in color even if an actual character or emote is in color.
  • If a Unicode character will be the last or only character you print, an additional key-press is required to get rid of the tooltip. In the examples, I inserted a space or a plus sign at the end of each string. Note that neither the space nor the plus sign will be printed, but are simply a way to communicate with AutoKey that you're done creating the character. If a space or plus sign is desired after the Unicode character, an additional space or plus sign must be inserted.
  • You can insert as many Unicode characters as you like into a string that contains just Unicode characters. In that case, you have two choices: You can put a space or plus sign after each key-combination or just put one space or plus sign at the end of all of the key-combination.
  • If you create a string that's a mixture of single characters and Unicode characters, each key-combination must end with a space or plus sign.

To print a single Unicode character:

Add a space after the key-combination:

<ctrl>+<shift>+u+0108

Or add a plus after the key-combination:

<ctrl>+<shift>+u+0108+

Result:

Ĉ

Or paste the Unicode character into a phrase and change the "Paste using" phrase setting to "Clipboard".

To print several Unicode characters:

Add a space after the last key-combination:

<ctrl>+<shift>+u+0108<ctrl>+<shift>+u+0108<ctrl>+<shift>+u+0108<ctrl>+<shift>+u+0108

Or add a plus sign after the last key-combination:

<ctrl>+<shift>+u+0108<ctrl>+<shift>+u+0108<ctrl>+<shift>+u+0108<ctrl>+<shift>+u+0108+

Result:

Ĉ❂♣❀

Or paste the Unicode characters into a phrase and change the "Paste using" phrase setting to "Clipboard".

To print a mixture of single characters and Unicode characters:

Add a space after each key-combination:

foo<ctrl>+<shift>+u+0108 foo<ctrl>+<shift>+u+0108 foo

Or add a plus sign after each key-combination:

foo<ctrl>+<shift>+u+0108+foo<ctrl>+<shift>+u+0108+foo

Result:

fooĈfooĈfoo

Unicode characters in scripts:

Important rules to keep in mind:

  • You should use keyboard.send_keys() for these, because they're multi-byte characters.
  • You cannot use keyboard.send_key() for these, because they're not technically single characters.
  • This will only work on Unicode character-codes that use the base-ten positional numeral system (that contain all digits and no letters).
  • This will display any Unicode character that has only four digits in its Unicode character-code.
  • This will not display the result in color even if an actual character or emote is in color.
  • If a Unicode character will be the last or only character you print, an additional key-press is required to get rid of the tooltip. The examples below contain a space or a plus sign at the end of each string. Note that neither the space nor the plus sign will be printed, but are simply a way to communicate with AutoKey that you're done creating the character. If a space or plus sign is desired after the Unicode character, an additional space or plus sign must be inserted.
  • When deciding whether to use a space or a plus sign at the end of each Unicode string, note that either one will be dropped automatically as part of the conversion to Unicode, but since the plus sign is visible to the human eye, it can be more obvious when debugging your scripts.
  • You can insert as many Unicode characters as you like into a string that contains just Unicode characters. In that case, you have two choices: You can put a space or plus sign after each of the characters or just put one space or plus sign at the end of all of the characters.
  • If you create a string that's a mixture of single characters and Unicode characters, each Unicode character must end with a space or plus sign.
  • In any of the example scripts below, wherever you see u being used to reference a Unicode character, you can use uU instead. It does the same thing, but it is an alternate syntax that may be preferable. You can also just use U, or, in fact, any sequence of u and U, such as <ctrl>+<shift>+uUUuuUUu+0108 .

To print a single Unicode character:

Add a space after the Unicode character:

keyboard.send_keys("<ctrl>+<shift>+u+0108 ")

Or add a plus sign after the Unicode character:

keyboard.send_keys("<ctrl>+<shift>+u+0108+")

Result:

Ĉ

To print several Unicode characters:

Add a space after the last Unicode character:

keyboard.send_keys("<ctrl>+<shift>+u+0108<ctrl>+<shift>+u+2742<ctrl>+<shift>+u+2663<ctrl>+<shift>+u+2740 ")

Or add a plus sign after the last Unicode character:

keyboard.send_keys("<ctrl>+<shift>+u+0108<ctrl>+<shift>+u+2742<ctrl>+<shift>+u+2663<ctrl>+<shift>+u+2740+")

Or add a space after each Unicode character:

keyboard.send_keys("<ctrl>+<shift>+u+0108 <ctrl>+<shift>+u+2742 <ctrl>+<shift>+u+2663 <ctrl>+<shift>+u+2740 ")

Or add a plus sign after each Unicode character:

keyboard.send_keys("<ctrl>+<shift>+u+0108+<ctrl>+<shift>+u+2742+<ctrl>+<shift>+u+2663+<ctrl>+<shift>+u+2740+")

Result:

Ĉ❂♣❀

Note that if you want to end the string with a unicode character and then one space, you will have to add two spaces in the end, even if you end the unicode sequence with a +.

So:

keyboard.send_keys("<ctrl>+<shift>+u+2740+ ")

or

keyboard.send_keys("<ctrl>+<shift>+u+2740 ")

will both give this, with one space after the nice flower:

To print a mixture of single characters and Unicode characters:

Add a space after each Unicode character:

keyboard.send_keys("foo<ctrl>+<shift>+u+0108 foo<ctrl>+<shift>+u+0108 foo")

Or add a plus sign after each Unicode character:

keyboard.send_keys("foo<ctrl>+<shift>+u+0108+foo<ctrl>+<shift>+u+0108+foo")

Result:

fooĈfooĈfoo

To print a character that won't print:

When you come across a character that won't print by using the above techniques, try putting it onto the clipboard and pasting it. Build your string in a variable or in the clipboard API call, then add a delay, and then paste it. For example:

clipboard.fill_clipboard("ã")
time.sleep(0.1)
keyboard.send_keys("<ctrl>+v")

Result:

ã

Note that when you operate on the clipboard, a delay is usually required after the API call to give it time to complete, because the call immediately returns successfully even though the action is being asynchronously processed in another thread. That's an artifact of the way the upstream clipboard libraries we use work and applies to both front ends.

To wrap text around a selection that contains one or more graphical Unicode characters:

When you have some text selected in a window, if it contains Unicode characters that AutoKey won't work with, you can get around that by letting the operating system intercept your key-combinations and handle the copying and pasting for you, bypassing AutoKey entirely for that part of the task. The way it works is that the operating system copies your selected text, then AutoKey deletes your selection and inserts the first part of your wrapper, then the operating system pastes your Unicode in, and then AutoKey inserts the last part of your wrapper. In this example, the first part of the wrapper is an opening <p> tag and the last part of the wrapper is a closing </p> tag.

keyboard.send_keys("<ctrl>+c")
keyboard.send_keys("<p>")
keyboard.send_keys("<ctrl>+v")
keyboard.send_keys("</p>")

Or the same thing as a two-liner:

keyboard.send_keys("<ctrl>+c")
keyboard.send_keys("<p><ctrl>+v</p>")

Or the same thing as a one-liner:

keyboard.send_keys("<ctrl>+c<p><ctrl>+v</p>")

Thanks go to Johnny Rosenberg and Kreezxil for coming up with this approach.

Emojis

About emojis

Emojis pose some unique challenges because they're reliant not only on the choices made in AutoKey, but also on the environment they're being using in. As a result, it can be tricky to figure out just the right combination of options and/or settings and/or environment when working with emojis. Below are some examples with possible results and some troubleshooting suggestions.

Emojis in phrases

  • Phrase examples with shortcodes:

    • Phrase:
      • Example phrase name: moon
      • Example abbreviation: moon
      • Example phrase contents: :moon:
    • Result:
      • Paste using Clipboard(Ctrl+Shift+V) pastes nothing.
      • Paste using Clipboard(Ctrl+V) pastes the raw contents of the phrase (:moon:).
      • Paste using Clipboard(Shift+Insert) pastes the raw contents of the phrase (:moon:).
      • Paste using Keyboard: Using the default or the Trigger immediately (don't require a trigger character) or the Trigger when typed as part of a word abbreviation settings in various programs produces either the raw contents of the phrase (:moon:) or nonsense or nothing or the Unicode HEX (1f314) or the 🌔 emoji.
  • Phrase examples with emojis:

    • Phrase:
      • Example phrase name: moon
      • Example abbreviation: moon
      • Example phrase contents: 🌔
    • Result:
      • Paste using Clipboard(Ctrl+Shift+V) pastes nothing.
      • Paste using Clipboard(Ctrl+V) pastes the 🌔 emoji.
      • Paste using Clipboard(Shift+Insert) pastes the 🌔 emoji.
      • Paste using Keyboard: Using the default or the Trigger immediately (don't require a trigger character) or the Trigger when typed as part of a word abbreviation settings in various programs produces either nothing or the 🌔 emoji.

Emojis in scripts

  • Script examples with shortcodes:
    • Script:
      • Example script name: moon
      • Example abbreviation: moon
      • Example script contents: keyboard.send_keys(":moon:")
    • Result:
      • Using the default or the Trigger immediately (don't require a trigger character) or the Trigger when typed as part of a word abbreviation settings in various programs produces either nonsense or the raw contents of the keyboard API call (:moon:)or the 🌔 emoji.
  • Script examples with emojis:
    • Script:
      • Example script name: moon
      • Example abbreviation: moon
      • Example script contents: keyboard.send_keys("🌔")
    • Result:
      • Using the default or the Trigger immediately (don't require a trigger character) or the Trigger when typed as part of a word abbreviation settings in various programs produces either nonsense or the Unicode HEX (1f314) or the 🌔 emoji.

Emoji troubleshooting

  • The various phrase options and abbreviation settings can influence the output, so it can be helpful to try various combinations of any or all of them to get the desired result.
  • The target program can also affect whether or not an emoji is displayed or how it's displayed (one program may display the shortcode while the other renders it as an emoji, etc.), so you may be able to get around a resistant program by using a different program with AutoKey and then copying and pasting that program's text into the target program.
  • If a phrase works best for you and you'd like to use a script, you can run a phrase from a script to get the desired effect.
  • If it's still not possible to work with an emoji, the Unicode Consortium provides a full list of emoji characters that includes the Unicode for each one. Some or all of them can be accessed by using the Unicode characters in phrases steps above. For example, any of these commands will produce a moon emoji:
    keyboard.send_keys("<ctrl>+<shift>+u1f314 ")
    keyboard.send_keys("<ctrl>+<shift>+u1f314+")
    keyboard.send_keys("<ctrl>+<shift>+u+1f314 ")
    keyboard.send_keys("<ctrl>+<shift>+u+1f314+")

Clone this wiki locally