#include #include #include #include #include Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form2", 405, 294, 243, 231) GUISetOnEvent($GUI_EVENT_CLOSE, "Form2Close") $Button1 = GUICtrlCreateButton("Button1", 256, 74, 75, 25) GUICtrlSetOnEvent(-1, "Button1Click") $Input1 = GUICtrlCreateInput("Input1", 98, 72, 121, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Local $cmd = Run("cmd.exe", @ScriptDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD) While 1 Sleep(100) WEnd Func Button1Click() $content = GUICtrlRead($Input1) sendEcho($content) EndFunc Func Form2Close() StdinWrite($cmd) ConsoleWrite("END" & @CRLF) exit EndFunc func sendEcho($text) ;build the command $command = "echo " & $text & @CRLF ConsoleWrite("COMMAND: " & $command & @CRLF) ; debug check ;send command to the console StdinWrite($cmd, $command) $line = "" ;loops and gathers all the command output While True $line &= StdoutRead($cmd) ConsoleWrite($line) ;debug If @error Then ExitLoop ;to exit the while loop we look for the blank command prompt, the trimming is needed to get a clean match. If StringRight($line,StringLen(@ScriptDir) + 1) = @ScriptDir & ">" Then ExitLoop Sleep(30) WEnd EndFunc