ASCII Macros with AutoHotKey

TL;DR

This article describes how to use AutoHotKey to type ASCII text sequences, such as the always-useful ShrugDude or shruggie ( ¯\_(ツ)_/¯ ).

Background

As a remote worker, a huge percentage of my communication with my coworkers involves using chat tools, such as Microsoft Teams. (I’ve shared my Tips for Successful Remote Work in a previous post – spoiler: Communication Tools/Services are critical!)

Not only are emoji a quintessential part of chat tools, they are becoming an even bigger part of all digital communication. The shrug/shrugging emoji was once available in the chat environment I used and I found myself using it a good bit. Unfortunately, it’s not available in the chat tool I’m using these days (*ahem* Microsoft Teams *ahem*), so I’ve had to find other ways to express the shrug.

I located the ASCII text sequence for the shrug at www.shrugdude.com, but I often need to access it quickly. I’ve written previously about using AutoHotKey to set up keyboard macros for my media keys. Why not use an AutoHotKey macro for ShrugDude too?

The biggest challenge is that most of the characters used by ShrugDude (and many other art-like text sequences) require some special handling in order to be included in an AutoHotKey macro.

The key is that you have to determine the numeric value that the system uses to represent the special character and then use AutoHotKey’s chr() function to have it render the desired character.

Steps

Below are the steps for configuring a hotkey combination for quickly typing ASCII text sequences.

Note: The specifics of these steps are subject to change as software is updated. But the concepts should remain consistent.

  1. Download and install AutoHotKey (free download).
  2. Create a new text file to use for the macro, call it MyMacros.ahk (the “ahk” extension is used by AutoHotKey). Edit this file in a text editor, such as NotePad++ (also a free download) .
  3. Create a variable to hold the sequence of characters for ShrugDude in the text file, followed by the assignment operator (colon + equals):

    ShrugDude :=

  4. Copy the text for ShrugDude from http://www.shrugdude.com. Paste into NotePad++.
  5. Turn on the Conversion Panel from the Converter Plugin, which is installed by default:
  6. Copy the first character of ShrugDude and paste it into the “ASCII” box on the Conversion Panel:
  7. Copy the value from the Decimal field and add the numeric value to the chr() function following the assignment of the ShrugDude variable, without spaces or commas. For instance, the Decimal value for the first character is 175, so it should look like this: ShrugDude := chr(175)
  8. Repeat Steps 6 and 7 for each character in the sequence. After all characters, the ShrugDude variable assignment should look like this:

    ShrugDude := chr(175)chr(92)chr(95)chr(40)chr(12484)chr(41)chr(95)chr(47)chr(175)

  9. Decide which keystroke you plan to use to trigger the macro; I’m using CTRL + F1. Using AutoHotKey’s syntax, bind Ctrl + F1 to the command to send the ShrugDude variable to the keyboard:

    ^F1:: Send %ShrugDude%

  10. Double-click the “MyMacros.ahk” file, which should associate it with AutoHotKey and make the hotkey available system-wide.
  11. Type Ctrl + F1 in a new text document and you should see ShrugDude looking back at you!

The entire MyMacros.ahk file for ShrugDude should look like this:

ShrugDude := chr(175)chr(92)chr(95)chr(40)chr(12484)chr(41)chr(95)chr(47)chr(175)
^F1:: Send %ShrugDude%

And now, you can quickly add ShrugDude when needed by just typing a keystroke: ¯\_(ツ)_/¯

You can use other keystrokes for any combination of literal characters or ASCII characters. You can really enhance your chat experience, which will make you the office fun guy…

Moss and mushrooms in the park near Juneau

3 thoughts on “ASCII Macros with AutoHotKey

  1. Hello, Mark!

    Thank you for the How-to!

    I was looking for a tutorial on how to use ASCII characters with Autohotkey, since the answers I found online didn’t seem to help. I followed your example and voilà! I have my AHK script working. Turns out I was using the CHR function wrong. And I didn’t know about the Conversion panel on Notepad++!

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s