Jump to content

Get Local IP Address


Recommended Posts

somebody help me..

i cant created project with local ip monitor..

here my example script

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 321, 59, 192, 124)
$Label1 = GUICtrlCreateLabel("Your IP :", 16, 16, 84, 28)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel(@IPAddress1, 104, 16, 130, 28)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

My problem..

when i am disconnect modem GUI not auto set to 127.0.0.1

i am must close and run gui again for update status my network..

thanks before for help..

sorry my english speak is very bad..

Link to comment
Share on other sites

somebody help me..

i cant created project with local ip monitor..

You need to implement a query inside your While ... Wend loop (probably involving a timed check after a specified duration) or maybe even just use a button.

Here's a simple implementation without timing.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 321, 59, 192, 124)
$Label1 = GUICtrlCreateLabel("Your IP :", 16, 16, 84, 28)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel(@IPAddress1, 104, 16, 130, 28)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $lastip = @IPAddress1

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch

        If $lastip <> @IPAddress1 Then
           $lastip = @IPAddress1
           GuiCtrlSetData($Label2, $lastip)
        EndIf
WEnd

That's better, copied properly by copying from a quoted version of code ... anyway I digress.

Not sure what constantly checking a Macro does for memory use, but personally I'd either go Timed (TimerInit and TimerDiff) or use a Button.

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

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...