JohnJF Posted January 15, 2010 Share Posted January 15, 2010 Hi, I cannot get the following to work - print a text string to stdout: ConsoleWrite("hello, world" & @CRLF) When I run it (hello.au3) using winxp command console, nothing happens and it exits to the shell. Do I miss something? Thanks for help! I did try to search the forum, but did not find anything to solve the issue. If it is already asked before, would appreciated the link. Link to comment Share on other sites More sharing options...
pbsds Posted January 15, 2010 Share Posted January 15, 2010 You must compile the script as a command line application to see it. if you need to test very often you can run the script in scite using F5. the the printed text will be shown in the box under the source editing box. Fuck 'em if they can't take a joke. Link to comment Share on other sites More sharing options...
JohnJF Posted January 15, 2010 Author Share Posted January 15, 2010 Thanks! Running the following and then hello.exe solves the problem: "c:\Program Files\AutoIt3\Aut2Exe\Aut2exe.exe" /in hello.au3 /out hello.exe /console However, just wonder why running .au3 directly on cmd console does not work. It would be nice to have that feature: have to compile the script to use ConsoleWrite is not really convenient. A follow-up question: can you (and if so how to) specify the command line arguments when running hello.au3 in the editor (your 2nd workaround)? Link to comment Share on other sites More sharing options...
water Posted January 15, 2010 Share Posted January 15, 2010 You can use the following Au3Wrapper directive to run your exe as an console application: #AutoIt3Wrapper_Change2CUI=Y ConsoleWrite("Hello World" & @CRLF) BlackLumiere 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 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 15, 2010 Moderators Share Posted January 15, 2010 JohnJF,And you can run with parameters in SciTE by pressing "Shft-F8" or by using the <View - Parameters> menu item.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
JohnJF Posted January 15, 2010 Author Share Posted January 15, 2010 But you still need to compile it and run the hello.exe, *not* hello.au3, right? I mean you cannot just add the line: #AutoIt3Wrapper_Change2CUI=Y and run hello.au3 and get the same result. I would prefer just have an .au3 file and run it on command line w/o any compile or other procedures. The interpreter seems not able to detect it is now running in console mode and print to stdout correctly. Link to comment Share on other sites More sharing options...
JohnJF Posted January 15, 2010 Author Share Posted January 15, 2010 JohnJF,And you can run with parameters in SciTE by pressing "Shft-F8" or by using the <View - Parameters> menu item.M23Cool! This will be handy. However, I still hope some future version can support the general command line usage, Shft-F8 only allows 4 args., this is really argc/argv in C program, and will make it easy to script and prototype. Link to comment Share on other sites More sharing options...
Developers Jos Posted January 15, 2010 Developers Share Posted January 15, 2010 (edited) But you still need to compile it and run the hello.exe, *not* hello.au3, right? I mean you cannot just add the line: #AutoIt3Wrapper_Change2CUI=Y and run hello.au3 and get the same result. I would prefer just have an .au3 file and run it on command line w/o any compile or other procedures. The interpreter seems not able to detect it is now running in console mode and print to stdout correctly. Its simple to explain as the AutoIt3.exe is compiled a GUI not a CUI. Have you tried to compile a script as CUI and then use that script to run the script with by using this format: Compiled.exe [/ErrorStdOut] [/AutoIt3ExecuteScript file] [params ...] Jos Edited January 15, 2010 by Jos 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. Link to comment Share on other sites More sharing options...
Developers Jos Posted January 15, 2010 Developers Share Posted January 15, 2010 Cool! This will be handy. However, I still hope some future version can support the general command line usage, Shft-F8 only allows 4 args., this is really argc/argv in C program, and will make it easy to script and prototype.Just put multiple arguments in one box 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. Link to comment Share on other sites More sharing options...
JohnJF Posted January 15, 2010 Author Share Posted January 15, 2010 Its simple to explain as the AutoIt3.exe is compiled a GUI not a CUI. Have you tried to compile a script as CUI and then use that script to run the script with by using this format: Compiled.exe [/ErrorStdOut] [/AutoIt3ExecuteScript file] [params ...] Jos Can you give an example how to do this - how to write the compiled.au3? I assume then you can use the compiled.exe to run any .au3 script. This sounds to me that the compiled.au3/compiled.exe is the interpreter itself, but in CUI mode. Link to comment Share on other sites More sharing options...
Developers Jos Posted January 15, 2010 Developers Share Posted January 15, 2010 (edited) Its pretty simple. Stub Script (mystub.au3) #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; CUI stub Compile it. test1.au3 script: ConsoleWrite("hallo") Now run this in the commandprompt: mystub.exe /AutoIt3ExecuteScript test1.au3 Thats all, Jos Edited January 15, 2010 by Jos 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. Link to comment Share on other sites More sharing options...
JohnJF Posted January 15, 2010 Author Share Posted January 15, 2010 Hi Jos, this does work for my hello.au3. However, I run into issues with script using include, eg, the following: #include <Array.au3> ConsoleWrite("hello, world" & @CRLF) $length = _ArraySize( $CmdLine ) ConsoleWrite("command line array length is: " & String($length)) Func _ArraySize( $aArray ) SetError( 0 ) $index = 0 Do $pop = _ArrayPop( $aArray ) $index = $index + 1 Until @error = 1 Return $index - 1 EndFunc Running the above pops up an error message, complaining that "Array.au3" cannot be opened. Do you know if this can be fixed? Its pretty simple. Stub Script (mystub.au3) #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; CUI stub Compile it. test1.au3 script: ConsoleWrite("hallo") Now run this in the commandprompt: mystub.exe /AutoIt3ExecuteScript test1.au3 Thats all, Jos Link to comment Share on other sites More sharing options...
Developers Jos Posted January 15, 2010 Developers Share Posted January 15, 2010 Running the above pops up an error message, complaining that "Array.au3" cannot be opened. Do you know if this can be fixed?Should work fine when you put it in the same directory as the Autoit3.exe.Jos 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. Link to comment Share on other sites More sharing options...
JohnJF Posted January 15, 2010 Author Share Posted January 15, 2010 Sweet - works now! Thanks for all the help and creating AutoIt! It is really cool and I guess I will sink lots of time into it :-)Should work fine when you put it in the same directory as the Autoit3.exe.Jos Link to comment Share on other sites More sharing options...
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