Sign in to follow this  
Followers 0
tbaror

Capture RUN output show it in GUICtrlCreateEdit

6 posts in this topic

hi ,

i am looking to a way to capute the output of RUN command and show it in GUICtrlCreateEdit box.

please advise

tHanks

Share this post


Link to post
Share on other sites



hi ,

i am looking to a way to capute the output of RUN command and show it in GUICtrlCreateEdit box.

please advise

tHanks

#include <GUIConstants.au3>
#Include <GuiEdit.au3>
Opt ("RunErrorsFatal", 0)
$GUI = GUICreate ("Run Output", 400, 200)
$Btn_Run = GUICtrlCreateButton ("Run Program", 300, 0, 100, 27)
$txt_edit = GUICtrlCreateEdit ("", 0, 0, 300, 200)
GUISetState (@SW_SHOW)

While 1
    $msg = GUIGetMsg ()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Btn_Run
            $file = FileOpenDialog ("Open...", "", ".exe (*.exe)")
            $run = _RunFile ($file)
            GUICtrlSetState ($txt_edit, $GUI_FOCUS)
            _GUICtrlEditReplaceSel ($txt_edit, False, $run)
    EndSelect
WEnd

Func _RunFile ($file)
    $rtn = Run ($file)
    $time = @HOUR & ":" & @MIN & ":" & @SEC
    If @error = 1 Then
        $def = "1- The EXE file could not be located."
    Else
        $def = "0- Success"
    EndIf
    
    $msg = "["&$time&"]>> RUN COMMAND: "&@CRLF&@TAB&"RUNNING '"&$file&"'"&@CRLF& _
    @TAB & "RETURNED: " & $def
    Return $msg
EndFunc

Share this post


Link to post
Share on other sites

Using the latest beta:

#include <GUIConstants.au3>
#Include <GuiEdit.au3>
Opt ("RunErrorsFatal", 0)
$GUI = GUICreate ("Run Output", 400, 200)
$Btn_Run = GUICtrlCreateButton ("Run Program", 300, 0, 100, 27)
$txt_edit = GUICtrlCreateEdit ("", 0, 0, 300, 200)
GUISetState (@SW_SHOW)

While 1
    $msg = GUIGetMsg ()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Btn_Run
            $file = FileOpenDialog ("Open...", "", ".exe (*.exe)")
            $run = _RunFile ($file)
                _GUICtrlEdit_AppendText($txt_edit, $run)
    EndSelect
WEnd

Func _RunFile ($file)
    $rtn = Run ($file)
    $time = @HOUR & ":" & @MIN & ":" & @SEC
    If @error = 1 Then
        $def = "1- The EXE file could not be located."
    Else
        $def = "0- Success"
    EndIf
    
    $msg = "["&$time&"]>> RUN COMMAND: "&@CRLF&@TAB&"RUNNING '"&$file&"'"&@CRLF& _
    @TAB & "RETURNED: " & $def
    Return $msg
EndFunc

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Using the latest beta:

#include <GUIConstants.au3>
#Include <GuiEdit.au3>
Opt ("RunErrorsFatal", 0)
$GUI = GUICreate ("Run Output", 400, 200)
$Btn_Run = GUICtrlCreateButton ("Run Program", 300, 0, 100, 27)
$txt_edit = GUICtrlCreateEdit ("", 0, 0, 300, 200)
GUISetState (@SW_SHOW)

While 1
    $msg = GUIGetMsg ()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Btn_Run
            $file = FileOpenDialog ("Open...", "", ".exe (*.exe)")
            $run = _RunFile ($file)
                _GUICtrlEdit_AppendText($txt_edit, $run)
    EndSelect
WEnd

Func _RunFile ($file)
    $rtn = Run ($file)
    $time = @HOUR & ":" & @MIN & ":" & @SEC
    If @error = 1 Then
        $def = "1- The EXE file could not be located."
    Else
        $def = "0- Success"
    EndIf
    
    $msg = "["&$time&"]>> RUN COMMAND: "&@CRLF&@TAB&"RUNNING '"&$file&"'"&@CRLF& _
    @TAB & "RETURNED: " & $def
    Return $msg
EndFunc
Ahhhhhhhh... Remind me to download the latest beta... :)

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