Search code examples
autohotkey

How to use {\ in AutoHotKey?


I am using AutoHotKey to help me in my writing

So instead of writing {\color{red} I will just push one key and AutoHotKey will do the writing of the whole thing

P.S. I am repeating these letters hundreds of times in my paper.

When I used it in my AutoHotKey file like this

^4::Send {\color{red}

which does nothing, nothing was written in my paper

and when i use this

^4::{\color{red}

I get this error when i load the AutoHotKey file

---------------------------
My.ahk
---------------------------
Error at line 14.

Line Text: {\color{red}
Error: This line does not contain a recognized action.

The script was not reloaded; the old version will remain in effect.
---------------------------
OK   
---------------------------

Any idea how to get it wok?


Solution

  • When the Send command or Hotstrings are used in their default (non-raw) mode, characters such as {}^!+# have special meaning. To use them literally in these cases, enclose them in braces:

    ^4::Send {{}\color{{}red{}}
    

    or use the raw mode

    ^4::SendRaw {\color{red}
    

    or the Text mode (recommended):

    ^4::Send {Text}{\color{red}
    

    See also Escape Sequences