Jump to content

Stream input and output (at the same time)


Recommended Posts

Long story short, I'm trying to write an advanced command prompt. Some of the programs will be launched from the GUI I created (which resembles the DOS prompt), and some of them will be user-interactive, with their output streamed into a text box and the input taken from either the keyboard or another text box below it.

The problem is, when I got the program to interact, output-only functions like "dir" worked perfectly, but other ones, like "prompt" which required input, would freeze the program and really mess up the processor. Any suggestions?

$foo = Run(@ComSpec & " /c " & $data, $currentdir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)      
        do 
        ;; run
            While 1
                $line = StdoutRead($foo)
                If @error Then ExitLoop
                if $line <> "" Then GUICtrlSetData($txtMain, $line, "add")
            ;MsgBox(0, "STDOUT read:", $line)
            Wend
            if not WinExists($foo) then ExitLoop
            do 
                $msg = GUIGetMsg()
            until $msg = $button1
            MsgBox(0,"","Writing OUT")
            StdinWrite($foo, GUICtrlRead($txtPrompt)& @CRLF)
            StdinWrite($foo)
        until not WinExists($foo)
Link to comment
Share on other sites

Can you show some code we can run to see the problem?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
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
 Share

  • Recently Browsing   0 members

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