Sign in to follow this  
Followers 0
cameleonowsky

IP address refresh

7 posts in this topic

Hello,

I'm trying to track my IP address. @IPaddress1 shows my IP correctly, but to find out the change (for example when LAN cable is disconnected) i must restart my program to see that my LAN network is down.

I was trying to make something like:

(...)
while 1
$IP = @IPaddress1
Sleep(1000)
ConsoleWrite($IP)
Wend

and its working correctly, but trying to put it in form by

(...)
$output=GuiCtrlCreateLAbel("IP: " & $IP,266,80,100,100)

make the form unstable and unable or hard to close.

Is there any way to make it simpler?

Share this post


Link to post
Share on other sites



Instead of re-writing the label, use GUICtrlSetData. Checking if the data has changed, then using GUICtrlSetData, reduces/eliminates flicker.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

yes, its working now ;) but a little flicker still exist. But its ok, thank you !

How about IP address consist of for ex. "192.168.*.*" ?

$IP = @IPaddress1
If Not $IP = "192.168.*.*" Then
(...)

autoit doesn't seem to like * star :evil: because its not working

Share this post


Link to post
Share on other sites

How about IP address consist of for ex. "192.168.*.*" ?

$IP = @IPaddress1
If Not $IP = "192.168.*.*" Then
(...)

$IP = StringSplit(@IPaddress1, ".")
ConsoleWrite(@IPaddress1 & @LF & $IP[1] & "." & $IP[2] & "." & $IP[3] & "." & $IP[4] & @LF)
If $IP[1] = "192" And $IP[2] = "168" Then
;...

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Add Sleep before GUICtrlSetData, 250 or so.

Nope, adding Sleep eliminates flicker, but whole application is being unstable and hard to close. But i've found an example using "AdlibEnable( function, time)" which eliminates flicker

#include <GUIConstants.au3>

GUICreate("Test")

$label1 = GUICtrlCreateLabel("", 10, 10, 200, 20)
GUISetState()

AdlibEnable("UpdateLabel", 500)

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
Exit

Func UpdateLabel()
    GUICtrlSetData($label1, "Label1" & Random(0, 500))
EndFunc

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

yes, its working now ;) but a little flicker still exist. But its ok, thank you !

How about IP address consist of for ex. "192.168.*.*" ?

$IP = @IPaddress1
If Not $IP = "192.168.*.*" Then
(...)

autoit doesn't seem to like * star :evil: because its not working

You can't use a wildcard when comparing strings using an equals sign.

You could do it with RegExp (though the syntax would be a lot more complex than a simple star), but it would be easier to do something like:

If StringLeft(@IPAddress1,8) <> "192.168." Then
Edited by james3mg

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

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