Jump to content

Help with StdoutRead/StderrRead


Recommended Posts

I'm trying to build a GUI for the attached exe but for some reason (that i don't know) StdoutRead/StderrRead are not outputting the info.

my code:

#include <array.au3>
Global $EXEC = @ScriptDir & "uurename.exe"
Manage()
Func Manage()
Local $lastreturn
$CMD = $EXEC
$foo = Run($CMD, @ScriptDir, @SW_show,0x8)
While 1
$line = StdoutRead($foo)
If @error Then ExitLoop
If $line <> "" Then ConsoleWrite("STDOUT read: " & $line & @CRLF)
WEnd
While 1
$line = StderrRead($foo)
If @error Then ExitLoop
If $line <> "" Then ConsoleWrite("STDERR read: " & $line & @CRLF)
WEnd
EndFunc ;==>Manage

EXE - > http://db.tt/S9A4ixq9

DLL - > http://db.tt/fhTLZbtb

Thanks in advance

Lior.

Edited by devilyn
Link to comment
Share on other sites

This is a particular example to demonstrate CMD output etc. Here it is:

#NoTrayIcon
Global $output = ""
$xWin = @DesktopWidth * .5
$yWin = @DesktopHeight * .5
$gui = GUICreate("CMD Tool",$xWin,$yWin,-1,-1)
$inputbox = GUICtrlCreateInput("VER",$xWin * .025,$yWin * .05,$xWin * .875,$yWin * .05)
GUICtrlSetFont (-1,9, 400, 0, "Arial")
$outputwin = GUICtrlCreateEdit("",$xWin * .025,$yWin * .15,$xWin * .95,$yWin * .8,2048+2097152)
GUICtrlSetFont (-1,9, 400, 0, "Lucida Console")
$btnGo = GUICtrlCreateButton("GO",$xWin * .925,$yWin * .05,$xWin * .05,$yWin * .05)
GUICtrlSetState(-1,512)
GUISetState()
While 1
$msg = GUIGetMsg()
If $msg = -3 Then ExitLoop
If $msg = $btnGo Then
$strCMD = GUICtrlRead($inputbox)
$CMD = Run(@Comspec & " /c " & $strCMD,"",@SW_HIDE,6)
While 1
$line = StdoutRead($CMD)
If @error Then ExitLoop
If $line = "" then
$output &= $line
else
$output &= $line & @CRLF
EndIf
WEnd
While 1
$line = StdErrRead($CMD)
If @error Then ExitLoop
If $line = "" then
$output &= $line
else
$output &= $line & @CRLF
EndIf
WEnd
ProcessClose($CMD)
$output &= "---------------------------------------------------------------------------------------" & @CRLF & @CRLF
GUICtrlSetData($inputbox,"")
If StringInstr($output,"") Then
GUICtrlSetData($outputwin,"")
$output = ""
EndIf
GuiCtrlSetData($outputwin,$output)
GUICtrlSetState($inputbox,256)
GUICtrlSetState($btnGo,512)
EndIf
WEnd
Exit

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

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...