Trong Posted November 22, 2025 Posted November 22, 2025 (edited) Debug-console version of AutoIt3.exe and AutoIt3_x64.exe? I want to test my script (it already passes Au3Check.exe) by running it through CMD, and I want any errors (crashes, syntax errors, array index issues, invalid assignments, etc.) to be printed directly to the console instead of stopping the program and showing an error message box. Those pop-up error dialogs make debugging difficult because I have to switch back to SciTE every time. What I’m asking for is a console-mode debug version of AutoIt3.exe/AutoIt3_x64.exe that, when an error occurs, prints the error to the console and exits immediately with a non-zero exit code. And with compiled scripts too, is it possible to print a message on console instead of showing it? Edited November 22, 2025 by Trong DonChunior 1 Enjoy my work? Buy me a 🍻 or tip via ❤️ PayPal
argumentum Posted November 22, 2025 Posted November 22, 2025 SciTE don't get those popups. They run with "/ErrorStdOut." Then you also have Opt("SetExitCode",1) 1 = Set @exitCode on Fatal error - see Exitcodes. If that is not enough then, let me know. P.S.: I really like the open source code you're integrating. Like really really like it. Thanks for that 💯 WildByDesign 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
argumentum Posted November 22, 2025 Posted November 22, 2025 I wrote an example some time ago too ( https://www.autoitscript.com/forum/topic/209902-optsetexitcode01 ) Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
argumentum Posted November 22, 2025 Posted November 22, 2025 #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Icons\au3script_v9.ico #AutoIt3Wrapper_Outfile=Autoit3cui.exe #AutoIt3Wrapper_Outfile_x64=AutoIt3_x64cui.exe #AutoIt3Wrapper_Compile_Both=y #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.16.1 Author: myName #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here FileChangeDir(@ScriptDir) ; my AutoIt is installed there Opt("TrayAutoPause", 0) ; Script pauses when click on tray icon = OFF/0 Opt("TrayOnEventMode", 0) ; Enable/disable OnEvent functions notifications for the tray = OFF/0 Opt("GUICloseOnESC", 1) ; When ESC is pressed on a GUI the $GUI_EVENT_CLOSE message is sent = ON/1 #pragma compile(Console, True) #pragma compile(AutoItExecuteAllowed, True) ..also used the above and instead of running a script with AutoIt3.exe, I would run it with Autoit3cui.exe If these cui versions are in the same folder as AutoIt3.exe, all will be running just fine. Trong 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Trong Posted November 23, 2025 Author Posted November 23, 2025 It seems not to be the optimal solution. Even running with /ErrorStdOut still does not show the error on the console, only when running with SCITE !! Does anyone know how to use this command? /ErrorStdOut Enjoy my work? Buy me a 🍻 or tip via ❤️ PayPal
water Posted November 23, 2025 Posted November 23, 2025 (edited) I had a similar problem a long time ago. A server application started my script. In rare cases, the script crashed due to faulty data. Trancexx helped me with this code. Edited November 23, 2025 by water Trong 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Developers Jos Posted November 23, 2025 Developers Posted November 23, 2025 Or make a simply RunConsole.au3 script and compile it: expandcollapse popup#AutoIt3Wrapper_Change2CUI=y $pgm = '"C:\Program Files (x86)\AutoIt3\AutoIt3.exe" /ErrorStdOut "' & $CMDLineRAW & '"' _RunCMDPgm($pgm) Func _RunCMDPgm($pgm) Local $pid $pid = Run($pgm, '', @SW_HIDE, 1 + 2 + 4) Local $handle = _ProcessExitCode($pid) ShowStdOutErr($pid) Local $exitcode = _ProcessExitCode($pid, $handle) _ProcessCloseHandle($handle) ConsoleWrite("+ Ended rc:" & $exitcode & @LF) SetError($exitcode) EndFunc ;==>_RunCMDPgm ; Func _ProcessExitCode($i_Pid, $h_Process = 0) ; 0 = Return Process Handle of PID else use Handle to Return Exitcode of a PID Local $v_Placeholder If Not IsArray($h_Process) Then ; Return the process handle of a PID $h_Process = DllCall('kernel32.dll', 'ptr', 'OpenProcess', 'int', 0x400, 'int', 0, 'int', $i_Pid) If Not @error Then Return $h_Process Else ; Return Process Exitcode of PID $h_Process = DllCall('kernel32.dll', 'ptr', 'GetExitCodeProcess', 'ptr', $h_Process[0], 'int*', $v_Placeholder) If Not @error Then Return $h_Process[2] EndIf Return 0 EndFunc ;==>_ProcessExitCode ; Func _ProcessCloseHandle($h_Process) ; Close the process handle of a PID DllCall('kernel32.dll', 'ptr', 'CloseHandle', 'ptr', $h_Process) If Not @error Then Return 1 Return 0 EndFunc ;==>_ProcessCloseHandle ; Func ShowStdOutErr($l_Handle) Local $Line, $tot_out, $err1 = 0, $err2 = 0 Do Sleep(10) $Line = StdoutRead($l_Handle) $err1 = @error ConsoleWrite($Line) $Lineerr = StderrRead($l_Handle) $err2 = @error ConsoleWrite($Lineerr) Until $err1 And $err2 Return EndFunc ;==>ShowStdOutErr Then run the script from the console with this compiled program: C:\test>RunConsole.exe "C:\test\test.au3" $CMDLineRAW=/ErrorStdOut ""C:\test\test.au3"" "C:\test\test.au3" (6) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $x [10] = 9 ^ ERROR + Ended rc:1 .. and bob's your uncle. 😉 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
genius257 Posted November 23, 2025 Posted November 23, 2025 (edited) Hi @Trong. The issue is the way AutoIt3.exe does outputs from it's runtime My suggestion is based on this: https://stackoverflow.com/a/54252275 "D:\Downloads\autoit-v3.3.16.1\install\AutoIt3.exe" /ErrorStdOut "D:\Downloads\autoit-v3.3.16.1\install\test.au3" 2>&1|more this was my test script: ConsoleWrite("ConsoleWriteTest"&@crlf) Local $x[1] $x[10] = 9 MsgBox(0, "aya", "yay") and here is the result: Edited November 23, 2025 by genius257 Trong 1 To show your appreciation My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser
Trong Posted November 23, 2025 Author Posted November 23, 2025 (edited) cool, it seems like a different way. Edited December 3, 2025 by Trong Enjoy my work? Buy me a 🍻 or tip via ❤️ PayPal
argumentum Posted November 23, 2025 Posted November 23, 2025 7 hours ago, Trong said: Even running with /ErrorStdOut still does not show the error on the console Because you need to "echo %ERRORLEVEL%". That is the "rc:1" on SciTE. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
argumentum Posted November 23, 2025 Posted November 23, 2025 ok, my bad I guess ( because I didn't test with errors as my code is always perfect ) AutoItCui.bat: @Echo OFF :: AutoItCui.bat ; name of the batch file that runs Autoit3cui Autoit3cui /ErrorStdOut /AutoIt3ExecuteScript %* echo rc:%errorlevel% With the above batch file you'd run your script. Say: Opt("SetExitCode",1) Global $a[1] $a[1] = 1 and the output would be: >Autoitcui MyFlaw.au3 "D:\Utilities\AutoIt3\MyFlaw.au3" (3) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $a[1] = 1 ^ ERROR rc:2147479674 were the 2147479674 errorlevel in hex is 0x7FFFF07A. So the code I posted in the beginning is all that is really needed. Trong 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now