Jump to content

Need help: How to set the variable to use the USER input.


Go to solution Solved by Zedna,

Recommended Posts

I have provided a portion of my script (seen below) and I wanted to use what the USER will input into my IP address box and input box for TCP port. I set the IP address to use 0.0.0.0 as default and the Port to 502. But I want to let the user change it and when they click the buttons (IP Address and Port), the tooltip will show what the USER entered. How can I use the details that the User will input into my input box and IP address box and let them see what they entered when they click the buttons?

 

Here are the scripts:

;-------------------------------------------------------------

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
#include <MsgBoxConstants.au3>
#include <Date.au3>
#include <TabConstants.au3>
#include <GuiTab.au3>


Global $Form1 = GUICreate("Security Automation", 490, 339, -1, -1)

;MAIN Tab
Global $TAB = GUICtrlCreateTab(0, 0, 489, 337)
Global $tab_main = GUICtrlCreateTabItem("Main")
$label_Title = GUICtrlCreateLabel("ETP-073 Security", 12, 33, 103, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

;-----------------TCP User input information-------------------------------------------------------------------------------
$groupBox_TCP = GUICtrlCreateGroup("TCP", 12, 49, 289, 57, BitOR($GUI_SS_DEFAULT_GROUP,$BS_FLAT))
;TCP IP address
Global $IPAddress1 = _GUICtrlIpAddress_Create($Form1, 20, 81, 170, 21)
$Label_ipAddress = GUICtrlCreateLabel("Host IP Address", 20, 65, 80, 17)
$userInputIP = _GUICtrlIpAddress_Set($IPAddress1, "0.0.0.0")

;TCP Port
$label_tcpPort = GUICtrlCreateLabel("Port", 196, 65, 23, 17)
Global $input_tcpPort = GUICtrlCreateInput("502", 196, 81, 57, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
$userPort = GUICtrlRead($input_tcpPort)

;TCP Address
$label_tcpAddress = GUICtrlCreateLabel("Addr.", 260, 65, 29, 17)
Global $input_tcpDevAddress = GUICtrlCreateInput("1", 260, 81, 33, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))

;Buttons
Global $btn_userIP = GUICtrlCreateButton("User IP", 308, 297, 81, 25)
Global $btn_Port = GUICtrlCreateButton("Port", 404, 297, 75, 25)

;Showing the GUI
GUISetState(@SW_SHOW)

While 1
   $nMsg = GUIGetMsg()

   Switch $nMsg
      Case $GUI_EVENT_CLOSE
         Exit

      Case $btn_userIP
         ToolTip($userInputIP)
      Case $btn_Port
         ToolTip($userPort)
   EndSwitch
WEnd

;--------------end of script ------------------

 

Note: There will be a "!->Includefile <WMDebug.au3> not found." Pay no attention to it.

Link to comment
Share on other sites

  • Solution
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
#include <MsgBoxConstants.au3>
#include <Date.au3>
#include <TabConstants.au3>
#include <GuiTab.au3>


Global $Form1 = GUICreate("Security Automation", 490, 339, -1, -1)

;MAIN Tab
Global $TAB = GUICtrlCreateTab(0, 0, 489, 337)
Global $tab_main = GUICtrlCreateTabItem("Main")
$label_Title = GUICtrlCreateLabel("ETP-073 Security", 12, 33, 103, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

;-----------------TCP User input information-------------------------------------------------------------------------------
$groupBox_TCP = GUICtrlCreateGroup("TCP", 12, 49, 289, 57, BitOR($GUI_SS_DEFAULT_GROUP,$BS_FLAT))
;TCP IP address
Global $IPAddress1 = _GUICtrlIpAddress_Create($Form1, 20, 81, 170, 21)
$Label_ipAddress = GUICtrlCreateLabel("Host IP Address", 20, 65, 80, 17)
$userInputIP = _GUICtrlIpAddress_Set($IPAddress1, "0.0.0.0")

;TCP Port
$label_tcpPort = GUICtrlCreateLabel("Port", 196, 65, 23, 17)
Global $input_tcpPort = GUICtrlCreateInput("502", 196, 81, 57, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))

;TCP Address
$label_tcpAddress = GUICtrlCreateLabel("Addr.", 260, 65, 29, 17)
Global $input_tcpDevAddress = GUICtrlCreateInput("1", 260, 81, 33, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))

;Buttons
Global $btn_userIP = GUICtrlCreateButton("User IP", 308, 297, 81, 25)
Global $btn_Port = GUICtrlCreateButton("Port", 404, 297, 75, 25)

;Showing the GUI
GUISetState(@SW_SHOW)

While 1
   $nMsg = GUIGetMsg()

   Switch $nMsg
      Case $GUI_EVENT_CLOSE
         Exit

      Case $btn_userIP
        $userIP = _GUICtrlIpAddress_Get($IPAddress1)
         ToolTip($userIP)

      Case $btn_Port
        $userPort = GUICtrlRead($input_tcpPort)
        ToolTip($userPort)
   EndSwitch
WEnd

 

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

×
×
  • Create New...