tvinicius Posted July 30, 2013 Share Posted July 30, 2013 expandcollapse popup#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 More sharing options...
Moderators Melba23 Posted July 30, 2013 Moderators Share Posted July 30, 2013 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 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Anas Posted July 31, 2013 Share Posted July 31, 2013 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. expandcollapse popup#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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now