Jump to content

get Stdoutread information to appear in an edit box in gui

Recommended Posts



                   Im trying to capture information from a dos command using StdoutRead() and have it appear in an edit box in my GUI. For some reason when i run the command with a msgbox in the while loop it will transfer the data to the edit box properly. but when i eliminate the msg box from the while loop nothing appears in the edit box. I cant sem to figure out exactly where i am going wrong here.

Sample code:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <inet.au3>
#include <Constants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 449, -815, 111)
$User = GUICtrlCreateButton("Who's Logged On", 16, 16, 171, 33)
$Host = GUICtrlCreateButton("Get Hostname", 16, 64, 171, 33)
$Mac = GUICtrlCreateButton("Get MAC Address", 16, 112, 171, 33)
$sUser = GUICtrlCreateInput("", 216, 24, 217, 21)
$sHost = GUICtrlCreateInput("", 216, 72, 217, 21)
$sMac = GUICtrlCreateInput("", 216, 120, 217, 21)
$pInfo = GUICtrlCreateInput("", 448, 168, 169, 21)
$Label1 = GUICtrlCreateLabel("Version", 448, 150, 164, 19)
$Acc = GUICtrlCreateButton("User Account", 456, 16, 155, 41)
$IP = GUICtrlCreateInput("IP/Host Name", 8, 408, 193, 21)
$Version = GUICtrlCreateButton("Check Version", 16, 160, 171, 33)
$pName = GUICtrlCreateInput("Enter Program", 216, 168, 217, 21)
$Ping = GUICtrlCreateButton("Ping", 232, 392, 169, 41)
$mDrive = GUICtrlCreateButton("Remote C$", 432, 392, 163, 41)
$nPrinter = GUICtrlCreateButton("Mapped Printers", 16, 208, 171, 33)
$pList = GUICtrlCreateEdit("", 216, 208, 217, 73)
GUICtrlSetData(-1, "Edit1")
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $User
        case $Host
        case $Mac
        Case $Version
        case $ping
        case $mDrive
        case $nPrinter
        Case $acc
        Case $GUI_EVENT_CLOSE


func remote_user()
    $pid= Run(@ComSpec & " /c wmic /node: computersystem get username", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

While 1
    $line = StdoutRead($pid)
    If @error Then ExitLoop
    MsgBox(0, "STDOUT read:", $line) ;<----- this msgbox i would like to get rid off but code doesnt seem to wrk without it 
    guictrlsetdata($pList, $line)
While 1
    $line = StderrRead($pid)
    If @error Then ExitLoop
   guictrlsetdata($pList, $line)

thank you to all that help or reply




Edited by Milas
wanted to edit the code

Share this post

Link to post
Share on other sites

alright while no one seems to have respond thank you for anyone who tried and just did not reply. Now im not sure if its the most correct answer but i added a sleep command for one second in between the run function and the while loop. i guess the wmic process needs time to resolve. hopefully i can find a better answer to this dilemma.

Share this post

Link to post
Share on other sites


Please remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare.  You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online.



  • Like 1

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Share this post

Link to post
Share on other sites

my apologizes i didn't mean to come across that way. i will have better diction in the future

Share this post

Link to post
Share on other sites


Func remote_user()
    $pid = Run(@ComSpec & " /c wmic computersystem get username", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    Local $line
    While 1
        $line &= StdoutRead($pid)
        If @error Then ExitLoop
        GUICtrlSetData($pList, $line)
    While 1
        $line &= StderrRead($pid)
        If @error Then ExitLoop
        GUICtrlSetData($pList, $line)
EndFunc    ;==>remote_user


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
Live for the present,
Dream of the future,
Learn from the past.

Share this post

Link to post
Share on other sites


           Thank you VERY MUCH! i am new to autoit and im not familiar with &=

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