Sign in to follow this  
Followers 0
dabus

Write output to cmd/console

11 posts in this topic

I use a simple wrapper for blat to use as a console-mail-tool.

The only thing that I would love to do is write the help to cmd's stdout.

(I open cmd; do a sendmail --help; the output should just be typed into this cmd-window -- or can you explain to me how to do a type without opening a second cmd-instance? B) ).

I know that it's possible to do this via mouse, but I would like to know if this can be done alternatively.

StdinWrite seems to modify an already existing "stream", that's not exactly what I want to do (or can autoit modify its own output? :o

Share this post


Link to post
Share on other sites



ConsoleWrite is the output stream for AutoIt, however, it will not send it to cmd (as it is a gui application). I believe someone is working on modifying an compiled exe of a script so as to run and output to cmd, however, I'm not sure about that.

You could pipe the output back to the command line. But because I can't think of that this minute, you could pipe it to a file (dir > tempfile.txt), and then type it back to the screen (type tempfile.txt).

At the End of the script, just do Run(@COMSPEC & " /k type tempfile.txt"), and that should work


Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites

I believe someone is working on modifying an compiled exe of a script so as to run and output to cmd, however, I'm not sure about that.

If you aren't sure of something, it is usually best to say nothing. The idea of modifying a compiled script to make it a CUI application has already been done and is dangerous. Not only that, to circumvent people doing dangerous things, I wrote a small wrapper to serve as a proxy between the CLI and a GUI application so that the streams are "connected".

Share this post


Link to post
Share on other sites

I've found that if you aren't SURE about something, but do believe that you are correct, it is best to state it, even if you are not 100% sure, as:

  • It gives them something to look in to
  • If someone proves you otherwise, then you know in the future that the 'something' does not exist, and does not need to be brought up in the future

Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites

I think this is what you want, if not than I'm sorry :graduated:

Valik, you're not really motivating people to help others out :)B):o

Felix

Share this post


Link to post
Share on other sites

I think this is what you want, if not than I'm sorry :graduated:

Valik, you're not really motivating people to help others out :)B):o

Felix

Misinformation annoys me. Whats worse than giving somebody free information is giving them free wrong information.

Share this post


Link to post
Share on other sites

Is that related to my post or only to "Valik, you're not really motivating people to help others out"?

Share this post


Link to post
Share on other sites

Is that related to my post or only to "Valik, you're not really motivating people to help others out"?

Just the comment, you linked to the correct thread.

Share this post


Link to post
Share on other sites

Thanks for your advice, but could someone please tell me how to invoke it?

If I do a

Run ( "stub.exe bla.exe" )

the stub will still create another terminal and run in that window. I would like to run the stub in the terminal the compiled script is running in.

I'm pretty sure, this can be done, but I just don't get it... B)

Share this post


Link to post
Share on other sites

the stub will still create another terminal and run in that window. I would like to run the stub in the terminal the compiled script is running in.

I'm pretty sure, this can be done, but I just don't get it... B)

Sigh. The entire point of stub.exe is because you can't do that so you start stub.exe from a Console window passing it the path of the script to start and then stub.exe bridges the gap between the Console window and the AutoIt script.

Share this post


Link to post
Share on other sites

Thx again, I would have searched for ages since autoit often surprised me with a bunch of solutions. B)

So I'll use this workaround to get my Help printed:

Func Help()
    BlockInput ( 1 )
    $Mouse=MouseGetPos ( )
    ClipPut ( "type %Temp%\SendMail-Help.txt" )
    $HelpFile=FileOpen ( @TempDir &"\SendMail-Help.txt" , 2 )
    FileWriteLine ( $HelpFile, '...' ) 
    FileClose ( $HelpFile )
    $Title=WinGetTitle ("" )
    $Pos=WinGetPos ( $Title )
    MouseClick ( "right", $Pos[0]+($Pos[2]/2), $Pos[1]+($Pos[3]/2), 1, 0 )
    MouseClick ( "left", $Pos[0]+($Pos[2]/2)+20, $Pos[1]+($Pos[3]/2)+45 , 1, 0)
    Send ( "{Enter}" )
    MouseMove ( $Mouse[0], $Mouse[1] , 0)
    BlockInput (0)
    Exit
EndFunc  ;==>Help

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