Hylia Posted October 9, 2015 Share Posted October 9, 2015 (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?expandcollapse popup#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 October 9, 2015 by Hylia Link to comment Share on other sites More sharing options...
Valuater Posted October 9, 2015 Share Posted October 9, 2015 try.. expandcollapse popup#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 EndFunc8) Hylia 1 Link to comment Share on other sites More sharing options...
Hylia Posted October 9, 2015 Author Share Posted October 9, 2015 try.. _GUICtrlIpAddress_Get($cl_IP)8)Thanks that did the trick, I assume GUICtrlReadData doesn't work properly for an IP Input box then? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 10, 2015 Moderators Share Posted October 10, 2015 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now