Hello IM new to AutoIT
I have been Scripting In batch code For a long time
What I want to do:
I have been trying to make a simple script to communicate over a network
Here it is:
AutoIt
#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.8.1 Author: DarkPhoeniX Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiIPAddress.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Global $Form1 = GUICreate("Saddle Server", 333, 450, 192, 124) Global $IPAddress1Input = _GUICtrlIpAddress_Create($Form1, 40, 24, 130, 21) _GUICtrlIpAddress_Set($IPAddress1Input, "0.0.0.0") Global $Label1 = GUICtrlCreateLabel("IP :", 16, 24, 22, 20) GUICtrlSetFont($Label1, 10, 400, 0, "MS Sans Serif") Global $PortInput1 = GUICtrlCreateInput("0", 232, 24, 65, 21) Global $Label2 = GUICtrlCreateLabel("Port :", 198, 24, 34, 20) GUICtrlSetFont($Label2, 10, 400, 0, "MS Sans Serif") Global $TestButton = GUICtrlCreateButton("Test Connection", 208, 56, 99, 25) Global $ClientInfoButton = GUICtrlCreateButton("Client Info", 207, 87, 99, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $TestButton IPsetup() Case $ClientInfoButton EndSwitch WEnd Func IPsetup() Global $szIPADDRESS = _GUICtrlIpAddress_Get($IPAddress1Input) if $szIPADDRESS == "0.0.0.0" Then MsgBox(4112, "Error", "Please Enter IP Address") EndIf Global $nPORT = $PortInput1 if $nPORT == "0" Then MsgBox(4112, "Error", "Please Enter Port Number" & $nPORT & $PortInput1 ) EndIf EndFunc Func Speak() TCPStartup() Local $ConnectedSocket, $szData $ConnectedSocket = -1 $ConnectedSocket = TCPConnect($szIPADDRESS, $nPORT) If @error Then MsgBox(4112, "Error", "Connection to Flank Failed: " & @error) exit Else ;Loop forever asking for data to send to the SERVER While 1 ; InputBox for data to transmit $szData = InputBox("Data for Server", @LF & @LF & "Enter data to transmit to the SERVER:") ; If they cancel the InputBox or leave it blank we exit our forever loop If @error Or $szData = "" Then ExitLoop ; We should have data in $szData... lets attempt to send it through our connected socket. ; convert AutoIt native UTF-16 to UTF-8 TCPSend($ConnectedSocket, StringToBinary($szData, 4)) ; If the send failed with @error then the socket has disconnected ;---------------------------------------------------------------- If @error Then ExitLoop WEnd EndIf EndFunc
Please note IPsetup()
at Global $nPORT = $PortInput1
The variable $PortInput1 keeps reverting to 4
I have perversely typed 4 in for a test into the input-box
The error seems to be in :
Global $PortInput1 = GUICtrlCreateInput("0", 232, 24, 65, 21)
but when I change $PortInput1 to $PortInput
I get the same problem
I ran this code on my other PC and it works fine
But after a autoit reinstalling and PC restart the $PortInput1 keeps reverting back to my previous input (4)
What is Wrong!?