Jump to content

Recommended Posts

Posted

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.

Posted

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. :D

Fuck 'em if they can't take a joke.

Posted

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)?

Posted

You can use the following Au3Wrapper directive to run your exe as an console application:

#AutoIt3Wrapper_Change2CUI=Y
ConsoleWrite("Hello World" & @CRLF)

My UDFs and Tutorials:

  Reveal hidden contents

 

  • Moderators
Posted

JohnJF,

And you can run with parameters in SciTE by pressing "Shft-F8" or by using the <View - Parameters> menu item.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:

  Reveal hidden contents

 

Posted

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.

Posted

  On 1/15/2010 at 4:16 PM, 'Melba23 said:

JohnJF,

And you can run with parameters in SciTE by pressing "Shft-F8" or by using the <View - Parameters> menu item.

M23

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.

  • Developers
Posted (edited)

  On 1/15/2010 at 4:20 PM, 'JohnJF said:

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 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.
  :)

  • Developers
Posted

  On 1/15/2010 at 4:28 PM, 'JohnJF said:

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 :D

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.
  :)

Posted

  On 1/15/2010 at 6:25 PM, 'Jos said:

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.
  • Developers
Posted (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 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.
  :)

Posted

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?

  On 1/15/2010 at 10:24 PM, 'Jos said:

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

  • Developers
Posted

  On 1/15/2010 at 11:03 PM, 'JohnJF said:

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.
  :)

Posted

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 :-)

  On 1/15/2010 at 11:09 PM, 'Jos said:

Should work fine when you put it in the same directory as the Autoit3.exe.

Jos

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...