Jump to content

gui input ip address


NTBM
 Share

Recommended Posts

This seems so simple but i cannot find an answer in either the forum or help file.

i am creating a Gui that has an input box which displays a default IP address, however when i reference the variable i get returned a different value.

see

$Label6 = GUICtrlCreateLabel("IP Address", 34, 160, 55, 17)
$I_IP = GUICtrlCreateInput("10.0.0.2", 96, 160, 121, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
MsgBox(0,"IP", String($I_IP))

Obviously there are more gui lines above this but what i have put above has no missing lines (so that you can see that the variable is not getting re-valued anywhere).

When i run this the msgbox says the value is "16" What am i missing ?

Cheers guys.

Link to comment
Share on other sites

GUICtrlCreateInput() returns a control id.

Return Value

Success: Returns the identifier (controlID) of the new control.

Use GUICtrlRead() on that to read the value.

To obtain the value of the control see GUICtrlRead.

GUICreate("")
$I_IP = GUICtrlCreateInput("10.0.0.2", 96, 160, 121, 21)
MsgBox(0,"IP", GUICtrlRead($I_IP))

Also, if the intent is for the user to write down a IP, you may want to look at "GuiIPAddress Management" in the helpfile for a control made for this.

Link to comment
Share on other sites

My bad feeling a little foolish. Just realized that i wasnt reading the value, was mearly displying the context.id

Msgbox should have been

msgbox(0, "IP", GUICtrlRead($I_IP))

sorry for wasting your time ;)

Link to comment
Share on other sites

sorry Admiral, your post wasnt there when i started to type my reetraction due to my brain freeze.

no the user needs to enter in an IP (if changed from default) the script then controls a web interface to a ip relay device to switch lights on and off.

but maybe you can give me some idea of an alternative.

currently i am controlling it via ie as per

$oIE = ObjCreate("Shell.Explorer.2")

     ;Turn 4 on, and 3 off
     $oIE.navigate("http://" & GUICtrlRead($I_IP) & "/SetIO?p64=1+p63=0")
     $xCounter = 0
     Do
      $xCounter = $xCounter + 1
      if $xCounter = 11 then
       $oIE.navigate("http://" & GUICtrlRead($I_IP) & "/SetIO?p64=0+p63=0")
       MsgBox(0,"Error","Red xCounter=" & $xCounter & @CR & "http://" & GUICtrlRead($I_IP) & "/SetIO?p64=1+p63=0")
       Exit
      EndIf
      $body = _IETagNameGetCollection($oIE, "body", 0)
      $Check = StringInStr($body.innerText, "64=1")
      if $Check > 0 Then
       $Check = StringInStr($body.innerText, "63=0")
      EndIf
      Sleep(200)
     Until $Check > 0

as you can see this passes a username and password to the page (dont care about security).

Then it looks at the page for the reponse.

IE by default now days does not allow passing of user

I would like to do this without relying on IE. Any idea's?

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