Hylia

Issue with _GUICtrlIpAddress

4 posts in this topic

#1 ·  Posted (edited)

I wanted to make a GUI form for inputting an IP and Port to then connect to the server that has that IP, however, when I use GUICtrlRead on $cl_IP (which is an IP input box), I get 0 eventhough it should give me 127.0.0.1, what am I doing wrongly here?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <GuiIPAddress.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>

Global $IP
Global $Port

; Connect to IP
$MainForm = GUICreate("Server Starter", 158, 113, 192, 124);
$cl_IP = _GUICtrlIpAddress_Create($MainForm, 16, 16, 130, 21);
_GUICtrlIpAddress_Set($cl_IP, "127.0.0.1")
$cl_Port = GUICtrlCreateInput("1018", 56, 44, 49, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER));
$bStartServer = GUICtrlCreateButton("Connect", 40, 72, 75, 25);
GUISetState(@SW_SHOW);

msgbox(0, "", GUICtrlRead($cl_IP))

While 1

    $nMsg = GUIGetMsg()
    Switch $nMsg
         Case $GUI_EVENT_CLOSE
            Exit;
         Case $bStartServer
            $IP = GUICtrlRead($cl_IP);
            $Port = CheckPort($cl_Port);
            GUIDelete($MainForm);
            ExitLoop;
    EndSwitch
 WEnd

Func CheckPort($PortGui)
   if (GUICtrlRead($PortGui) >= 0 and GUICtrlRead($PortGui) <= 65535) then
      return GUICtrlRead($PortGui);
   Else
      msgbox(0, "Port is not correct", "Please, pick a different Port");
      return -1;
   EndIf
EndFunc

 

Edited by Hylia

Share this post


Link to post
Share on other sites



try..

 

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <GuiIPAddress.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>

Global $IP
Global $Port

; Connect to IP
$MainForm = GUICreate("Server Starter", 158, 113, 192, 124);
$cl_IP = _GUICtrlIpAddress_Create($MainForm, 16, 16, 130, 21);
_GUICtrlIpAddress_Set($cl_IP, "127.0.0.1")
$cl_Port = GUICtrlCreateInput("1018", 56, 44, 49, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER));
$bStartServer = GUICtrlCreateButton("Connect", 40, 72, 75, 25);
GUISetState(@SW_SHOW);

 MsgBox( 0, "Information", "IP Address: " & _GUICtrlIpAddress_Get($cl_IP))


While 1

    $nMsg = GUIGetMsg()
    Switch $nMsg
         Case $GUI_EVENT_CLOSE
            Exit;
         Case $bStartServer
            $IP = GUICtrlRead($cl_IP);
            $Port = CheckPort($cl_Port);
            GUIDelete($MainForm);
            ExitLoop;
    EndSwitch
 WEnd

Func CheckPort($PortGui)
   if (GUICtrlRead($PortGui) >= 0 and GUICtrlRead($PortGui) <= 65535) then
      return GUICtrlRead($PortGui);
   Else
      msgbox(0, "Port is not correct", "Please, pick a different Port");
      return -1;
   EndIf
EndFunc

8)

1 person likes this

NEWHeader1.png

Share this post


Link to post
Share on other sites

try..

 

_GUICtrlIpAddress_Get($cl_IP)

8)

Thanks that did the trick, I assume GUICtrlReadData doesn't work properly for an IP Input box then?

Share this post


Link to post
Share on other sites

Hylia,

 I assume GUICtrlReadData doesn't work properly for an IP Input box then?

Correct. In general, GUICtrl* functions only work on controls created by the native GUICtrlCreate* functions which return a ControlID - these controls are tracked internally by AutoIt. To interact with controls created by the UDF functions (those preceded by an underscore), you usually need to use other UDF functions - as is the case here.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

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