Jump to content

Any help me to complete this functions


Recommended Posts

#include <guiconstants.au3>
#include <guiconstantsex.au3>
#include <inet.au3>
 
$interface=guicreate("My Gui",303,454,5,5)
guisetfont(7,400,0,"verdana")
guictrlcreatetab(0,0,642,21)
guictrlcreatetabitem("Info")

$hostname=guictrlcreateinput(@computername,1,22,150,17)=guictrlcreatelabel("HOSTNAME",151,24)
;$domain=guictrlcreateinput(,1,40,150,17)=guictrlcreatelabel("DOMAIN",151,42)
$username=guictrlcreateinput(@username,1,58,150,17)=guictrlcreatelabel("USERNAME",151,60)
;$macaddress=guictrlcreateinput(,1,76,150,17)=guictrlcreatelabel("MAC ADDRESS",151,78)
$publicaddress=guictrlcreateinput(_getip(),1,94,150,17)=guictrlcreatelabel("IP EXTERNAL",151,96)
$ipaddress=guictrlcreateinput(@ipaddress1,1,112,150,17)=guictrlcreatelabel("IP INTERNAL",151,114)
;$ipsubnet=guictrlcreateinput(,1,130,150,17)=guictrlcreatelabel("NETMASK",151,132)
;$defaultipgateway=guictrlcreateinput(,1,148,150,17)=guictrlcreatelabel("GATEWAY",151,150)
;$dnsserversearchorder=guictrlcreateinput(,1,166,150,17)=guictrlcreatelabel("DNS",151,168)

guictrlcreatetabitem("Ping")
$01=guictrlcreateinput(ping("10.1.0.1",4000)&"ms",1,22,150,17)=guictrlcreatelabel("SERV-01",151,24)
$02=guictrlcreateinput(ping("10.1.0.2",4000)&"ms",1,40,150,17)=guictrlcreatelabel("SERV-02",151,42)
$03=guictrlcreateinput(ping("10.1.0.3",4000)&"ms",1,58,150,17)=guictrlcreatelabel("SERV-03",151,60)
$04=guictrlcreateinput(ping("10.1.0.4",4000)&"ms",1,76,150,17)=guictrlcreatelabel("SERV-04",151,78)
$05=guictrlcreateinput(ping("10.1.0.5",4000)&"ms",1,94,150,17)=guictrlcreatelabel("SERV-05",151,96)

guisetstate()

while 1
$fechar = guigetmsg()
select
case $fechar = $gui_event_close
guidelete()
tooltip("O programa está parando todos os serviços, por favor aguarde.",0,0)
sleep(3000)
tooltip("O programa está sendo finalizado, obrigado.",0,0)
sleep(3000)
exit
endselect
wend

I just want to discover this functions: domain, macaddress, ipsubnet, defaultipgateway and dnsserversearchorder

If possible, i want to refresh tab ping in x time

Any help me? my first day with autoit, thanks.

Link to comment
Share on other sites

  • Moderators

tvinicius,

Welcome to the AutoIt forum. :)

But please pay attention to where you post - the "Examples" section where you started this thread is clearly marked: "This is NOT a general support forum!". I have moved the thread for you, but would ask you to be more careful in future. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

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

 

Link to comment
Share on other sites

This should give you live ping for a number of hosts, which can be easily increased from $Pings array.

I've copied some functions from a script I've, you might need to clean it up of left overs.

#include <inet.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>

Global $SRVList[6] = [5], $Pings[2][6] = [[5, '10.1.0.1', '10.1.0.2', '10.1.0.3', '10.1.0.4', '8.8.8.8'], [0, 0, 0, 0, 0, 0]], $Ping = 0

Opt("GUIOnEventMode", 1)

$interface=guicreate("My Gui",303,454,5,5)
guisetfont(7,400,0,"verdana")
guictrlcreatetab(0,0,642,21)
guictrlcreatetabitem("Info")

$hostname=guictrlcreateinput(@computername,1,22,150,17)=guictrlcreatelabel("HOSTNAME",151,24)
$domain=guictrlcreateinput(@LogonDomain,1,40,150,17)=guictrlcreatelabel("DOMAIN",151,42)
$username=guictrlcreateinput(@username,1,58,150,17)=guictrlcreatelabel("USERNAME",151,60)
;$macaddress=guictrlcreateinput(,1,76,150,17)=guictrlcreatelabel("MAC ADDRESS",151,78)
$publicaddress=guictrlcreateinput(_getip(),1,94,150,17)=guictrlcreatelabel("IP EXTERNAL",151,96)
$ipaddress=guictrlcreateinput(@ipaddress1,1,112,150,17)=guictrlcreatelabel("IP INTERNAL",151,114)
;$ipsubnet=guictrlcreateinput(,1,130,150,17)=guictrlcreatelabel("NETMASK",151,132)
;$defaultipgateway=guictrlcreateinput(,1,148,150,17)=guictrlcreatelabel("GATEWAY",151,150)
;$dnsserversearchorder=guictrlcreateinput(,1,166,150,17)=guictrlcreatelabel("DNS",151,168)

guictrlcreatetabitem("Ping")

For $i = 1 To $SRVList[0]
    $SRVList[$i] = guictrlcreateinput($Pings[0][$i],1,6 + ($i * 18),150,17)
    guictrlcreatelabel("SERV-0" & $i,151,8 + ($i * 18))
Next



$BTN = GUICtrlCreateButton('Start', 30, 200, 80, 30)
GUICtrlSetOnEvent(-1, 'BTN')

$Progress = GUICtrlCreateProgress(10, 150, 250)

GUISetOnEvent($GUI_EVENT_CLOSE, 'Quit')
guisetstate()

While 1
    If $Ping Then LivePing()
    Sleep(100)
WEnd

Func BTN()
    $Ping = Not $Ping
EndFunc

Func Quit()
    KillPings()
guidelete()
;tooltip("O programa est? parando todos os serviços, por favor aguarde.",0,0)
;sleep(3000)
;tooltip("O programa est? sendo finalizado, obrigado.",0,0)
;sleep(3000)
Exit
EndFunc

Func LivePing()
    Local $PRG = 0, $Wait = 0

    $RefRate = 1
    GUICtrlSetData($BTN, 'Stop')
    GUICtrlSetData($Progress, 0)

    For $x = 1 to $Pings[0][0]
        $Pings[1][$x] = Run('Ping ' & $Pings[0][$x] & ' -w 500 -t', '', @SW_HIDE, $STDOUT_CHILD)
    Next

    While $PRG < 100
        $PRG += 1
        Sleep(10)
        GUICtrlSetData($Progress, $PRG)
    WEnd

    GUICtrlSetStyle($Progress, $PBS_MARQUEE)
    GUICtrlSendMsg($Progress, $PBM_SETMARQUEE, True, 50 * $RefRate)

    While 1
        For $x = 1 to $Pings[0][0]
            If Not $Ping Then ExitLoop 2

            $MS = PingInfo($Pings[1][$x])
            If $MS <> 'Wait' Then SetPingState($MS, $x)
        Next
        $Wait = 0
        While $Wait < $RefRate
            $Wait += 0.1
            Sleep(100)
            If Not $Ping Then ExitLoop 2
        WEnd
    WEnd

    GUICtrlSendMsg($Progress, $PBM_SETMARQUEE, False, 50)

    KillPings()
    GUICtrlSetData($BTN, 'Start')
EndFunc

Func PingInfo(ByRef $Proc)
    Local $UMS, $MS

    $R = StdoutRead($Proc)
    If @error Then Return 'Error'
    If StringInStr($R, 'Request timed out.', 2, 1, 1) Then Return 'T.O'
    If StringLen($R) < 55 And StringInStr($R, 'ms', 2, 1, 1, 55) = 0 Then Return 'Wait'

    $S = StringRegExp(StringRegExpReplace($R, '<1ms', '=0ms'), '(?i)time\=(\d*)ms', 3)
    If @error Then Return 'Error'
    $A = UBound($S)

    If $A > 1 Then
        For $x = 0 To ($A - 1)
            $UMS += $S[$x]
        Next
        $MS = $UMS / $A
    ElseIf $A = 1 Then
        $MS = $S[0]
    EndIf

    Return Round($MS) & ' ms'
EndFunc

Func KillPings()
    For $x = 1 to $Pings[0][0]
        If $Pings[1][$x] Then ProcessClose($Pings[1][$x])
    Next
EndFunc

Func SetPingState(ByRef $MS, ByRef $x)
    Local $PNG[2][3] = [[35, 60, 100], [1, 2, 3]]
    Local $CLR, $R = 0, $Pos = 1

    $R = 1
    Select
        Case $MS = 'T.O' Or $MS = 'Down' Or $MS = 'Error'
            $CLR = 0xCC0000
        Case $MS < $PNG[$R][0]
            $CLR = 0x0033FF
        Case $MS < $PNG[$R][1]
            $CLR = 0x008000
        Case $MS < $PNG[$R][2]
            $CLR = 0xFF6600
        Case Else
            $CLR = 0x808A87
    EndSelect
    GUICtrlSetData($SRVList[$x], $MS)
    GUICtrlSetColor($SRVList[$x], $CLR)
EndFunc
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...