Sign in to follow this  
Followers 0
Ruud0209

Check if Website is up then do this else that

12 posts in this topic

#1 ·  Posted (edited)

Hi,

i'm pretty new to autoIt script and not quite as smart as i would like to be ( :P ) but...

I want to make a script that, when started, pings a host and when succesfull connects to it with Obj.Navigate.

If the host is down the script should display a nice message saying the houst is unreachable.

In both cases I want it to ping at a regular interval to see if the connection status is changed and, if so. act accordingly.

When the connection is ok it shoud keep pinging but not do a page refresh.

So far i've put this together but, for obvious reasons, this isn't quite working the way I want it to.

Is there anybody out there wich some spare time ??

TIA

;start
#include <GUIConstants.au3>
#include <IE.au3>

$Form1 = GUICreate("Zuilen Pagina", 800, 600, 10, 10);,  $WS_POPUP )
$Obj = ObjCreate("Shell.Explorer.2")
$browser = GUICtrlCreateObj($Obj, 0, 0, 800, 600 )
GUISetState(@SW_SHOW)
sleep (2000)

;$var = Ping("www.google.nl",250)
$var = Ping("www.google.nl",250)

While 1
If $var Then ;also possible:  If @error = 0 Then ...
;   Msgbox(0,"Status","Online, roundtrip was:" & $var)
; $Form1 = GUICreate("Test Webbrowser", 1024, 770, 10, 10,  $WS_POPUP, $WS_EX_TOPMOST)

$Obj.Navigate ('http://www.google.com')
;$Obj.Navigate ('about:blank')
 
Sleep (2000)
Else


sleep (2000)

$Obj.Navigate ('about:blank')

$sHTML = "<h1>The Server is unreachable</h1>"
WinActivate("Zuilen Pagina")
_IEBodyWriteHTML ($Obj, $sHTML)

Endif

WEnd


While 1
     $msg = GUIGetMsg()
         Select
         Case $msg = $GUI_EVENT_CLOSE
             ExitLoop

         Case Else
      ;;;;;;;
      EndSelect
WEnd
; end

Edit: It should also refresh when some 1 or more frames conains a 404 or 500 page.

Can this be done?

Edited by Ruud_Sas

Share this post


Link to post
Share on other sites



bump ?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

What are you trying to make? What problem does it solve? (just wondering)

We have a bunch of remote locations wich have a kind of intranet station connecting to a webserver at the headoffice.

They are "touch screen only". Because the are on DSL locations they sometimes timeout.

The thing is that the main intranetpage they connect to is made up of a few frames and, if noone is working on it for a minute or so, it resets itself to the main page.

During this process it sometimes times out, probably due to network hickups or something.

This cause ugly 404 pages in several frames as it can't find a server, and since users cannot "F5" to refresh they sometimes have to completely turn off/and on the thing by pulling the plug (no nice shutdown).

So what I'm trying to achieve is to make it more robust and to display a message if the server cannot be reached but to keep checking wether or not it can.

This way it will have a higher uptime and can/will be used better/more.

Edited by Ruud_Sas

Share this post


Link to post
Share on other sites

I see. You had a great start. Try this:

#include <GUIConstants.au3>
#include <IE.au3>
Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode


$Form1 = GUICreate("Zuilen Pagina", 800, 600, 10, 10);,  $WS_POPUP )

GUISetOnEvent($GUI_EVENT_CLOSE, "terminate")
Func terminate()
  exit
EndFunc

$Obj = _IECreateEmbedded ( )
$browser = GUICtrlCreateObj($Obj, 0, 0, 800, 600 )
GUISetState(@SW_SHOW)
_IENavigate ($Obj, 'about:blank')
$sHTML = "<h1>Initializing...</h1>"
_IEBodyWriteHTML ($Obj, $sHTML)

$online = 1
$wasonline = 0

While 1
    
    if Ping("www.google.com",250) Then
        $online = 1
    Else
        $online = 0
    EndIf
    if $wasonline <> $online Then
        WinActivate($Form1)
        $wasonline = $online
        if $online Then
            _IENavigate ($Obj, 'http://www.google.com')
        Else
            _IENavigate ($Obj, 'about:blank')
            $sHTML = "<h1>The Server is unreachable</h1>"
            _IEBodyWriteHTML ($Obj, $sHTML)
        EndIf
    EndIf
    sleep (2000)

WEnd


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

Hi,

kudos for you man !

We'll finetune it for our needs and put it to a live test the coming week.

So far it looks like its exactly what we need.

You are the :P

Thanks a lot ! :nuke:

Share this post


Link to post
Share on other sites

@lod3n

Good job. Nice and clean - I like it.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

In my first post I wrote I wanted to make an application that pings a host with an interval.

Since then, with the help of Lod3n and numerous forum contributors, I've been able to make a little program that actually works fine except that it now pings a little to often (i think)

The problem, I think, is in the last "while" loop.

I want it to ping the host but I also want it to check the system tray for input . When I put a sleep in the first part it seems like it neer sleeps and when i put it after the second part (after the select) in only sleeps.

Whoever is willing to take a good look and give me some hints. I also would like some "good programming conduct" feedback if possible if you know what I mean.

Search for ;;;;- to get to the things I have a question about.

What the application does is check if it is installed, checks what IP the PC it runs on has, if the ini should be read and then displays a IE object/page.

The original ping loop was kindly provided by lod3n.

If you intend to run it then remember there may be some registrykeys written (if you install):

HKLM\Software\Zuilen

HKCU\Software\Zuilen

HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\Zuilen

and

HKCU\Software\Microsoft\Windows\Currentversion\Run key: Zuilen

Any help appreciated.

I will insert my code here :

;; Includes

#Include <GUIConstants.au3>
;#Include <GUIDefaultConstants.au3>
;#Include <Constants.au3>
;#Include <WindowsConstants.au3>
#Include <IE.au3>

Global $autostartitem
Global $lokatie
Global $inifile
Global $initem
; ----------------------------------------------------------------------------
;;;; Funtioncs

Func _SelectLok()
      $Form2 = GUICreate("Vestiging_selectie", 240, 160, @DesktopWidth / 2 - 120, @DesktopHeight / 2 - 260)
    $City_Combo = GUICtrlCreateCombo("Eindhoven", 24, 48, 177, 21)
    GUICtrlSetData(-1, "Eindhoven|Nijmegen|Heerlen|Maastricht|Roermond|Venlo|Sittard|Helmond")
    GUICtrlCreateLabel("Welke vestiging wilt u emuleren ?", 24, 24, 162, 17)
    $Group1 = GUICtrlCreateGroup("Maak uw keuze:", 8, 8, 224, 140)
    

    $OKButton = GUICtrlCreateButton("&OK",14, 100, 210, 33 ) 
    GUICtrlSetState(-1,$GUI_FOCUS)  
    GUISetState(@SW_SHOW)
while 1
        $msg1 = GuiGetMsg()
        Select
            Case $msg1 = $GUI_EVENT_CLOSE
                GUISetState(@SW_HIDE)
                terminate()
                Exitloop
            Case $msg1 = $OKButton
                GUISetState(@SW_HIDE)
                $selection = GUICtrlRead( $city_Combo )
                Return $selection

                Case Else
        ;;;;;
        EndSelect
Wend

EndFunc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func terminate()
    ConsoleWrite('@@ (107) :(' & @MIN & ':' & @SEC & ') terminate()' & @CR);### Trace Function
    exit 3
EndFunc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func _Install()
    
;If RegRead("HKEY_LOCAL_MACHINE\Software\Zuilen","InstallPath") Then
;;  MsgBox(64, "Error" , "errorlevel : " & @error )
;Else
;   MsgBox(64, "Error" , "errorlevel : " & @error )
    $PathToInstall = FileSelectFolder("Select Folder", @ProgramFilesDir ,3)
    RegWrite("HKEY_LOCAL_MACHINE\Software\Zuilen","Installpath","REG_SZ", $PathToInstall)
    RegWrite("HKEY_LOCAL_MACHINE\Software\Zuilen","ProgramName","REG_SZ", @ScriptName)
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Zuilen", "DisplayIcon", "REG_SZ", $PathToInstall & "\" & @ScriptName )
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Zuilen", "DisplayIconEx", "REG_SZ", $PathToInstall & "\" & @ScriptName )
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Zuilen", "DisplayName", "REG_SZ", "Zuilen Emulator")
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Zuilen", "EstimatedSizeEx", "REG_DWORD", "00000259")
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Zuilen", "InstallLocationEx", "REG_SZ", $PathToInstall)
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Zuilen", "NoModify", "REG_DWORD", "00000001")
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Zuilen", "NoRepair", "REG_DWORD", "00000001")
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Zuilen", "UninstallString", "REG_SZ", """" &  $PathToInstall & "\uninstall.exe" & """" )
    RegWrite("HKEY_CURRENT_USER\Software\Zuilen","PingSpeed","REG_SZ", "250")
    RegWrite("HKEY_CURRENT_USER\Software\Zuilen","ReadIni","REG_SZ", "0")

    FileInstall ("C:\Program Files\AutoIt3\Projects\zuilen\zuilen_banner.jpg" , $PathToInstall & "\", 1 )
    DirCreate ( @WindowsDir & "\uninstall\zuilen")
    FileInstall ("C:\Program Files\AutoIt3\Projects\zuilen\uninstall.exe" , $PathToInstall & "\",1)
    FileCopy( @ScriptFullPath , $PathToInstall , 1 )
    DirCreate ( @ProgramsCommonDir & "\Zuilen")
    FileCreateShortcut( $PathToInstall & "\" & @ScriptName, @ProgramsCommonDir & "\Zuilen\Zuilen Emulator.lnk")
    return
    Exit
    Exit
;EndIf
    
EndFunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func OnAutoItStart()

    If $CmdLine[0]>"0" Then
        If $CmdLineRaw <> "" Then
    ;;
            IF $CmdLineRaw = "/INSTALL" Then
                _Install()
                exit
            Else
                MsgBox(16, "De parameter is incorrect !", "Gebruik : " & @ScriptName & " [/INSTALL]")
                Exit
            Endif
        Endif
    Endif
EndFunc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func _SetPingValue()
    
;#include <GUIConstants.au3>
; == GUI generated with Koda ==
Local $Form2
Local $Group2
Local $Input2
Local $Slider2
Local $msg2
Local $Pingvalue
$Pingvalue = RegRead("HKEY_CURRENT_USER\Software\Zuilen","PingSpeed")
$Form2= GUICreate("Stel ping waarde in millisecondes in :", 533, 183, 192, 125)
$Group2 = GUICtrlCreateGroup("Stel de ping waarde in met de schuifknop", 8, 8, 513, 161)
$Input2 = GUICtrlCreateInput("$Pingvalue", 32, 32, 89, 21)
$Slider2 = GUICtrlCreateSlider(144, 32, 353, 41, BitOR($TBS_AUTOTICKS,$TBS_NOTICKS))
GUICtrlSetLimit(-1,1500,250)
GUICtrlSetData( $Slider2 , $Pingvalue )
GUICtrlCreateLabel("250", 144, 72, 22, 17)
GUICtrlCreateLabel("1500", 472, 72, 28, 17)
$Button2 = GUICtrlCreateButton("&OK", 176, 112, 145, 33, $BS_DEFPUSHBUTTON)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
While 1
    $msg2 = GUIGetMsg()
    GUICtrlSetData($Input2,GUICtrlRead($Slider2))
    Select
    Case $msg2 = $GUI_EVENT_CLOSE 
        Exit
        
    Case $msg2 = $Button2
        RegWrite("HKEY_CURRENT_USER\Software\Zuilen","PingSpeed","REG_SZ",GUICtrlRead($Slider2))
        GUISetState(@SW_HIDE)
        Return GUICtrlRead($Slider2)
        ExitLoop
    EndSelect
    sleep (25)
Wend

EndFunc

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func AutoStart()
    If RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Zuilen","InstallPath") = "" Then
        MsgBox ( 16, "Programma is niet geinstalleerd", "Installeer a.u.b. het programma eerst.",10)
    Else
        IF RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","Zuilen") = "" Then
            If RegWrite("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","Zuilen","REG_SZ",RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Zuilen","InstallPath") & "\" & RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Zuilen","ProgramName")) Then TrayItemSetState($autostartitem,65)
        Else
            If RegDelete("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","Zuilen") Then TrayItemSetState($autostartitem,68)
        Endif
EndIf
EndFunc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func _SetState()
If RegRead("HKEY_LOCAL_MACHINE\Software\Zuilen","Installpath") Then
    TrayItemSetState ($installitem,128)
    Else
    TrayItemSetText( $installitem,"Installeren")
Endif
EndFunc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func _SetIni()
    If RegRead("HKEY_LOCAL_MACHINE\Software\Zuilen","Installpath") Then
        If RegRead("HKEY_CURRENT_USER\Software\Zuilen","ReadIni") = "0" Then
            TrayItemSetState ($initem,65)
            RegWrite("HKEY_CURRENT_USER\Software\Zuilen","ReadIni","REG_SZ","1")
            return 1
        Else
            TrayItemSetState( $initem,68)
            RegWrite("HKEY_CURRENT_USER\Software\Zuilen","ReadIni","REG_SZ","0")
            return 0
        Endif
    Else
    MsgBox ( 16, "Programma is niet geinstalleerd", "Installeer a.u.b. het programma eerst.",10)
    EndIf   
EndFunc

Func _ReadIni()
    If RegRead("HKEY_LOCAL_MACHINE\Software\Zuilen","Installpath") Then
        If RegRead("HKEY_CURRENT_USER\Software\Zuilen","ReadIni") = "0" Then
            TrayItemSetState ($initem,68)
            return 0
        Else
            TrayItemSetState( $initem,65)
            return 1
        Endif
    Else
    MsgBox ( 16, "Programma is niet geinstalleerd", "Installeer a.u.b. het programma eerst.",10)
    return 0
    EndIf   
EndFunc
;;;; End Functions
;; Options
Opt("GUIOnEventMode", 0); Change to OnEvent mode
Opt("TrayMenuMode",1); Default tray menu items (Script Paused/Exit) will not be shown.
Opt("TrayIconDebug",0); Debug in tooltip
Opt("TrayAutoPause",0)
;; End Options

;; TrayTip
TrayTip ("Google Zuilen", "Het Zuilen programma is aktief" , 1, 1)
;; End Traytip
;;splashimage
#Region --- CodeWizard generated code Start ---
;SpashImage features: Title=Yes, Always On Top
SplashImageOn("Google Groep NV","zuilen_banner.jpg","480","60","-1","-1",1)
Sleep ( 1000 )
SplashOff()
#EndRegion --- CodeWizard generated code End ---

;;end splashimage
;; TrayItems
;;; Check Installation

;;;

$settingsitem = TrayCreateMenu("Instellingen")
$installitem    = TrayCreateItem("Installeren", $settingsitem)
$autostartitem = TrayCreateItem("AutoStart", $settingsitem)
TrayCreateItem("", $settingsitem)
$initem = TrayCreateItem("Gebruik INI", $settingsitem)
TrayCreateItem("", $settingsitem)

$PingItem = TrayCreateItem("Ping Instellingen", $settingsitem)
TrayCreateItem("")
$aboutitem  = TrayCreateItem("Over")
TrayCreateItem("")
;$aboutitem = TrayCreateItem("About")
;TrayCreateItem("")
$exititem   = TrayCreateItem("Exit")
;; End TrayItems

$Autorun=RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","Zuilen")
; MsgBox (64,"Autorun :", $Autorun ) 
If $Autorun = "" Then 
TrayItemSetState($autostartitem,68)
Else
TrayItemSetState($autostartitem,65)
Endif
_SetState()
$setlokatie = _ReadIni()
;MsgBox(0,"Ini", "Value :"& $setlokatie)

$copyright = Chr("169")

If $setlokatie = "0" then 
    
DIM $IP = @IPAddress1; get local IP
$lokatie = StringReplace(StringReplace($IP, "." , "" ),"192168",""); From the ip adress replace the "." with nothing then replace 192168 with nothing.
; MsgBox (64,"ip = ", $lokatie )
Select
    case $lokatie = "17343"; If ip adress ends with
        $lokatie = "EINDHOVEN";  Lokatie = City
    case $lokatie = "17415"
        $lokatie = "EINDHOVEN"
    case $lokatie = "166"
        $lokatie = "HEERLEN"
    case $lokatie = "17715"
        $lokatie = "HEERLEN"
    case $lokatie = "17845"
        $lokatie = "HEERLEN"
    case $lokatie = "18215"
        $lokatie = "HELMOND"
    case $lokatie = "17015"
        $lokatie = "MAASTRICHT"
    case $lokatie = "17853"
        $lokatie = "MAASTRICHT"
    case $lokatie = "17615"
        $lokatie = "NIJMEGEN"
    case $lokatie = "17815"
        $lokatie = "NIJMEGEN"
    case $lokatie = "17834"
        $lokatie = "NIJMEGEN"
    case $lokatie = "17867"
        $lokatie = "ROERMOND"
    case $lokatie = "16915"
        $lokatie = "SITTARD"
    case $lokatie = "17860"
        $lokatie = "VENLO"
    case $lokatie = "17915"
        $lokatie = "VENLO"
    case Else
        $lokatie = _SelectLok()

    EndSelect
Else
    If StringRight( @scriptname,3) = "au3" Then
        $inifile = StringReplace(@Scriptname,".au3",".ini")
        Else
        $inifile = StringReplace(@Scriptname,".exe",".ini")
    Endif
        If not FileExists($inifile) Then
            MsgBox (16 , "Fout :","Het bestand " & $inifile & " is niet gevonden" & @CRLF & "Er wordt een bestand aangemaakt")
            IniWrite($inifile,"Instellingen","Lokatie","Geen")
        Else
            $lokatie = IniRead( $inifile,"Instellingen","Lokatie","Geen")
            If $lokatie = "Geen" Then
                MsgBox (16 , "Fout :","Het bestand " & $inifile & " bevat een fout op de lokatie sleutel : " & $lokatie & @CRLF & "Herstel de fout en start het programma opnieuw")
                terminate()
            Else
            MsgBox (64,"Lokatie :", "Lokatie ingesteld op : " & $lokatie ,2)
            EndIf
        Endif
EndIf
$Form1 = GUICreate("Zuilen Pagina", 1024, 772, (@DesktopWidth - 1024) /2, (@DesktopHeight - 768) /2,  BitOR($WS_POPUP,$WS_EX_TOPMOST  )); create the GUI object
; The Internet Explorer object will be projected on this object.

GUISetOnEvent($GUI_EVENT_CLOSE, "terminate")

$Obj = _IECreateEmbedded ( )
$browser = GUICtrlCreateObj($Obj, 0, 0, 1024, 772 )
GUISetState(@SW_SHOW)
_IENavigate ($Obj, 'about:blank')
dim $sHTML
$sHTML = "<HTML><BODY><BR><BR><BR><CENTER><h1 style='font-family : ARIAL; color: #000377'>" _
        & "Er wordt verbinding gezocht met de server ...</h1><BR>" _
        & " <h2 style='font-family : ARIAL; font-size : 20px; font-weight :bold; color: #000377'>Een moment geduld a.u.b.</h2>" _
        & "<BR><BR><BR><h2 style='font-family : ARIAL; color: #000377'> Lokatie : " & $lokatie & "</h2></CENTER></body></html>"
_IEBodyWriteHTML ($Obj, $sHTML)

$online = 1
$wasonline = 0

sleep ( 2000 )
dim $pingwaarde
$ping = RegRead("HKEY_CURRENT_USER\Software\Zuilen","PingSpeed")

while   1
        if Ping("www.Google.nl",$ping ) Then
;   MsgBox(0,"Ping","MS : " & $ping )
        $online = 1
    Else
        $online = 0
    EndIf
    if $wasonline <> $online Then
        WinActivate($Form1)
        $wasonline = $online
        if $online Then
            _IENavigate ($Obj, 'http://www.Google.nl')

        Else
            _IENavigate ($Obj, 'about:blank')
            $sHTML = "<HTML><BODY><CENTER><BR><BR><BR><h1 style='font-family : ARIAL; font-size : 24px; font-weight" _
                    & ":bold; color: #000377'>De server is tijdelijk niet bereikbaar. </h1><BR><BR><h2 style='font-family : ARIAL;" _
                    & "font-size : 20px; font-weight :bold; color: #000377'>De verbinding wordt automatisch hersteld ...</h2>"
            _IEBodyWriteHTML ($Obj, $sHTML)
        EndIf
        Sleep (2000);;;;- If Here it never seems to sleep
    EndIf
_SetState()               ;;;;-  Is this the best place for this to be ?
HotKeySet ("!{F4}","terminate");;;;- And what about this ?

    $msg = TrayGetMsg()
            Select
            case $msg = $GUI_EVENT_CLOSE
                terminate()
            case $msg = $installitem
                  _Install()
              case $msg = $autostartitem
                  autostart()
              case $msg = $initem
                  _SetIni()
              case $msg = $PingItem
                  $pingwaarde = _SetPingValue()
                  $ping = $pingwaarde
            ; MsgBox(0,"", $ping & " - " & $pingwaarde )
               Case $msg = $aboutitem
                Msgbox(64, "Over:", "Google Zuilen Emulator" & @CRLF & "Ruud Sas "  & " (2006)"& @CRLF & "Version : 1.3b" )
            Case $msg = $exititem
                Exit
                terminate()
            Case Else
        ;;
     EndSelect
Sleep (2000);;;;- If Here  systemtray does not respond
Wend

Share this post


Link to post
Share on other sites

You can do something like the following, but this is just a conceptual example, you'll have to work it into your code:

$count = 0
while 1
  $count += 1
  if $count = 10 then ; you can change the 10 to whatever you like
     $count = 0
     checkhost() ; does the ping, etc.
  endif

  $msg = guigetmsg()
  $msg = TrayGetMsg()
wend


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

You can do something like the following, but this is just a conceptual example, you'll have to work it into your code:

$count = 0
while 1
  $count += 1
  if $count = 10 then ; you can change the 10 to whatever you like
     $count = 0
     checkhost() ; does the ping, etc.
  endif

  $msg = guigetmsg()
  $msg = TrayGetMsg()
wend

Thanks for the advice, in the meanwhile, i've deciced to go for hotkeys though. This keeps the ping loop clean and makes the program a little shorter because it was getting pretty messy :).

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0