Jump to content
Sign in to follow this  
d0n

doesn't close

Recommended Posts

d0n

How come the on event close does not seem to work?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Server Status", 80, 40)
$Label1 = GUICtrlCreateLabel("", 10, 10, 70, 20)
GUISetState(@SW_SHOW)

Gui()

Func Check()
    $var = Ping("75.150.216.162",250)
    If $var Then
        GUICtrlSetData($Label1, "Server Online")
    Else
        GUICtrlSetData($Label1, "Server Offline")
    EndIf
EndFunc

Func Gui()
    While 1
        $Msg = GUIGetMsg()
        If $Msg = $GUI_EVENT_CLOSE Then
            Exit
        EndIf
        Check()
        Sleep(500)
    WEnd
EndFunc

Share this post


Link to post
Share on other sites
enaiman

Sleep inside main loop in this mode = big NO-NO.

Use OnEvent Mode if you need sleep time or, put the sleep inside your Check() function.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
d0n

That still doesn't close my GUI, unless i missed something :S

Share this post


Link to post
Share on other sites
Valuater

The sleep(500) was "most" of the prob AFAIK

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $Ping_Complete = False

$Form1 = GUICreate("Server Status", 80, 40)
$Label1 = GUICtrlCreateLabel("", 10, 10, 70, 20)
GUISetState(@SW_SHOW)

Gui()

Func Check()
    $var = Ping("75.150.216.162", 250)
    If $var Then
        GUICtrlSetData($Label1, "Server Online")
    Else
        GUICtrlSetData($Label1, "Server Offline")
    EndIf
    $Ping_Complete = True
EndFunc   ;==>Check

Func Gui()
    While 1
        $Msg = GUIGetMsg()
        If $Msg = $GUI_EVENT_CLOSE Then
            Exit
        EndIf
        If Not $Ping_Complete Then Check()
    WEnd
EndFunc   ;==>Gui

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
d0n

thanks for the help :D

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  

×