Jump to content

Problem with show result of console on a GUI


myazdi
 Share

Recommended Posts

Hi
Dear support

How To Run multiple Commands (ipconfig, ping google.com, ...) Without Opening New Shell window and result appeared on a GUI window?

My project is this.
I want to create a GUI that show below information in 3 tabs:

TAB1
Status:
Show local admin
DEP Status
UAC Status
Guest account status
Host file
IE version
NIC status
OS info 32/64, name, SP
Is some services running
Show create and modify date of a file

TAB2
Action:
Restore IE
Remove all Temps
Run windows update

TAB3
Monitor:
Startup
%appdata%

Already I have bunch of scripts that do above jobs separately  (Is it possible to upload a zip file on autoit forum i want to upload my script but i can't ), but the problem is I need all of these information appeared on single GUI window as soon as I run this file.
When I run each of this scripts result show on console!!! I need all result appeared on a single GUI windows.

would you please help me!

Edited by myazdi
Link to comment
Share on other sites

myaydi,

   then all you have left to do is build a GUI with three tabs and add your little scripts as functions and position them where you like as edits or labels etc.

give it a shot and come back for help if you get stuck  :)

Bill

Link to comment
Share on other sites

,

myaydi,

then all you have left to do is build a GUI with three tabs and add your little scripts as functions and position them where you like as edits or labels etc.

give it a shot and come back for help if you get stuck :)

Bill

Hi

Thank you for your reply Bill,

First of all i'm myazdi not myaydi !

And second, Would you please write a script that show the result of two command in the single GUI,

For e.g. When i run your script it will show Ipconfig and netstat result at the same time in a single GUI, if you write first part of it i will write remain ....

Regards

Edited by myazdi
Link to comment
Share on other sites

Hi myazdi,

  sry msp name (first day with new laptop, has German kezboard) ;)

We practice the "teach a man to fish and he can feed himself forever" philosophy here. So were gonna have to see some effort from your side before the script monkeys start typing...

You said you have "bunch of scripts that do above jobs separately".

So take one of them that you understand how it works, build a simple GUI and use your script to update a label in the GUI for instance.

There are 1000's of working examples in the helpfile for such things.

Hints:

GUI Control Creation builds the GUI

GuiCreate

GUI Control Update allows you to change (update) the GUI with your data

GuiCtrlSetData

GuiCreateLabel is a pretty simple one to start with.

good luck!

Bill

Link to comment
Share on other sites

Your in luck  :thumbsup:

Feeling Generous & Bored...

here is the help file GUICtrlCreateTab example with some quick changes for you to practice on.

Have fun

#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $msg

    GUICreate("Tabs", 600, 500) ; will create a dialog box that when displayed is centered

    GUICtrlCreateTab(10, 10, 580, 480)

    GUICtrlCreateTabItem("The Tab # 1")
    GUICtrlCreateLabel("Operating System - " & @OSType , 20, 40)
    GUICtrlCreateLabel("OS Version - " & @OSVersion , 20, 55)
    GUICtrlCreateLabel("Computer Name - " & @ComputerName , 20, 70)
    GUICtrlCreateLabel("User Name - " & @UserName , 20, 85)

    GUICtrlCreateTabItem("The Tab # 2")
    GUICtrlCreateLabel("Today is the " & @WDAY & " day of the week", 20, 40)
    GUICtrlCreateLabel("Current Year - " & @YEAR , 20, 55)
    GUICtrlCreateLabel("The Time is - " & @HOUR & ":" & @MIN & ":" & @SEC , 20, 70)
    GUICtrlCreateLabel("%appdata% - " & @AppDataCommonDir , 20, 85)


    GUICtrlCreateTabItem("The Tab # 3")
    GUICtrlCreateLabel("Operating System - " & @OSType , 20, 40)
    GUICtrlCreateLabel("OS Version - " & @OSVersion , 20, 55)
    GUICtrlCreateLabel("Computer Name - " & @ComputerName , 20, 70)
    GUICtrlCreateLabel("User Name - " & @UserName , 20, 85)

    GUICtrlCreateTabItem("") ; end tabitem definition

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        $msg = GUIGetMsg()

        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>Example
Link to comment
Share on other sites

Your in luck  :thumbsup:

Feeling Generous & Bored...

 

here is the help file GUICtrlCreateTab example with some quick changes for you to practice on.

Have fun

#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $msg

    GUICreate("Tabs", 600, 500) ; will create a dialog box that when displayed is centered

    GUICtrlCreateTab(10, 10, 580, 480)

    GUICtrlCreateTabItem("The Tab # 1")
    GUICtrlCreateLabel("Operating System - " & @OSType , 20, 40)
    GUICtrlCreateLabel("OS Version - " & @OSVersion , 20, 55)
    GUICtrlCreateLabel("Computer Name - " & @ComputerName , 20, 70)
    GUICtrlCreateLabel("User Name - " & @UserName , 20, 85)

    GUICtrlCreateTabItem("The Tab # 2")
    GUICtrlCreateLabel("Today is the " & @WDAY & " day of the week", 20, 40)
    GUICtrlCreateLabel("Current Year - " & @YEAR , 20, 55)
    GUICtrlCreateLabel("The Time is - " & @HOUR & ":" & @MIN & ":" & @SEC , 20, 70)
    GUICtrlCreateLabel("%appdata% - " & @AppDataCommonDir , 20, 85)


    GUICtrlCreateTabItem("The Tab # 3")
    GUICtrlCreateLabel("Operating System - " & @OSType , 20, 40)
    GUICtrlCreateLabel("OS Version - " & @OSVersion , 20, 55)
    GUICtrlCreateLabel("Computer Name - " & @ComputerName , 20, 70)
    GUICtrlCreateLabel("User Name - " & @UserName , 20, 85)

    GUICtrlCreateTabItem("") ; end tabitem definition

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        $msg = GUIGetMsg()

        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>Example

Thank you , but already i have something like this code.

My question is how can i put the the result of two cmd on a GUI?

Regards,

Link to comment
Share on other sites

Now I have this code, but user must push the bottom till command run, I want as soon as the exe file is open this information appeared on GUI as label.

#include <GUIConstants.au3>
; This script requires full Administrative rights
#requireadmin
#AutoIt3Wrapper_UseAnsi=y

Opt("GUICoordMode",2)
Opt("GUIResizeMode", 1)
Opt("GUIOnEventMode", 1)


$Parent1 = GUICreate("Test", 160, 490, 500) ; width, height, position on screen from left 
GUICtrlCreateLabel("Wait 10 sec. after clicking", 20, 20) ; position on screen from left, down from top
GUISetBkColor(0x00CCFF) ; set color (0x33CCCC old color)

GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

$ip1 = GUICtrlCreateButton ("Check Addresses", -100, 15, 100, 25)
GUICtrlSetOnEvent(-1, "IP1Pressed")


GUISetState(@SW_SHOW)

GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")


; diff background color, winver works different, shows all enabled network adapter addresses 
; added note about renew ip, changed dimensions, added comments in script
; thanks to users in the AutoIt Forum: sahsanu, guinness, Monamo, MrCreatoR, FreeFry, Kademlia, LIMITER, Squirrely1, DickG, ChrisBair

GUISetState(@SW_SHOW)

; Just idle around
While 1
Sleep(10)
Wend



; END

Func IP1Pressed()
MsgBox(64, "Check Addresses",_IPDetails()) ; open widow shows all enabled network adapters
EndFunc

;Function to read from Command Line process.
Func _RunStdOutRead($sRunCmd)
Local $iPID = Run(@ComSpec & ' /c ' & $sRunCmd, @ScriptDir, @SW_HIDE, 4 + 2)
Local $sStdOutRead = ""

While ProcessExists($iPID)
$sStdOutRead &= StdoutRead($iPID)
WEnd

Return $sStdOutRead
EndFunc

Func SpecialEvents()

Select
Case @GUI_CTRLID = $GUI_EVENT_CLOSE
Exit

Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE
MsgBox(0, "Window Minimized", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)

Case @GUI_CTRLID = $GUI_EVENT_RESTORE
MsgBox(0, "Window Restored", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)

EndSelect

EndFunc

MsgBox(64, "IP Addresses",_IPDetails())
Exit

Func _IPDetails()
    Local $totalReturn=""
    Local $oWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & "." & "\root\cimv2")
    Local $oColItems = $oWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration", "WQL", 0x30), $aReturn[6] = [5]
    If IsObj($oColItems) Then
        For $oObjectItem In $oColItems
        If IsString($oObjectItem.IPAddress(0)) Then
                If IsString($oObjectItem.Description) Then
                    $aReturn[1] = "Description:" & @TAB & $oObjectItem.Description
                Else
                    $aReturn[1] = "Description:" & @TAB & "Not Available"
                EndIf

                If IsString($oObjectItem.IPAddress(0)) Then
                    $aReturn[2] = "IP Address:" & @TAB & $oObjectItem.IPAddress(0)
                Else
                    $aReturn[2] = "IP Address:" & @TAB & "Not Available"
                EndIf
                If IsString($oObjectItem.DefaultIPGateway(0)) Then
                    $aReturn[3] = "Default Gateway:" & @TAB & $oObjectItem.DefaultIPGateway(0)
                Else
                    $aReturn[3] = "Default Gateway:" & @TAB & "Not Available"
                EndIf

                If IsArray($oObjectItem.DNSServerSearchOrder()) Then
                    $aReturn[4] = "DNS Servers:" & @TAB & _WMIArrayToString($oObjectItem.DNSServerSearchOrder(), " - ")
                Else
                     $aReturn[4] = "DNS Servers:" & @TAB & "Not Available"
                EndIf

                If IsString($oObjectItem.MACAddress) Then
                    $aReturn[5] = "MAC: " & @TAB & @TAB & $oObjectItem.MACAddress
                Else
                    $aReturn[5] = "MAC: " & @TAB & @TAB & "Not Available"
                EndIf

            $totalReturn &= $aReturn[1] & @CRLF & $aReturn[2] & @CRLF & $aReturn[3] &  @CRLF & $aReturn[4] &  @CRLF & $aReturn[5] & @CRLF & @CRLF
            EndIf
        Next
        Return StringTrimRight($totalReturn,4)
    EndIf
    Return SetError(1, 0, $aReturn)
EndFunc   ;==>_IPDetails

Func _WMIArrayToString($aArray, $sDelimeter = "|")
    If IsArray($aArray) = 0 Then
        Return SetError(1, 0, "")
    EndIf
    Local $iUbound = UBound($aArray) - 1, $sString
    For $A = 0 To $iUbound
        $sString &= $aArray[$A] & $sDelimeter
    Next
    Return StringTrimRight($sString, StringLen($sDelimeter))
EndFunc   ;==>_WMIArrayToString
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...