Sign in to follow this  
Followers 0
Scribble

Howto...just console output...? equivalent to "ECHO"?

11 posts in this topic

#1 ·  Posted (edited)

Hello,

This is probably a very easy question for you, but I can't seem to find the answer in the help or by forum-search...

I'm writing an AutoIT commandline-ONLY tool that can be used in a batchfile. It receives input from $cmdline, but now I need a function that will write output (i.e. Syntax) to that same console I started my autoit compiled executable in. (Just like the ECHO command in Batch) So, I do NOT want to use the GUI (i.e. MsgBox) to output messages for this tool I'm writing.

How can I do this? B)

Related question... how can I check if my autoit compiled prog is run from the dos-console?

Thanx guys.

Edited by Scribble

Share this post


Link to post
Share on other sites



I do NOT want to use the GUI (i.e. MsgBox) to output messages for this tool I'm writing.

How can I do this? B)

Related question... how can I check if my autoit compiled prog is run from the dos-console?

AutoIt is a Gui application, not a console application. This means that AutoIt cannot communicate to a console window like a console application does. Using Send() is the only method that may help but it is indirect and requires active focus to work.

For your related question, their is no flag to inform you of what executed your program, AFAIK. If it is executed by mouseclick, then it will be started without parameters so you can know of no parameters used, otherwise you would not know if it were a shortcut, batch file or console window that started your program.

Share this post


Link to post
Share on other sites

AutoIt is a Gui application, not a console application. This means that AutoIt cannot communicate to a console window like a console application does. Using Send() is the only method that may help but it is indirect and requires active focus to work.

For your related question, their is no flag to inform you of what executed your program, AFAIK. If it is executed by mouseclick, then it will be started without parameters so you can know of no parameters used, otherwise you would not know if it were a shortcut, batch file or console window that started your program.

Hi Mhz and W0uter,

Thank you for your answer, but I'm very dissappointed that something that SEEMS so simple (it probably isn't) cannot be done easily in AutoIT. I tried consolewrite, but that wouldn't echo anything to the console...

maybe autoit needs another parser, just like WSH Cscript and Wscript.... :-)

@W0uter, If you could point me to that thread, I'd gladly read it. I've searched a lot, but probably on the wrong keywords...

Thanx.

Share this post


Link to post
Share on other sites

you dont read the forums very often do you B)

I do...but I would not recommended it. Command prompts are unreliable to script and I did mention indirect with Send().

Here is a SendKeys method for beta that also needs focus.

Func _WshSend($title, $string)
    $WshShell = ObjCreate("WScript.Shell")
    If Not @error Then
        $WshShell.AppActivate( WinGetTitle($title) )
        $WshShell.SendKeys($string)
        $WshShell = ''
        Return True
    EndIf
EndFunc

But AutoIt is still a Gui application so making a console ONLY application is futile.

Share this post


Link to post
Share on other sites

Thanx guys,

@W0uter

that thread was very interesting, although it looks a bit advanced for a newbie like me, but I think I understand it. And like Mhz explained to me, it gave me some insight on why AutoIT isn't a console app in the first place. But I hope one day it has this functionality built-in.

Anyways, "copy /b"-ing the stubloader in seems to be the road I'm taking, because patching the binary I'd rather not do.

Thx again!

Share this post


Link to post
Share on other sites

This seems to do it rather nicely:

ConsoleWrite('This is one line' & @LF)
ConsoleWrite('This is another line' & @LF)
ConsoleWrite('This is a third line' & @LF)

C:\>CompiledScript.exe

C:\>CompiledScript.exe | Find /V ""

This is one line

This is another line

This is a third line

C:\>_

Share this post


Link to post
Share on other sites

I tried consolewrite, but that wouldn't echo anything to the console...

There's a pitfall to testing ConsoleWrite: Windows actually detects whether an app (or compiled script) is a "Windows" app and disconnects the console input/output pipes from it if it is, so yes, if a compiled script is run by itself there's usually no output from ConsoleWrite. However, if you spell matters out to Windows (as Alex has done above) by using a command line that pipes the output of your compiled script to another app then Windows won't disconnect the output pipe.


Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Share this post


Link to post
Share on other sites

There's a pitfall to testing ConsoleWrite: Windows actually detects whether an app (or compiled script) is a "Windows" app and disconnects the console input/output pipes from it if it is, so yes, if a compiled script is run by itself there's usually no output from ConsoleWrite. However, if you spell matters out to Windows (as Alex has done above) by using a command line that pipes the output of your compiled script to another app then Windows won't disconnect the output pipe.

You know what's sad? You have more or less the quoted post in your signature and you still have to make similar posts about once a week. I think I might just have to shoot you if I see it again. B)

Share this post


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
Sign in to follow this  
Followers 0