Jump to content
Sign in to follow this  

Tiny LAN Chat

Recommended Posts

I know this has been done before but I am trying to make a  small standalone chat client. 

I have done this much but I still can't get it to work. Please help! Thanks in advance.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
#include <GuiEdit.au3>

Global $socket = "", $nickname = @UserName, $Addr = "", $cConnection = ""

#Region ### START Koda GUI section ### Form=E:\Users\Libre\Google Drive\AU3\Tiny LAN Chat\TLC.kxf
$Form1 = GUICreate("TLC [Tiny LAN Chat] ~ 3N!GM@", 390, 442, 192, 154)
$MenuItem1 = GUICtrlCreateMenu("&File")
$MenuItem10 = GUICtrlCreateMenu("&What's My IP", $MenuItem1)
$MenuItem11 = GUICtrlCreateMenuItem(@IPAddress1, $MenuItem10)
;~ $MenuItem4 = GUICtrlCreateMenuItem("&New Connection", $MenuItem1)
$MenuItem6 = GUICtrlCreateMenuItem("&Save Chat To File", $MenuItem1)
$MenuItem12 = GUICtrlCreateMenuItem("&Minimize 2 Tray", $MenuItem1)
$MenuItem5 = GUICtrlCreateMenuItem("E&xit", $MenuItem1)
$MenuItem2 = GUICtrlCreateMenu("&Edit")
$MenuItem7 = GUICtrlCreateMenuItem("&Change Nickname", $MenuItem2)
$MenuItem3 = GUICtrlCreateMenu("&Help")
$MenuItem8 = GUICtrlCreateMenuItem("&About", $MenuItem3)
$MenuItem9 = GUICtrlCreateMenuItem("He&lp", $MenuItem3)
$Edit1 = GUICtrlCreateEdit("", 8, 296, 369, 89, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL))
$Button1 = GUICtrlCreateButton("Send", 304, 392, 75, 25, $BS_DEFPUSHBUTTON)
$Edit2 = GUICtrlCreateEdit("", 8, 8, 369, 281, BitOR($ES_AUTOVSCROLL, $ES_READONLY, $ES_WANTRETURN, $WS_VSCROLL))
GUICtrlSetBkColor(-1, 0xffffff)
$Button2 = GUICtrlCreateButton("Connect", 144, 392, 75, 25)
$IPAddress1 = _GUICtrlIpAddress_Create($Form1, 8, 392, 130, 21)
_GUICtrlIpAddress_Set($IPAddress1, @IPAddress1)
#EndRegion ### END Koda GUI section ###

$socket = TCPListen(@IPAddress1, 13374)
While 1
    $nMsg = GUIGetMsg()
    $connection = TCPAccept($socket)
    If $connection = -1 Then Sleep(10)
    $Recv = TCPRecv($connection, 10000)
    If $Recv <> @error And $Recv <> "" Then
        _GUICtrlEdit_AppendText($Edit2, $Recv & @CRLF & @CRLF)
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
        Case $Button1
            $txt = "[" & $nickname & " " & _Now() & "]" & @CRLF & GUICtrlRead($Edit1)
            $sentMsg = TCPSend($connection, $txt)
            If $sentMsg <> @error Then
                _GUICtrlEdit_AppendText($Edit2, $txt & @CRLF & @CRLF)
            ElseIf @error Then
                _GUICtrlEdit_AppendText($Edit2, "Error MSG Not Sent!!!")
            $txt = ""
        Case $Button2
            $Addr = _GUICtrlIpAddress_Get($IPAddress1)
            $cConnection = TCPConnect($Addr, 13374)
            If $cConnection < 0 Then
                MsgBox(16, "Error", "Connection could not be established.")
                _GUICtrlEdit_AppendText($Edit2, "Connection established!" & @CRLF & @CRLF)

Share this post

Link to post
Share on other sites

Generally have to allow the compiled script firewall access for that kind of thing...if the script functions.

Edit: if it is a local lan, you can get around firewalls by mapping drives, and doing file read|writes rather than tcp.  Make a dir for each station, and drop in files with the text.  Your app would then loop for files found in it's dir, and add the text to the app.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post

Link to post
Share on other sites

The problem I am having is that it is not receiving. If I coded this right when I connect to myself and send a message, the message would show up twice.

Also I have already add an exception to the firewall on both of my computers. I thought about writing to and reading from a network drive ,but I want this to run on guest accounts as well as all other accounts.

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  

  • Create New...