#EscapeChar (and explanation of escape sequences)

Homepage
Command List

Changes the script's escape character (e.g. accent vs. backslash).

#EscapeChar NewChar

Parameters

NewChar Specify a single character.

Remarks

The escape character is used to indicate that the character immediately following it should be interpreted differently than it normally would.

The default escape character for AutoIt v2 (.aut) scripts is backslash (\). For all other file extensions, including all compiled scripts, the escape character defaults to accent/backtick (`). When a .aut script is auto-converted into a .ahk script, the backslash escape character is globally replaced with the accent character.

Escape Sequences (when accent is the escape character)

Type This To Get This
`, , (literal comma). Note: Commas that appear within the last parameter of a command do not need to be escaped because the program knows to treat them literally. The same is true for all parameters of MsgBox because it has smart comma handling.
`% % (literal percent)
`` ` (literal accent; i.e. two consecutive escape characters result in a single literal character)
`;  ; (literal semicolon). Note: This is necessary only if a semicolon has a space or tab to its left. If it does not, it will be recognized correctly without being escaped.
`:: :: (literal pair of colons). In v1.0.40+, it is no longer necessary to escape these.
`n newline (linefeed/LF)
`r carriage return (CR)
`b backspace
`t tab (the more typical horizontal variety)
`v vertical tab -- corresponds to Ascii value 11. It can also be manifest in some applications by typing Control+K.
`a alert (bell) -- corresponds to Ascii value 7. It can also be manifest in some applications by typing Control+G.
`f formfeed -- corresponds to Ascii value 12. It can also be manifest in some applications by typing Control+L.
Send When the Send command or Hotstrings are used in their default (non-raw) mode, characters such as {}^!+# have special meaning. Therefore, to use them literally in these cases, enclose them in braces. For example: Send {^}{!}{{}
"" Within an expression, two consecutive quotes enclosed inside a literal string resolve to a single literal quote. For example: Var := "The color ""red"" was found."

Related

The following rarely used directives also exist; their usage is shown in these examples:

#DerefChar #  ; Change it from its normal default, which is %.
#Delimiter /  ; Change it from its normal default, which is comma.

Example

#EscapeChar \  ; Change it to be backslash instead of the default of accent (`).

Homepage  |  Command List