Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
break on $=setconsole("hide")
;$merlin_path = "%windir%\msagent\chars\merlin.acs" ;$agent = createobject ("agent.control.2") ;$agent.connected= "1" ;$= $agent.characters.load("merlin","$merlin_path") ;$merlin = $agent.characters.character("merlin")
$KPingerRegKey='HKEY_CURRENT_USER\Software\KPinger' Global $ButtonArray0[0] $row = 5 $col = 5 $hoff = 1 $voff = 10 $hsize = 20 $vsize = 20
$Form = CreateObject("Kixtart.Form") $yres = $Form.screen.height $Form.Size = 1,1 $Form.left = 0 $Form.Text = "KPinger" $Form.MinButton = 0 $Form.borderstyle = 0 $Form.top = $yres-taskbar()+3-$Form.height
$=tb("New Server" ,0,0,12) $Server1.onClick = "add()" $=tb("End Program",1,0,37) $Server2.onClick = "end()"
$Index = 0 $ValueName = ENUMVALUE("$KPingerRegKey", $Index) While @ERROR = 0 $nextbutton=ubound($buttonarray0)+1 $=tb($ValueName,$nextbutton,0,32) $Index = $Index + 1 $ValueName = ENUMVALUE("$KPingerRegKey", $Index) Loop
$timer=$form.timer(60*1000) $timer.ontimer='pingarray()'
$Form.Show While $Form.Visible $= Execute($Form.DoEvents) Loop Exit 1 : **************************************************************************** Function PingArray() for $loop=3 to ubound($buttonarray0) $controlname=$buttonarray0[$loop] $rc=execute("$$commonname = $$$controlname.tooltip") $rc=execute("$$$controlname.icon=35") $p=WSHPing($commonname) if $p[1]=1 $rc=execute("$$$controlname.icon=34") else $rc=execute("$$$controlname.icon=33") ; $= $merlin.show() ; $wait = $merlin.speak("$commonname doesn't reply to ping" ) ; do sleep 1 until $merlin.wait($wait) <> 0 endif next ;$= $merlin.hide() endfunction
function TB($name,$r,$c,$icon) dim $left, $top $rc=execute("$$ubound=ubound($$buttonarray$c)+1") $controlname="Server$ubound" ;? $controlname $commonname =$name ;? $commonname $left=($hoff+$hsize)*$r+$row $top =($vsize+$voff)*$c+$col $rc=execute(' redim preserve $$ButtonArray$c[$ubound] $$ButtonArray$c[$r] = "$Controlname" $$$controlname=$$Form.ToolButton("",$left,$top,$hsize,$vsize) $$$controlname.icon = $icon $$$controlname.Tooltip = "$commonname" $$$controlname.ToggleStyle = 0 $$$controlname.onClick = "" ') while $top + $vsize + $voff >= $form.clientheight $form.clientheight=$form.clientheight + 2 loop while $left + $hsize + $hoff >= $form.clientwidth $form.clientwidth=$form.clientwidth + 2 loop if $form.right + $hsize + $hoff >= $Form.screen.width $Server1.enabled = 0 endif endfunction
Function Add() $servername=$form.inputbox("Server Name or IP addr to monitor","Add Server") if $servername $nextbutton=ubound($buttonarray0)+1 $=tb($servername,$nextbutton,0,32) $=writevalue("$KPingerRegKey",$servername,'',Reg_SZ) endif endfunction
Function TaskBar() If @dos=="4.0" $_S="StuckRects" Else $_S="StuckRects2" EndIf $TaskBar=Val("&"+SubStr(ReadValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\$_S","settings"),41,2)) EndFunction
Function end() quit endfunction ;**************************************************************************** Function WshPipe($ShellCMD, OPTIONAL $NoEcho) Dim $WshShell, $oExec, $AllOutput, $Exit, $WshExitCode $WshErrorMsg="" $WshShell=CreateObject("WScript.Shell") $oExec=$WshShell.Exec($ShellCMD) While $Exit<>1 Dim $Output Select Case Not $oExec.StdOut.AtEndOfStream $Output=$oExec.StdOut.ReadAll Case Not $oExec.StdErr.AtEndOfStream $Output=$oExec.StdErr.ReadAll $WshErrorMsg = $Output Case 1 $Output=-1 EndSelect If $Output=-1 If $oExec.Status=1 $Exit=1 Endif Else If $NoEcho<>1 ? $Output Endif $AllOutput = $AllOutput + $Output Endif Loop $WshExitCode=$oExec.ExitCode $WshPipe=split($AllOutput,chr(10)) Exit($WshExitCode) EndFunction ;******************************************************************************************************** FUNCTION WSHPing($Computer,optional $replies) dim $ip, $l, $r, $count, $return, $line ,$pos, $avg if not $replies $replies=1 endif $ip=$computer $Count=0 $shell='%comspec% /c %windir%\system32\ping $Computer -n $replies ' $return=WSHPipe($shell,1) if not @error for each $line in $return select case instr($line,"[") $l=instr($line,"[")+1 $r=instr($line,"]") $ip=substr($line,$l,$r-$l) case instr($line,"reply from") $Count=$Count+1 case instr($line,"Average") $pos=instr($line,"Average")+8 $avg=val(right("$line",len($line)-$pos)) endselect if instr($line,"timed out") $Count=$Count-1 endif next $WSHPing=$ip,$count,$avg else $WSHPing="0.0.0.0","0","0" exit(487) endif ENDFUNCTION
|