Jump to content

AutoIt3Wrapper STDOUT


Recommended Posts

Hi all! :)

I have a problem: when I run the command to execute the selected script, I want to output to an EditBox the STDOUT.

Here's the function code, the only problem is that there's no output! :(

The command itself works, the script is executed correctly, but the STOUT remains empty.

Func _File_Execute($hConsole, $pFile, $sParams = "")
    Local $hError = 0
    If $AutoItVer = "1" Then
        Local $sUseBeta = "/prod"
    Else
        Local $sUseBeta = "/beta"
    EndIf
    Local $pCFile = _PathFull($pFile)
    $aPath = StringSplit($pCFile, "")
    $sSep = ""
    $sPath = ""
    For $i = 1 To $aPath[0]-1 Step 1
        If $i = $aPath[0]-1 Then $sSep = ""
        $sPath &= $aPath[$i]&$sSep
    Next
    Global $hExecuteStdOut = Run(@ComSpec&" /C "&Chr(34) & $AutoItDir&"SciTEAutoIt3WrapperAutoIt3Wrapper.exe" & Chr(34) & " /run " & $sUseBeta & " /ErrorStdOut /in " & Chr(34) & $pCFile & Chr(34) & " /UserParams " & $sParams, $sPath, @SW_SHOW, $STDOUT_CHILD+$STDERR_CHILD)
    While 1
        Local $sStdout = StdoutRead($hExecuteStdOut)
        If @error Then $hError = 1
        Local $sData = GUICtrlRead($hConsole)
        Local $hError = GUICtrlSetData($hConsole, $sData & $sStdout & @CRLF)
        MsgBox(0,"",$sData & $sStdout & @CRLF)
        If $hError = 1 Then ExitLoop
    WEnd
    StdioClose($hExecuteStdOut)
EndFunc ;==>_File_Execute
Edited by FrontBack
Link to comment
Share on other sites

Here is some code to get you started right:

#include <GUIEdit.au3>

#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
_GUICtrlEdit_AppendText($outputwin,$output)
GUICtrlSetState($inputbox,256)
GUICtrlSetState($btnGo,512)
EndIf
WEnd
Exit
Edited by MKISH

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

: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

Thank you, but it's not what I'm searching for.

I want to run this command:

"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "<Path><Name>.au3" /UserParams

Your script works if the line 20 is replaced with this:

$CMD = Run($strCMD,"",@SW_HIDE,6)

But the STDOUT display isn't realtime...

Link to comment
Share on other sites

Then replace line 19 by: $strCMD = 'C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe /run /prod /ErrorStdOut /in "<Path>\<Name>.au3" /UserParams'

Edited by MKISH

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

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