How do I write to console in AutoIt?
As per Documentation - Function Reference - ConsoleWrite()
:
The purpose for this function is to write to the STDOUT stream. … Scripts compiled as Console applications also have a STDOUT stream.
Save script as .au3
file, then:
press F5 (Tools > Go) in editor. Console output will be displayed in the editor's lower pane:
or press Ctrl + F7 (Tools > Compile), enable Create CUI instead of GUI EXE.
, then click Compile Script
and run the resulting executable.
- or add
#AutoIt3Wrapper_Change2CUI=Y
(or #pragma compile(Console, True)
) to top of script, then press F7 (Tools > Build) and run the resulting executable.
- or execute:
...\AutoIt3\Aut2Exe\Aut2exe.exe /in ...\script.au3 /out ...\script.exe /console
and run the resulting executable.
I compiled the script using Aut2Exe. It still does not print to console.
For compiled scripts a console window is visible during runtime only. Example:
#AutoIt3Wrapper_Change2CUI=Y
Global Enum $EXITCODE_OK
Global Const $g_sMsg = 'Hello, World!' & @CRLF
Global Const $g_iDelay = 1000 * 10
Main()
Func Main()
ConsoleWrite($g_sMsg)
Sleep($g_iDelay)
Exit $EXITCODE_OK
EndFunc
Related: Console and graphical user interface.