Sends any syntax error that prevents a script from launching to the standard error stream (stderr) rather than displaying a dialog.
An encoding string specifying how to encode the output. For example,
#ErrorStdOut "UTF-8" encodes error messages as UTF-8 before sending them to stderr. Whatever program is capturing the output must support UTF-8, and in some cases may need to be configured to expect it. If omitted, it defaults to
Note: This parameter is not an expression, but can be enclosed in quote marks (either 'single' or "double").
Errors are written to stderr instead of stdout. The command prompt and fancy editors usually display both.
This allows fancy editors such as TextPad, SciTE, Crimson, and EditPlus to jump to the offending line when a syntax error occurs. Since the #ErrorStdOut directive would have to be added to every script, it is usually better to set up your editor to use the command line switch /ErrorStdOut when launching any AutoHotkey script (see further below for setup instructions).
Because AutoHotkey is not a console program, errors will not appear at the command prompt directly. This can be worked around by 1) compiling the script with the Ahk2Exe ConsoleApp directive, or 2) capturing the script's output via piping or redirection. For example:
"C:\Program Files\AutoHotkey\AutoHotkey.exe" /ErrorStdOut "My Script.ahk" 2>&1 |more "C:\Program Files\AutoHotkey\AutoHotkey.exe" /ErrorStdOut "My Script.ahk" 2>"Syntax-Error Log.txt"
You can also pipe the output directly to the clipboard by using the operating system's built-in clip command. For example:
"C:\Program Files\AutoHotkey\AutoHotkey.exe" /ErrorStdOut "My Script.ahk" 2>&1 |clip
2>&1 causes stderr to be redirected to stdout, while
2>Filename redirects only stderr to a file.
Like other directives, #ErrorStdOut cannot be executed conditionally.
C:\Windows\System32\cmd.exe-- then press OK.
cmd.exe(or the full path to it)
/c ""C:\Program Files\AutoHotkey\AutoHotkey.exe" /ErrorStdOut "$File""
FileAppend (because it can also send text to stderr or stdout)