cramaboule Posted May 18, 2007 Posted May 18, 2007 Hello, I am pinging some devices (server, router AP, switches,...) and some server trough the Internet. If the ping is answering, the IP address and the server name is displayed in green otherwise is becomes red. The problem that I have is that when the ping is not answering, it froze the GUI until the end of the timout. I have a timeout of 3 sec on my ping (If I reduce it I get some "red" on the IP from the Internet. My question is How can I ping without waiting the answer,... and get the answer later that, it does not freeze my GUI ? I tried the Ping from Autoit $ping=Ping($machine[$i][1],3000) and the command dos with the $STDOUT_CHILD any other Idea ? My Autoit programs: MAC Address - - Delete Temp Files - - Ping Test - - Play Video with VLC full screen dual monitors - - Set IP - - Pics Converter - - AutoUpdater - - CPU Usage - - Ending Script Nicely - - GDI+ GUI crossfades (slide transitions) - - Beamer - - Search and Search in Files - - Silent Ninite Others: Export Icons into Dll - - My website
Zedna Posted May 18, 2007 Posted May 18, 2007 Look at my NET SEND GUI.I'm using Run() with STDOUT_CHILD Resources UDF ResourcesEx UDF AutoIt Forum Search
cramaboule Posted May 18, 2007 Author Posted May 18, 2007 Look at my NET SEND GUI.I'm using Run() with STDOUT_CHILDThanks I'll have a look !Cramaboule My Autoit programs: MAC Address - - Delete Temp Files - - Ping Test - - Play Video with VLC full screen dual monitors - - Set IP - - Pics Converter - - AutoUpdater - - CPU Usage - - Ending Script Nicely - - GDI+ GUI crossfades (slide transitions) - - Beamer - - Search and Search in Files - - Silent Ninite Others: Export Icons into Dll - - My website
cramaboule Posted May 18, 2007 Author Posted May 18, 2007 Well... that's not exactly what I am looking for: I have an IP address to "ping" ! my script at the moment look like this: expandcollapse popup#comments-start History: Ping Test 1.2 Ping Test 1.1 Ping Test 1.0 first realese #comments-end #include <Constants.au3> #include <GuiConstants.au3> #include <iNet.au3> #NoTrayIcon Opt("TrayMenuMode",1); Default tray menu items (Script Paused/Exit) will not be shown. Global $ping=0 , $k=1 , $msg , $button_hide=1 , $button_show=1 , $Hide=0 , $a=0 Global $machine[60][5] , $machine_not_good[60][5], $machine_good[60][5], $input[60][5] Global $seq[100], $Winposping[4] , $Winpospingold[4] Global $noping , $head , $file , $exititem , $showallitem , $showgooditem , $gui , $doneonce , $button_hide_there , $winstate Global $pPing , $pPingRead ; head---------- $head="Ping Test 1.3" ;$showgooditem = TrayCreateItem("Show only good") $showallitem = TrayCreateItem("Show"); all") $exititem = TrayCreateItem("Exit") TraySetIcon("grip.DLL",0) TraySetState() Func getmachine () ;get Ip address and device name for hosts file in my server ; $machine[$i][1] => IP address ; $machine[$i][2] => machine name ; $k => number of machine EndFunc Call("getmachine") Call("fPing"); for the first one $gui=GuiCreate($head,300, (18*($k-1))+20,700, -1 ) $button_hide=GUICtrlCreateButton ( "<< Hide",100, 18*($k-1), 100 , 20) For $i = 1 to $k-1 $Input[$i][1] = GuiCtrlCreateInput($machine[$i][1],10,18*($i-1), 80,18,$ES_READONLY) $Input[$i][2] = GuiCtrlCreateInput($machine[$i][2],90,18*($i-1),200,18,$ES_READONLY) GUICtrlSetBkColor ( $Input[$i][1],0xffff00); yellow GUICtrlSetBkColor ( $Input[$i][2],0xffff00); yellow Next GuiSetState(@SW_SHOW,$gui) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $button_hide ; do something EndSelect $traymsg= TrayGetMsg() Select Case $traymsg = $exititem Exit Case $traymsg = $showallitem GuiSetState(@SW_SHOW,$gui) GuiSetState(@SW_RESTORE,$gui) EndSelect ; $pPingRead &= StdoutRead($pPing,-1) If @error Then If IsArray(StringRegExp($pPingRead, "(\d+)ms", 1)) Then ;MsgBox(0, "", $machine[$a][1]&" :good") $machine_good[$a][1]=1 $machine_good[$a][2]=1 GUICtrlSetBkColor ( $Input[$a][1],0x00ff00); green GUICtrlSetBkColor ( $Input[$a][2],0x00ff00); green Else ;MsgBox(0, "", $machine[$a][1]&" :na") TraySetIcon("grip.DLL",1) $machine_good[$i][1]=0 $machine_good[$i][2]=0 $noping += 1 $machine_not_good[$noping][1]=$machine[$i][1] $machine_not_good[$noping][2]=$machine[$i][2] GUICtrlSetBkColor ( $Input[$a][1],0xff0000); red GUICtrlSetBkColor ( $Input[$a][2],0xff0000); red EndIf Call("fPing") Else ; EndIf WEnd Func fPing() $a += 1 If $a >= $k Then $a = 1 Call("getmachine") EndIf ; $pPingRead="" $noping=0 ; $pPing = Run("ping -w 10000 -n 1 -l 8 " & $machine[$a][1], "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) GUICtrlSetBkColor ( $Input[$a][1],0xffff00); yellow GUICtrlSetBkColor ( $Input[$a][2],0xffff00); yellow EndFunc any other suggestion My Autoit programs: MAC Address - - Delete Temp Files - - Ping Test - - Play Video with VLC full screen dual monitors - - Set IP - - Pics Converter - - AutoUpdater - - CPU Usage - - Ending Script Nicely - - GDI+ GUI crossfades (slide transitions) - - Beamer - - Search and Search in Files - - Silent Ninite Others: Export Icons into Dll - - My website
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