Jump to content

GUICtrlCreateMenuitem update on every click


Didonet
 Share

Recommended Posts

I have a drop-down menu in my program.

Like that:

$connectitem = GUICtrlCreateMenuitem ("Login",$filemenu)

If Ping("my.site.com",250) Then GUICtrlSetState(-1,$GUI_DISABLE)

$disconnectitem = GUICtrlCreateMenuitem ("Logout",$filemenu)

If Not Ping("my.site.com",250) Then GUICtrlSetState(-1,$GUI_DISABLE)

When the program loads it pings the site. But when the connection is lost the info is still the old. Can i refresh it ? I try with WHILE, but it didn't works.

I try this:

$disconnectitem = GUICtrlCreateMenuitem ("Logout",$filemenu)

While 1

$msg = GUIGetMsg()

Select

Case $msg = $disconnectitem

If Not Ping("forum.recbg.net",250) Then

GUICtrlSetState(-1,$GUI_DISABLE)

EndIf

EndSelect

WEnd

Error:

myscript.au3 (28) : ==> Variable used without being declared.:

If Ping("my.site.com",250) Then GUICtrlSetState(-1,$GUI_DISABLE)

If Ping("my.site.com",250) Then GUICtrlSetState(-1,^ ERROR

:)

What a spammer am i... :)

Edited by Didonet
Link to comment
Share on other sites

$disconnectitem = GUICtrlCreateMenuitem ("Logout",$filemenu)

While 1
    $msg = GUIGetMsg()
        Select
        Case $msg = $disconnectitem
        If Not Ping("forum.recbg.net",250) Then
            GUICtrlSetState($disconnectitem, $GUI_DISABLE)
        EndIf
        EndSelect
WEnd

your error is that you use GUICtrlSetState(-1, $GUI_DISABLE) and -1 indicates the latest variable (item) used, so you cant use -1 you have to insert the variable of your menu item

(i suggest that you change 250 [timeout] to a larger value, cause there is a possibility that it wont ping that site in 250 and there might be a false result)

Edited by Gif
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...