Jump to content
Sign in to follow this  
Klovis

Buttons and loops

Recommended Posts

Klovis

So I want to click this button once and after I click it the first time it will receive new properties, the first time It connects to the IP you put in input1 then the second time you press it, it will send what is in input1. But I failed and I'm lost.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $IP, $TCPConnect, $i = 0

TCPStartup()

$Form1 = GUICreate("Client", 108, 23, 373, 441, -1, $WS_EX_TOPMOST)
$Input1 = GUICtrlCreateInput("0.0.0.0", 0, 0, 66, 21)
$Button1 = GUICtrlCreateButton("Connect", 72, 0, 35, 21)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            If $i = 0 Then
                $IP = GUICtrlRead($Input1)
                $TCPConnect = TCPConnect($IP, 5000)
                GUICtrlSetData($Button1, "Send")
            EndIf
            $i = 1
            If $i = 1 Then
                TCPSend($TCPConnect, GUICtrlRead($Input1))
                GUICtrlSetData($Input1, "")
            EndIf
    EndSwitch
WEnd

clientinput.au3

Share this post


Link to post
Share on other sites
Klovis

Try this :)

Case $Button1
    If $i = 0 Then
        $IP = GUICtrlRead($Input1)
        $TCPConnect = TCPConnect($IP, 5000)
        GUICtrlSetData($Button1, "Send")
        $i = 1
    Else
        TCPSend($TCPConnect, GUICtrlRead($Input1))
        GUICtrlSetData($Input1, "")
    EndIf

It's always the else I forget. Thanks Cartmen ^^

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.