Jump to content

Need Help with GUI Input


Recommended Posts

So here's my client code:

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.0.0
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=C:\Documents and Settings\HP_Administrator\Desktop\koda_1.7.2.0\Forms\Client.kxf
$Client = GUICreate("Client [Server Control Center]", 307, 363, -1, -1)
$MenuItem1 = GUICtrlCreateMenu("File")
$MenuItem2 = GUICtrlCreateMenuItem("Exit", $MenuItem1)
$MenuItem3 = GUICtrlCreateMenu("Report Bug")
GUISetBkColor(0xA6CAF0)
$Input1 = GUICtrlCreateInput("Server Command Here", 17, 24, 199, 21, -1, BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
$Group1 = GUICtrlCreateGroup("Command to Send to Server", 8, 8, 289, 49)
$Button1 = GUICtrlCreateButton("Send", 216, 24, 67, 22, $WS_GROUP, $WS_EX_STATICEDGE)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Server Command List", 8, 64, 289, 273)
$Label1 = GUICtrlCreateLabel("All Commands must be preceeded by a / otherwise ", 24, 80, 256, 17)
$Label2 = GUICtrlCreateLabel("whatever you send will be received as a message to ", 24, 96, 261, 17)
$Label3 = GUICtrlCreateLabel("whom ever is using the current machine. The Server", 24, 112, 250, 17)
$Label4 = GUICtrlCreateLabel("will then generate a message box with your sent text", 24, 128, 249, 17)
$Label5 = GUICtrlCreateLabel("on the current user's desktop.", 24, 144, 144, 17)
$Group3 = GUICtrlCreateGroup("Command List", 16, 160, 97, 169, $BS_CENTER)
$Label7 = GUICtrlCreateLabel("1. - cd open", 24, 176, 61, 17)
$Label6 = GUICtrlCreateLabel("2. - cd close", 24, 192, 62, 17)
$Label8 = GUICtrlCreateLabel("3. - beep", 24, 208, 46, 17)
$Label9 = GUICtrlCreateLabel("4. - mousetrap", 24, 224, 71, 17)
$Label10 = GUICtrlCreateLabel("5. - selfd", 24, 240, 44, 17)
$Label11 = GUICtrlCreateLabel("6. - shutdown", 24, 256, 68, 17)
$Label12 = GUICtrlCreateLabel("7. - restart", 24, 272, 51, 17)
$Label13 = GUICtrlCreateLabel("8. - logoff", 24, 288, 48, 17)
$Label14 = GUICtrlCreateLabel("9. - iprelease", 24, 304, 64, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("Command Description's", 120, 160, 169, 169, $BS_CENTER)
$Label16 = GUICtrlCreateLabel("Open's CD Tray", 128, 176, 79, 17)
$Label17 = GUICtrlCreateLabel("Close's CD Tray", 128, 192, 79, 17)
$Label18 = GUICtrlCreateLabel("Play's a Beep", 128, 208, 68, 17)
$Label19 = GUICtrlCreateLabel("Possess' Cursor", 128, 224, 78, 17)
$Label20 = GUICtrlCreateLabel("Self Destruct's Server", 128, 240, 106, 17)
$Label21 = GUICtrlCreateLabel("Shutdown Remote Machine", 128, 256, 136, 17)
$Label22 = GUICtrlCreateLabel("Restart's Remote Machine", 128, 272, 129, 17)
$Label23 = GUICtrlCreateLabel("Logoff Remote User", 128, 288, 99, 17)
$Label24 = GUICtrlCreateLabel("Release Remote Machines Ip", 128, 304, 144, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd



HotKeySet("^s","SendMsg");Press CTRL+S to send a message to server.
HotKeySet("^q","Quit");Press CTRL+Q to quit

Global $SERVER_IP = "127.0.0.1"
Global $SERVER_PORT = "65432"
Global $SOCKET

; Start The TCP Services
TCPStartUp()

; Connect to The Server
$socket = TCPConnect( $SERVER_IP, $SERVER_PORT )
If $socket = -1 Then Exit
    
If @error Then
    MsgBox(0, "Client", "Unable to Contact Server!")
    Exit
Else
    MsgBox(0, "Client","Successfully Connected to the Server!",1)
EndIf

While True
    $RECV = TCPRecv($SOCKET,256)
    If $RECV <> "" Then 
        MsgBox(0, "Client", $RECV,1)
    Sleep(20)
EndIF
WEnd

Func SendMsg()
    $MESSAGE = $INPUT1
    TCPSend($SOCKET,$MESSAGE)
EndFunc

Func Quit()
    TCPCloseSocket($SOCKET)
    TCPShutdown()
    Exit
EndFunc

I need help linking the Input Box from the GUI to the SendMsg()

Code includes both methods. CTRL+S = Works but, I cannot tie the

$Input1 = GUICtrlCreateInput("Server Command Here", 17, 24, 199, 21, -1, BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
$Button1 = GUICtrlCreateButton("Send", 216, 24, 67, 22, $WS_GROUP, $WS_EX_STATICEDGE)

to

Func SendMsg()
    $MESSAGE = $INPUT1
    TCPSend($SOCKET,$MESSAGE)
EndFunc
Link to comment
Share on other sites

try this seeing how you have GUIGETMSG in there

Case $nMsg = $Button1
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...