Ghost21 Posted January 22, 2008 Share Posted January 22, 2008 $get = Run("ping -n 1 " & $PC, @ScriptDir, @SW_HIDE, $STDOUT_CHILD) While ProcessExists($get) Sleep(100) WEnd This takes about 1:30 seconds When I run this I'm grabing approx 200+ pcs pinging each one and if I remove the While ProcessExists($get) Sleep(100) WEnd This takes about 30 seconds I speed the program up but the data is hit and miss... IS there some other code thats quicker ? Link to comment Share on other sites More sharing options...
BrettF Posted January 22, 2008 Share Posted January 22, 2008 Make the sleep 50? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
stampy Posted January 22, 2008 Share Posted January 22, 2008 You know, one time I was playing around and wondered what would happen if I overlapped pings. I found it was able to do it, and I got faster results. Here is that if you wanna take a look. It does call the pings in a separate exe. I believe they both had to be compiled first to run, can't remember why both. I'm sure there are better ways, it's just an example. hope it help. pingtestmain: expandcollapse popup#include <file.au3> #include <GUIConstants.au3> #include <array.au3> $guiH = 150 $guiW = 260 $pingGUI=GUICreate("Ping Test", $guiW, $guiH) $LabelTop = GUICtrlCreateLabel("Enter address range to Ping:", 20, 10) $LabelStart = GUICtrlCreateLabel("Starting address", 20, 42) $LabelEnd = GUICtrlCreateLabel("Ending address", 20, 72) $addressInput1 = GUICtrlCreateInput('',110,40,30,20) $addressInput2 = GUICtrlCreateInput('',145,40,30,20);LTWH $addressInput3 = GUICtrlCreateInput('',180,40,30,20);LTWH $addressInput4 = GUICtrlCreateInput('',215,40,30,20);LTWH $addressInput5 = GUICtrlCreateInput('',110,70,30,20) GUICtrlSetState(-1,$GUI_DISABLE) $addressInput6 = GUICtrlCreateInput('',145,70,30,20);LTWH GUICtrlSetState(-1,$GUI_DISABLE) $addressInput7 = GUICtrlCreateInput('',180,70,30,20);LTWH GUICtrlSetState(-1,$GUI_DISABLE) $addressInput8 = GUICtrlCreateInput('',215,70,30,20);LTWH $Pingbutton = GUICtrlCreateButton("Start Ping", $guiW/2-60-10, $guiH-30, 60,20) $ResetButton = GUICtrlCreateButton("Reset", $guiW/2-60-10, $guiH-30, 60,20) GUICtrlSetState(-1,$GUI_HIDE+$GUI_DISABLE) $Exitbutton = GUICtrlCreateButton("Exit", $guiW/2+10, $guiH-30, 60,20) $list = GUICtrlCreateList('',30,30,$guiw-60,95) GUICtrlSetState(-1,$GUI_HIDE+$GUI_DISABLE) GUISetState(@SW_SHOW) While 1 Sleep(50) $inputRead = GUICtrlRead($addressInput1) GUICtrlSetData($addressInput5,$inputRead) $inputRead = GUICtrlRead($addressInput2) GUICtrlSetData($addressInput6,$inputRead) $inputRead = GUICtrlRead($addressInput3) GUICtrlSetData($addressInput7,$inputRead) $msg = GUIGetMsg() Select Case $msg = $Pingbutton $a = Number(GUICtrlRead($addressInput1)) $b = Number(GUICtrlRead($addressInput2)) $c = Number(GUICtrlRead($addressInput3)) $x = Number(GUICtrlRead($addressInput4)) $y = Number(GUICtrlRead($addressInput8)) ;make sure all are num and none are blank and not 0 and not greater that 255 If not StringIsInt($a) Or Not StringIsInt($B) Or Not StringIsInt($c)Or Not StringIsInt($x)Or Not StringIsInt($y)Then MsgBox(0,'PingTest','Address must be a integer') GUICtrlSetState($addressInput1,$GUI_FOCUS) ContinueLoop ;ElseIf $a='' or $b=''or $y=''or $x=''or $y=''Then;;;;;;;;actually the isint will do this ElseIf $a < 0 or $a > 255 or $b < 0 or $b > 255 or $c < 0 or $c > 255 or $x < 0 or $x > 255 or $y < 0 or $y > 255 then MsgBox(0,'PingTest','Address must be between 1 and 255') GUICtrlSetState($addressInput1,$GUI_FOCUS) ContinueLoop EndIf ;make sure 8 is more than 4 ;MsgBox(0,'test','x='&$x &':y='&$y) if $y < $x Then MsgBox(0,'PingTest','Ending address must be larger than starting address.') GUICtrlSetState($addressInput8,$GUI_FOCUS) GUICtrlSetData($addressInput8,$x) ContinueLoop EndIf ;ContinueLoop;for testing ;set address $address = $a&'.'&$b&'.'&$c&'.' ;set start ;MsgBox(0,'test start',$x) $start = $x ;set end $end = $y GUISetState(@SW_DISABLE ,$pingGUI) GUISetCursor(15,1,$pingGUI) ;...................................'clear list first GUICtrlSetData($list,'') $Results = Pings() ;$Results = '7.7.7.7' ;for testing If $Results <> 0 Then ;'after the result is found hide all controls and show list and add results to list GUICtrlSetState($list,$gui_SHOW+$GUI_ENABLE) GUICtrlSetState($addressInput1,$GUI_HIDE+$GUI_DISABLE) GUICtrlSetState($addressInput2,$GUI_HIDE+$GUI_DISABLE) GUICtrlSetState($addressInput3,$GUI_HIDE+$GUI_DISABLE) GUICtrlSetState($addressInput4,$GUI_HIDE+$GUI_DISABLE) GUICtrlSetState($addressInput5,$GUI_HIDE+$GUI_DISABLE) GUICtrlSetState($addressInput6,$GUI_HIDE+$GUI_DISABLE) GUICtrlSetState($addressInput7,$GUI_HIDE+$GUI_DISABLE) GUICtrlSetState($addressInput8,$GUI_HIDE+$GUI_DISABLE) ; GUICtrlSetState($Pingbutton,$GUI_HIDE+$GUI_DISABLE) GUICtrlSetState($ResetButton,$GUI_SHOW+$GUI_ENABLE) ;enable gui GUISetState(@SW_ENABLE ,$pingGUI) ;change cursor GUISetCursor(2,0,$pingGUI) ;hide label GUICtrlSetState($LabelStart,$GUI_HIDE+$GUI_DISABLE) ;hide label GUICtrlSetState($LabelEnd,$GUI_HIDE+$GUI_DISABLE) ;change top label GUICtrlSetData($LabelTop,'Ping Results:') ;set list $Results = StringReplace($Results,@CRLF,'|') GUICtrlSetData($list,$Results) $a='' $b='' $c='' $x='' $y='' Else ;enable gui GUISetState(@SW_ENABLE ,$pingGUI) ;change cursor GUISetCursor(2,0,$pingGUI) ;msg no pings??? EndIf Case $msg = $ResetButton ;clear the list GUICtrlSetData($list,'') ;hide the list GUICtrlSetState($list,$GUI_HIDE+$GUI_DISABLE) ;hide reset btn GUICtrlSetState($ResetButton,$GUI_HIDE+$GUI_DISABLE) ;show ping btn GUICtrlSetState($Pingbutton,$gui_SHOW+$GUI_ENABLE) ;change top label GUICtrlSetData($LabelTop,"Enter address range to Ping:") ;show side labels GUICtrlSetState($LabelEnd,$gui_SHOW+$GUI_ENABLE) GUICtrlSetState($LabelStart,$gui_SHOW+$GUI_ENABLE) ;show all inputs GUICtrlSetState($addressInput1,$gui_SHOW+$GUI_ENABLE) GUICtrlSetState($addressInput2,$gui_SHOW+$GUI_ENABLE) GUICtrlSetState($addressInput3,$gui_SHOW+$GUI_ENABLE) GUICtrlSetState($addressInput4,$gui_SHOW+$GUI_ENABLE) GUICtrlSetState($addressInput5,$gui_SHOW) GUICtrlSetState($addressInput6,$gui_SHOW) GUICtrlSetState($addressInput7,$gui_SHOW) GUICtrlSetState($addressInput8,$gui_SHOW+$GUI_ENABLE) Case $msg = $GUI_EVENT_CLOSE Or $msg = $Exitbutton ;MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...") Exit EndSelect WEnd Func pings() $file = _TempFile() $exefile=@TempDir & '\Pingtest.exe' FileInstall('Pingtest.exe',$exefile,1) ;$file = 'PingResult.ini' $section = 'Pings' ;$address = '192.168.200.' ;$start = 1 ;$end = 255 $cutoff=10 $RunAmount = ($end-$start+1 )/$cutoff $RunAmountN = Round($RunAmount) If $RunAmountN < $RunAmount then $RunAmountN = $RunAmountN+1 ;MsgBox(0,'',$RunAmountN) ;Exit For $i = 1 to $RunAmountN $y = $i*$cutoff if $y > $end then $y=$end if $i<>1 then $x = $i*$cutoff-$cutoff+1 Run($exefile & ' "'&$address&'" '&$x&' '&$y&' '& $i &' "'&$file&'" '&$section) Next Do Sleep(1000) Until not ProcessExists('PingTest.exe') ;MsgBox(0,'','done') $array = IniReadSection($file,'Pings') if @error =0 Then Dim $arrayNew[$array[0][0]+1] $arrayNew[0]=$array[0][0] For $i = 1 to $array[0][0] $arrayNew[$i]=$array[$i][1] Next $array=0 $arrayNew[0]='' _ArraySort($arrayNew);...........................error if 2dim $msgx='' For $i = 1 to UBound($arrayNew)-1;[0] $msgx = $msgx & $arrayNew[$i] & @CRLF ;$msgx = $msgx & $array[$i][1] & @CRLF Next $arrayNew=0 ;MsgBox(0,'Pings Results',$msg) FileDelete($file) FileDelete($exefile) Return $msgx Else ;MsgBox(0,'Error','Error reading pings #'&@error) FileDelete($exefile) FileDelete($file) Return 0 EndIf EndFuncoÝ÷ Øø§7¬µ«¢+Ù%ÀÌØí µ1¥¹lÁt±ÐìØÑ¡¸($í%¹¥]É¥Ñ ÀÌØí¥±°ÌäíÉɽÈÌäì°ÀÌØí¤°ÌäíQ½¼ÜÁɵÑÉÌÌäì¤(%á¥ÐÄ)¹%()=ÁÐ ÅÕ½ÐíQÉå%½¹!¥ÅÕ½Ðì°Ä¤ìÀõÍ¡½Ü°Äõ¡¥ÑÉ䥽¸()½ÈÀÌØí¤ôÄѼØ(%%ÀÌØí µ1¥¹lÀÌØí¥tôÌäìÌäìÑ¡¸($$í5Í ½à À°ÌäìÌäì°Ìäíá¥ÐÈÌäì¤($$í%¹¥]É¥Ñ ÀÌØí¥±°ÌäíÉɽÈÌäì°ÀÌØí¤°Ìäí=¹½Èµ½ÉÁɵÑÉ̵ÁÑäÌäì¤($%á¥ÐÈ(%¹%$)9áÐ((í5Í ½à À°ÌäìÌäì°Ìäí½¬Í¼ÈÌäì¤(ÀÌØíÉÍÌôÀÌØí µ1¥¹lÅt(ÀÌØíÍÑÉÐôÀÌØí µ1¥¹lÉt(ÀÌØí¹ôÀÌØí µ1¥¹lÍt(ÀÌØíIÕ¹9Õ´ôÀÌØí µ1¥¹lÑt(ÀÌØí¥±ôÀÌØí µ1¥¹lÕt(ÀÌØíÍÑ¥½¸ôÀÌØí µ1¥¹lÙt((ÀÌØí½¬ôÌäìÌäì)½ÈÀÌØí¤ôÀÌØíÍÑÉÐѼÀÌØí¹(ì%Q½½±Q¥À ÀÌØíIÕ¹9Õ´µÀìÌäì´µA¥¹¥¹èÌäìµÀìÀÌØí¤°À°ÀÌØíIÕ¹9Õ´¨ÈÀ´ÈÀ¤($ÀÌØíÉÐôA¥¹ ÀÌØíÉÍ̵ÀìÀÌØí¤°ÔÀÀ¤($í5Í ½à À°ÌäíÉÍձн¸ÌäìµÀìÀÌØí¤°ÀÌØíÉФ(%%ÀÌØíÉбÐìÐìÀÑ¡¸($$ÀÌØí¹Ý¤ôÀÌØí¤($%¼($$%%MÑÉ¥¹1¸ ÀÌØí¹Ý¤¤±ÐìÌÑ¡¸ÀÌØí¹Ý¤ôÌäìÀÌäìµÀìÀÌØí¹Ý¤($%U¹Ñ¥°MÑÉ¥¹1¸ ÀÌØí¹Ý¤¤ÐìÈ($$ÀÌØíÈõ%¹¥]É¥Ñ ÀÌØí¥±°ÀÌØíÍÑ¥½¸°ÀÌØí¤°ÀÌØíÉÍ̵ÀìÀÌØí¹Ý¤¤($%%ÀÌØíÈôÀQ¡¸($$%M±À ÄÀÀÀ¤í¥¸ÍÉɽÈÑÉ䥸($$$ÀÌØíÈõ%¹¥]É¥Ñ ÀÌØí¥±°ÀÌØíÍÑ¥½¸°ÀÌØí¤°ÀÌØíÉÍ̵ÀìÀÌØí¹Ý¤¤($$%¥ÀÌØíÈôÀQ¡¸($$$%M±À ÄÀÀÀ¤($$$$ÀÌØíÈõ%¹¥]É¥Ñ ÀÌØí¥±°ÀÌØíÍÑ¥½¸°ÀÌØí¤°ÀÌØíÉÍ̵ÀìÀÌØí¹Ý¤¤($$%¹%($%¹%($$ÀÌØí½¬ôÀÌØí½¬µÀìÀÌØíÉÍ̵ÀìÀÌØí¹Ý¤µÀì I1(%¹%($)9áÐ()Q½½±Q¥À ÌäìÌäì¤(í5Í ½à À°ÌäíÁ¥¹ÌÌäìµÀìÀÌØíIÕ¹9Õ´°ÀÌØí½¬¤(í%¹¥]É¥Ñ ÌäíA¥¹IÍձй¥¹¤Ìäì°ÌäíA¥¹ÌÌäì°ÀÌØíIÕ¹9Õ´°ÀÌØí½¬¤ 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