Recent Changes - Search:

APCU Wiki Home

Meeting Notes Meeting Notes Feed

Favorite links

What's New

New Battery Discussion

Historical notes and links

Creating New Topics

Ward's AutoIT scripts

That graphical outliner Ward uses: APCU.Freemind

APCU's web Home - Leave this wiki

APCU.WardsBlog

Basic Editing
MarkupMasterIndex
SandBox (Try things)

edit SideBar

qping.au3

;;; Little windows program to ping a site; goes on top if fails; 10/24/10 Ward Christensen
;
;
; I could include the gui constants, but just copied over the ONE I needed
;
Global Const $GUI_EVENT_CLOSE = -3
;
; See if the defaults file exists in the current directory
;
$IP = FileExists("qping-default.txt")
;
; Default to pinging every 60 seconds
;
$reset = 60
;
; If the default file exists, process it:   addr   or addr,seconds between e.g. comcast.com,30
;
if $ip = 1 then
        $IPH = FileOpen("qping-default.txt",0)
        $IP = FileReadLine($IPH)
        $ips = stringsplit($ip,",")
        if $ips[0] > 1 then
                $ip = $ips[1]
                $reset = $ips[2]
        endif
        FileClose($IPH)
else
        msgbox(0,"NO: qping-default.txt","No default url file found -  using Comcast.com",3)
;
; if no default file, then ping comcast.com
;
        $IP = "Comcast.com"
endif

;
; This creates the window - title, 300 wide, 120 high,

guicreate("Ping "&$IP,300,120,@desktopwidth-330,@desktopHeight*.72)
GUICtrlCreateLabel ( "Delay (sec)",10,40,100,20)
$PingDelay = 8000

$tmsg1   = GUICtrlCreateLabel ( "     "                        ,    175,  3,110,20);
$pingwho = GUICtrlCreateInput ( $IP,                                 10,  8,150,20);
$tmsg2   = GUICtrlCreateLabel ( "     "                        ,    175, 18,110,20);
$tmsg3   = GUICtrlCreateLabel ( "     "                        ,    175, 32,110,20);
$tmsg4   = GUICtrlCreateLabel ( "     "                        ,    175, 48,110,20);
$tmsg5   = GUICtrlCreateLabel ( "     "                        ,    175, 63,110,20);
$message = GUICtrlCreateLabel ( "Message Area                 ",     10, 65,150,20);
$tmsg6   = GUICtrlCreateLabel ( "     "                        ,    175, 78,110,20);
$failmsg = GUICtrlCreateLabel ( "No Failures                  ",     14,100,230,20);

$which = 1
$fails = 0
$lastfail = ""
$delay = 0
$oldsec = 0
$time = "no"
$delayfield = GUICtrlCreateInput ($reset,90,38,50,20)

GUISetState ()                                                          ; Dislay the window
do
        $msg = GUIGetMsg()                                              ; wait for a windows event
        if $msg = $delayfield then
                $reset = GuiCtrlRead($delayfield)
                $delay = 0
        endif
        if $msg = $pingwho then
                $IP = GuiCtrlRead($pingwho)
                WinSetTitle ("Ping ","","Ping "&$ip)
                $delay = 0
                $fails = 0
                GuiCtrlSetData($FailMsg,"Fails: none")
                GUICtrlSetColor($FailMsg, 0x000000)   ; black

        endif

        if $delay = 0 then
                GuiCtrlSetData($Message,"pinging "&$IP)
                $time = ping($IP,$PingDelay)
                if $time = 0 then
                        winsetontop("Ping "&$ip,"",1)
                        GuiCtrlSetData($Message,"***Can't Ping***")
                        $time="*NO*"
                        $fails = $fails + 1
                        GuiCtrlSetData($FailMsg,"Fails: "&$fails&", Last="&@MON&"/"&@MDAY&"@"&@HOUR&":"&@MIN&":"&@SEC)
                        GUICtrlSetColor($FailMsg, 0xff0000)   ; Red
                else
                        winsetontop("Ping "&$ip,"",0)
                endif
                if $time <> "*NO*" then $time=$time&"ms"
                if $which = 1 then
                        GuiCtrlSetData($tmsg1,$time&" -"&@HOUR&":"&@MIN&":"&@SEC)
                        GuiCtrlSetData($tmsg2,"----------------------------")
                        GuiCtrlSetData($tmsg6," ")
                elseif $which = 2 then
                        GuiCtrlSetData($tmsg2,$time&" -"&@HOUR&":"&@MIN&":"&@SEC)
                        GuiCtrlSetData($tmsg3,"----------------------------")
                elseif $which = 3 then
                        GuiCtrlSetData($tmsg3,$time&" -"&@HOUR&":"&@MIN&":"&@SEC)
                        GuiCtrlSetData($tmsg4,"----------------------------")
                elseif $which = 4 then
                        GuiCtrlSetData($tmsg4,$time&" -"&@HOUR&":"&@MIN&":"&@SEC)
                        GuiCtrlSetData($tmsg5,"----------------------------")
                elseif $which = 5 then
                        GuiCtrlSetData($tmsg5,$time&" -"&@HOUR&":"&@MIN&":"&@SEC)
                        GuiCtrlSetData($tmsg6,"----------------------------")
                endif

                $which = $which + 1
                if $which = 6 then $which = 1

                $delay = $reset
        endif
        if $oldsec <> @sec then
                $oldsec = @sec
                if $delay > 0 then $delay = $delay - 1
                GuiCtrlSetData($Message," Sleeping..." & $delay);

        endif

until $msg = $Gui_EVENT_CLOSE


Edit - History - Print - Recent Changes - Search
Page last modified on December 19, 2010, at 02:09 PM