Sign in to follow this  
Followers 0
darkjohn20

Writing to consoles

9 posts in this topic

#1 ·  Posted (edited)

I have a main GUI application that I want to call a few command prompts to display data in them.

$hCMD = Run("cmd.exe", "", @SW_SHOW, $STDIN_CHILD + $STDOUT_CHILD)
StdinWrite($hCMD, "echo Hello" & @CRLF)

I've tried both $STDIN_CHILD alone and $STDIN_CHILD + $STDOUT_CHILD, but neither work.

I noticed that:

$hCMD = Run("cmd.exe", "", @SW_SHOW, $STDIN_CHILD)
StdinWrite($hCMD, "echo Hello" & @CRLF)

Writes "Hello" to the Scite console, and writes nothing when compiled.

What am I doing wrong?

Edit: Fixed my examples to include &CRLF in StdinWrite.

Edited by darkjohn20

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You have to use #AutoIt3Wrapper_Change2CUI=y!

Try this:

#AutoIt3Wrapper_Change2CUI=y
#include <Constants.au3>
$hCMD = Run("cmd.exe", "", @SW_SHOW, $STDIN_CHILD)
StdinWrite($hCMD, "echo Hello" & @CRLF)

Exit

Compile and run it in CMD!

BR,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

"I have a main GUI application"

The main program needs to be a GUI application, it cannot be a CUI. I want it to create a few command prompts that it can write to.

I don't want to use them for actual commands, such as "ping" or "tree", but rather just to display information.

Share this post


Link to post
Share on other sites

You can still use GUIs but ConsoleWrite will prompt directly to CMD!

The only disadvantage I see is when you start the exe it will open CMD and it will close not until the exe has been closed first.

BR,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

And what if I need to output to multiple different CMD windows? I would like to have my main GUI control about 3 cmd windows, which wouldn't necessarily be running all of the time.

Edited by darkjohn20

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

And what if I need to output to multiple different CMD windows? I would like to have my main GUI control about 3 cmd windows, which wouldn't necessarily be running all of the time.

That is possible however main program would have to spawn the CMD windows, know their pids then write to the cmd windows. I question the use of that. If you want to output information, use there different log files.

If you want to interface to another cmd program then you will have your work cut out for you. As for the first post, there is a UDF for diskpart here http://www.autoitscript.com/forum/index.php?app=core&module=attach&section=attach&attach_id=26230 which may help.

Edited by bo8ster

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

I solved the issue.

I created a separate script that would run as a CUI, and ConsoleWrite any text written to a hidden window with ControlSetText.

I've decided that a few CMD windows is too messy anyway, so I've abandoned the idea. Thanks anyway.

Share this post


Link to post
Share on other sites

If you need the cmd-window just for output, you also could create a custom GUI with a textbox in read-only mode.

Then you could use _GUICtrlEdit_AppendText to append data.


*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

One process can't allocate more than one console. How would you even manage to do that?

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