Jump to content

Printing a string back to the command line


Recommended Posts

Hello. I found created a long time ago of exactly the thing i'm trying to do, but its resolution isn't working for me.

I would like to write some text back to the commandline that executed my compilied AutoIT script. Nothing complicated and i did a search and found ConsoleWrite. My code currently looks like this but, nothing is written back in to the cmd window.

Case $CmdLine[$i] = "-spath"
If $i == $CmdLine[0] Then
  ConsoleWrite("-spath requires a path to be specified" & @CRLF)
  Msgbox(0,"Test", "-spath requires a path to be specified")
  Exit
Endif

So when -spath is not supplied with a path to a file, it writes back to the cmdline "there was no path". The msgbox is just there to show me it's got to the right part of the code.

Edited by ndw
Link to post
Share on other sites

If you want to use ConsoleWrite to output to a CMD console window you must change the GUI to a CUI. You can use a wrapper flag but the specific syntax and command are eluding me right now. Something to the effect of AutoItWrapperChangetoCUI=Y (must be compiled)

Alternatively check this out.

Edited by spudw2k
Link to post
Share on other sites

Sorry to be a pain but i don't understand what i need to do with this. With StdInWrite, i'm confused about the "child process" bit. Sorry for sounding like a noob but, is that asking for the process id of the command window that launched the program? From what i can see, it looks to be used for if i run something within my script, but i'm running an .exe version of my AutoIT script, not a command window from within it.

What i'm doing is running my AutoIT script from the command line which i would like to pass some switches in

eg AutoITScript.exe -spath "C:\blah\blah" -v -p 46

And to that command window, i want to output if a switch has incorrect data like -v wasn't specificed.

Ugh, i'm confusing myself with this, i can explain it again if it's unclear.

Link to post
Share on other sites

Hi ndw,

like spudw2k already stated you need to add the following line at the top of your script:

#AutoIt3Wrapper_Change2CUI=y

But you'll need to compile it from Scite script editor. Please make sure you've installed the latest version.

Running the script from Scite: the ConsoleWrites are displayed in the output pane.

Running the script from CMD: The ConsoleWrites are displayed in the command window.

Running the script by double-click: The ConsoleWrites are displayed in a temp. command window, that will disappear after program termination.

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to post
Share on other sites

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