Jump to content

Chatta


Recommended Posts

Here is a quick n' dirty IM client called Chatta I whipped up (yes, the name is queer). Unlike others, it uses files instead of an internet connection. It's intended for people on a network or who have an open space on the internet can.

Update 10-30-07!

Thanks to MildWarlock for making messages multiline and widening the box.

Code:

$uname = IniRead(@ScriptDir & "\ChattaData.chdt", "User", "Name", "Unknown")
$chmw = IniRead(@ScriptDir & "\ChattaData.chdt", "Sounds", "Sound", 3)
$fsize = IniRead(@ScriptDir & "\ChattaData.chdt", "Font", "FColor", "00x999999")
$fname = IniRead(@ScriptDir & "\ChattaData.chdt", "Font", "FName", "Tahoma")
;FileInstall("E:\NewChatMessage1.wav", @ScriptDir & "\NewChatMessage1.wav")
;FileInstall("E:\NewChatMessage2.wav", @ScriptDir & "\NewChatMessage2.wav")
;FileInstall("E:\NewChatMessage3.wav", @ScriptDir & "\NewChatMessage3.wav")
AutoItSetOption("TrayAutoPause", 0)
#include <GUIConstants.au3>
#Include <GuiEdit.au3>
#include <Misc.au3>
#include <Array.au3>
$show = TrayCreateItem("Show Chatta")
$exit = TrayCreateItem("Exit Chatta")
$Form3 = GUICreate("Chatta", 169, 173, 281, 168)
$newchat = GUICtrlCreateButton("New", 8.5, 8.5, 153, 41, 0)
$joinbutton = GUICtrlCreateButton("Join", 8.5, 56, 153, 49, 0)
$opt = GUICtrlCreateButton("Options..", 8.5, 144, 153, 25, 0)
$hidewindows = TrayCreateItem("Hide All Windows")
$winshiding = 0
GUISetState(@SW_SHOW)

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

        Case $newchat
            GUISetState(@SW_HIDE)
      ;begin New Chat
        $d = FileSaveDialog("New Chat", "C:\", "Chatta Chats (*.chat)")
        If FileExists($d & ".chat") Then
            MsgBox(0, "Sorry", "You can't replace an existing chat.")
            Run(@ScriptDir & "\Chatta.exe")
            Exit
        EndIf
        If MsgBox(4, "Open Chat?", "Would you like to open this chat to the public?") = 7 Then
            IniWrite($d & ".chat", "Chat", "Open", 0)
            $allowed = InputBox("Chatta Allowed Chatters", "Enter the name of the chatter that you want to be allowed.")
            IniWrite($d & ".chat", "Chat", "Allowed user 1", $allowed)
            $allowed = InputBox("Chatta Allowed Chatters", "Enter the name of the second chatter that you want to be allowed.")
            IniWrite($d & ".chat", "Chat", "Allowed user 2", $allowed)
            $allowed = InputBox("Chatta Allowed Chatters", "Enter the name of the third chatter that you want to be allowed.")
            IniWrite($d & ".chat", "Chat", "Allowed user 3", $allowed)
            $allowed = InputBox("Chatta Allowed Chatters", "Enter the name of the third chatter that you want to be allowed.")
        Else
            IniWrite($d & ".chat", "Chat", "Open", 1)
        EndIf
    IniWrite($d & ".chat", "Users", "User 1", $uname)
$u1 = IniRead($d & ".chat", "Users", "User 1", "")
$u2 = IniRead($d & ".chat", "Users", "User 2", "")
$u3 = IniRead($d & ".chat", "Users", "User 3", "")
$Form2 = GUICreate($d & ".chat Chatta Chat", 518.5, 300, 357, 270, BitOR($ES_READONLY, $ES_MULTILINE))
$TextPut = GUICtrlCreateInput("", 8.5, 220, 241, 21)
GUISetState(@SW_SHOW)
Global $lr = ""
Global $lastsentuser = ""
$lrbefore = $lr
$gr = 0
$log = 0
$LastSent1 = ""
$lr1 = ""
$lr2 = ""
$lr3 = ""
$lr4 = ""
$lr5 = ""
$lru1 = ""
$lru2 = ""
$lru3 = ""
$lru4 = ""
$lru5 = ""
$lrc1 = ""
$lrc2 = ""
$lrc3 = ""
$lrc4 = ""
$lrc5 = ""
$z = ""
Global $fc5
Global $fc4
Global $fc4
Global $fc3
Global $fc3
Global $fc2
Global $fc2
Global $fc1
Global $fc1
Global $lrfs
Global $fn5
Global $fn4
Global $fn4
Global $fn3
Global $fn3
Global $fn2
Global $fn2
Global $fn1
Global $fn1
global $lrfn
$time = @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC
While 1
    $lr = IniRead($d & ".chat", "Chat", "Last Sent-", "")
        If $lrbefore <> $lr Then
            If IniRead(@ScriptDir & "ChattaData.chdt", "Log?", "Log...", 0) = 1 Then
                IniWrite(@ScriptDir & "ChattaData.chdt", "Log?", "Log" & $gr + 1, $lr)
                $gr = $gr + 1
            EndIf
            $lastsentuser = IniRead($d & ".chat", "Chat", "Last Sent User", "")
            $lrfn = IniRead($d & ".chat", "Chat", "Last Sent Font Name", "Tahoma")
            $lrfc = IniRead($d & ".chat", "Chat", "Last Sent Font Color", 000000)
            $lr5 = $lr4
            $lr4 = $lr3
            $lr3 = $lr2
            $lr2 = $lr1
            $lr1 = $lr
            $lru5 = $lru4
            $lru4 = $lru3
            $lru3 = $lru2
            $lru2 = $lru1
            $lru1 = $lastsentuser
            $fc5 = $fc4
            $fc4 = $fc3
            $fc3 = $fc2
            $fc2 = $fc1
            $fc1 = $lrfc
            $fn5 = $fn4
            $fn4 = $fn3
            $fn3 = $fn2
            $fn2 = $fn1
            $fn1 = $lrfn
            GUICtrlDelete($lrc1)
            $lrc1 = GUICtrlCreateLabel($lru1 & " says: " & $lr1, 8.5, 146, 500, 30)
            GUICtrlSetFont($lrc1, 8.5, -1, -1, $fn1)
            GUICtrlSetColor($lrc1, $lrfc)
            GUICtrlDelete($lrc2)
            $lrc2 = GUICtrlCreateLabel($lru2 & " says: " & $lr2, 8.5, 116, 500, 30)
            GUICtrlSetFont($lrc2, 8.5, -1, -1, $fn2)
            GUICtrlSetColor($lrc2, $fc2)
            GUICtrlDelete($lrc3)
            $lrc3 = GUICtrlCreateLabel($lru3 & " says: " & $lr3, 8.5, 86, 500, 30)
            GUICtrlSetFont($lrc3, 8.5, -1, -1, $fn3)
            GUICtrlSetColor($lrc3, $fc3)
            GUICtrlDelete($lrc4)
            $lrc4 = GUICtrlCreateLabel($lru4 & " says: " & $lr4, 8.5, 56, 500, 30)
            GUICtrlSetFont($lrc4, 8.5, -1, -1, $fn4)
            GUICtrlSetColor($lrc4, $fc4)
            GUICtrlDelete($lrc5)
            $lrc5 = GUICtrlCreateLabel($lru5 & " says: " & $lr5, 8.5, 26, 500, 30)
            GUICtrlSetFont($lrc5, 8.5, -1, -1, $fn5)
            GUICtrlSetColor($lrc5, $fc5)
            If WinActive($d & ".chat Chatta Chat") = 0 Then
                $text = WinGetText($d & ".chat Chatta Chat")
                WinSetTitle($d & ".chat Chatta Chat", $text, "You recieved a message.")
                SoundPlay(@ScriptDir & "\NewChatMessage" & $chmw & ".wav")
            EndIf
            If $lastsentuser <> $uname Then
                TrayTip("Chatta", "New Message from " & $lastsentuser, 3)
            EndIf
        EndIf
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            If MsgBox(4, "Delete?", "Would you like to delete this chat? If you have Log Chats on, it will still be there in the chat log.") = 6 Then
                FileDelete($d & ".chat")
                GUIDelete($Form2)
                GUISwitch($Form3)
                ExitLoop
            Else
                GUIDelete($Form2)
                GUISwitch($Form3)
                ExitLoop
            EndIf

        Case $TextPut
            $LastSent1 = GUICtrlRead($TextPut)
            IniWrite($d & ".chat", "Chat", "Last Sent-", $LastSent1)
            IniWrite($d & ".chat", "Chat", "Last Sent User", $uname)
            GUICtrlDelete($TextPut)
            $TextPut = GUICtrlCreateInput("", 8.5, 220, 241, 21)
            ControlFocus($d & ".chat Chatta Chat", "", $TextPut)
            IniWrite($d & ".chat", "Chat", "Last Sent Font Name", $fname)
            IniWrite($d & ".chat", "Chat", "Last Sent Font Color", $fsize)
    EndSwitch
    $tmsg = TrayGetMsg()
    Switch $tmsg
        Case $hidewindows
            If $winshiding = 1 Then
                $winshiding = 0
                TrayItemSetText($hidewindows, "Hide Windows")
                GUISetState(@SW_SHOW, $Form3)
                GUISetState(@SW_SHOW, $Form2)
            Else
                $winshiding = 1
                TrayItemSetText($hidewindows, "Show Windows")
                GUISetState(@SW_HIDE, $Form3)
                GUISetState(@SW_HIDE, $Form2)
            EndIf
    EndSwitch
        $log = IniRead($d & ".chat", "Chat", "Last Sent-", $LastSent1)
        IniWrite(@ScriptDir & "ChattaData.chdt", "Log?", "Log" & $gr + 1, $gr)
        $lrbefore = $lr
        
WEnd
;end New Chat
            
        
    Case $joinbutton
        GUISetState(@SW_HIDE)
;begin Join Chat
$d = FileOpenDialog("Open Chat", "C:\", "Chatta Chats (*.chat)")
If @error = 1 Then
    MsgBox(0, "Sorry", "ERROR!!! ARGH!!!")
Else
If IniRead($d & ".chat", "Chat", "Open", 1) = 0 Then
    If IniRead($d & ".chat", "Chat", "Allowed user 1", "") <> $uname Then
        If IniRead($d & ".chat", "Chat", "Allowed user 2", "") <> $uname Then
            If IniRead($d & ".chat", "Chat", "Allowed user 3", "") <> $uname Then
                MsgBox(0, "Sorry", "This chat is private, and you are not on the allowed-user list.")
                Run(@ScriptDir & "\Chatta.exe")
                Exit
            EndIf
        EndIf
    EndIf
EndIf
If IniRead($d , "Users", "User 1", "") <> "" then
    If IniRead($d , "Users", "User 2", "") <> "" then
        If IniRead($d , "Users", "User 3", "") <> "" Then
            If IniRead($d , "Users", "User 4", "") <> "" Then
                If IniRead($d , "Users", "User 5", "") <> "" Then
                    MsgBox(0, "Sorry!", "This chat is full.")
                    Run(@ScriptDir & "\Chatta.exe")
                    Exit
                Else
                    IniWrite($d , "Users", "User 5", "")
                EndIf
            Else
            IniWrite($d , "Users", "User 4", "")
            EndIf
        Else
            IniWrite($d , "Users", "User 3", $uname)
        EndIf
    Else
        IniWrite($d , "Users", "User 2", $uname)
    EndIf
Else
    IniWrite($d , "Users", "User 1", $uname)
EndIf
$u1 = IniRead($d , "Users", "User 1", "")
$u2 = IniRead($d , "Users", "User 2", "")
$u3 = IniRead($d , "Users", "User 3", "")
$Form1  = GUICreate($d & ".chat Chatta Chat", 500.5, 300, 357, 270, BitOR($ES_READONLY, $ES_MULTILINE))
$TextPut = GUICtrlCreateInput("", 8.5, 220, 241, 21)
GUISetState(@SW_SHOW)
Global $lr = ""
Global $lastsentuser = ""
$lrbefore = $lr
$gr = 0
$log = 0
$LastSent1 = 0
$time = @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC
$LastSent1 = ""
$lr1 = ""
$lr2 = ""
$lr3 = ""
$lr4 = ""
$lr5 = ""
$lru1 = ""
$lru2 = ""
$lru3 = ""
$lru4 = ""
$lru5 = ""
$lrc1 = ""
$lrc2 = ""
$lrc3 = ""
$lrc4 = ""
$lrc5 = ""
$z = ""
Global $fc5
Global $fc4
Global $fc4
Global $fc3
Global $fc3
Global $fc2
Global $fc2
Global $fc1
Global $fc1
Global $lrfs
Global $fn5
Global $fn4
Global $fn4
Global $fn3
Global $fn3
Global $fn2
Global $fn2
Global $fn1
Global $fn1
global $lrfn
While 1
    If WinActive("You recieved a message.") = 1 Then
        $text = WinGetText("You recieved a message.")
        WinSetTitle("You recieved a message.", $text, $d & " Chatta Chat")
    EndIf
    $lr = IniRead($d , "Chat", "Last Sent-", "")
    If @MIN & @SEC > $time Then
        $time = @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC
        If FileExists($d) = 0 then
            MsgBox(0, "Sorry", "The person who created this chat has deleted it.")
            Run(@ScriptFullPath)
            Exit
        EndIf
    EndIf
    If $lrbefore <> $lr Then
            If IniRead(@ScriptDir & "ChattaData.chdt", "Log?", "Log...", 0) = 1 Then
                IniWrite(@ScriptDir & "ChattaData.chdt", "Log?", "Log" & $gr + 1, $lr)
                $gr = $gr + 1
            EndIf
            $lastsentuser = IniRead($d, "Chat", "Last Sent User", "")
            $lrfn = IniRead($d, "Chat", "Last Sent Font Name", "Tahoma")
            $lrfc = IniRead($d, "Chat", "Last Sent Font Color", 000000)
            $lr5 = $lr4
            $lr4 = $lr3
            $lr3 = $lr2
            $lr2 = $lr1
            $lr1 = $lr
            $lru5 = $lru4
            $lru4 = $lru3
            $lru3 = $lru2
            $lru2 = $lru1
            $lru1 = $lastsentuser
            $fc5 = $fc4
            $fc4 = $fc3
            $fc3 = $fc2
            $fc2 = $fc1
            $fc1 = $lrfc
            $fn5 = $fn4
            $fn4 = $fn3
            $fn3 = $fn2
            $fn2 = $fn1
            $fn1 = $lrfn
            GUICtrlDelete($lrc1)
            $lrc1 = GUICtrlCreateLabel($lru1 & " says: " & $lr1, 8.5, 146, 500, 30)
            GUICtrlSetFont($lrc1, 8.5, -1, -1, $fn1)
            GUICtrlSetColor($lrc1, $lrfc)
            GUICtrlDelete($lrc2)
            $lrc2 = GUICtrlCreateLabel($lru2 & " says: " & $lr2, 8.5, 116, 500, 30)
            GUICtrlSetFont($lrc2, 8.5, -1, -1, $fn2)
            GUICtrlSetColor($lrc2, $fc2)
            GUICtrlDelete($lrc3)
            $lrc3 = GUICtrlCreateLabel($lru3 & " says: " & $lr3, 8.5, 86, 500, 30)
            GUICtrlSetFont($lrc3, 8.5, -1, -1, $fn3)
            GUICtrlSetColor($lrc3, $fc3)
            GUICtrlDelete($lrc4)
            $lrc4 = GUICtrlCreateLabel($lru4 & " says: " & $lr4, 8.5, 56, 500, 30)
            GUICtrlSetFont($lrc4, 8.5, -1, -1, $fn4)
            GUICtrlSetColor($lrc4, $fc4)
            GUICtrlDelete($lrc5)
            $lrc5 = GUICtrlCreateLabel($lru5 & " says: " & $lr5, 8.5, 26, 500, 30)
            GUICtrlSetFont($lrc5, 8.5, -1, -1, $fn5)
            GUICtrlSetColor($lrc5, $fc5)
            If WinActive($d & " Chatta Chat") = 0 Then
                $text = WinGetText($d & " Chatta Chat")
                WinSetTitle($d & " Chatta Chat", $text, "You recieved a message.")
                SoundPlay(@ScriptDir & "\NewChatMessage" & $chmw & ".wav")
            EndIf
            If $lastsentuser <> $uname Then
                TrayTip("Chatta", "New Message from " & $lastsentuser, 3)
            EndIf
        EndIf
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
            GUIDelete($Form1)
            GUISwitch($Form3)
            ExitLoop

        Case $TextPut
            $LastSent1 = GUICtrlRead($TextPut)
            IniWrite($d , "Chat", "Last Sent-", $LastSent1)
            IniWrite($d , "Chat", "Last Sent User", $uname)
            GUICtrlDelete($TextPut)
            $TextPut = GUICtrlCreateInput("", 8.5, 220, 241, 21)
            ControlFocus($d & " Chatta Chat", "", $TextPut)
            IniWrite($d, "Chat", "Last Sent Font Name", $fname)
            IniWrite($d, "Chat", "Last Sent Font Color", $fsize)
    EndSwitch
    $tmsg = TrayGetMsg()
    Switch $tmsg
        Case $hidewindows
            If $winshiding = 1 Then
                $winshiding = 0
                TrayItemSetText($hidewindows, "Hide Windows")
                GUISetState(@SW_SHOW, $Form3)
                GUISetState(@SW_SHOW, $Form1)
            Else
                $winshiding = 1
                TrayItemSetText($hidewindows, "Show Windows")
                GUISetState(@SW_HIDE, $Form3)
                GUISetState(@SW_HIDE, $Form1)
            EndIf
    EndSwitch
    $log = IniRead($d , "Chat", "Last Sent-", $LastSent1)
    $lrbefore = $lr
WEnd
;end Join Chat
EndIf

    Case $opt
;begin Options
#include <GUIConstants.au3>

$Form1 = GUICreate("Chatta Options", 256, 234, 193, 115)
$apply = GUICtrlCreateButton("Apply", 8, 176, 113, 49, 0)
$cancel = GUICtrlCreateButton("Cancel", 128, 176, 121, 49, 0)
$unm = GUICtrlCreateLabel("Username:", 8, 8, 55, 17)
$unme = GUICtrlCreateInput($uname, 8, 32, 241, 21)
$logchats = GUICtrlCreateCheckbox("Log Chats", 8, 64, 161, 17)
$1s = GUICtrlCreateRadio("Message Sound 1", 8, 85)
$2s = GUICtrlCreateRadio("Message Sound 2", 8, 105)
$3s = GUICtrlCreateRadio("Message Sound 3", 8, 125)
$4s = GUICtrlCreateRadio("No Message Sound", 8, 145)
$font = GUICtrlCreateButton("Font...", 120, 85)
If $chmw = 1 Then
    GUICtrlSetState($1s, $GUI_CHECKED)
ElseIf $chmw = 2 Then
    GUICtrlSetState($2s, $GUI_CHECKED)
ElseIf $chmw = 3 Then
    GUICtrlSetState($3s, $GUI_CHECKED)
EndIf
    
If IniRead(@ScriptDir & "ChattaData.chdt", "Log?", "Log...", 0) = 1 Then
    GUICtrlSetState($logchats, $GUI_CHECKED)
EndIf
GUISetState(@SW_SHOW)
$sound = 0
$f = _ArrayCreate("")
_ArrayAdd($f, "")
_ArrayAdd($f, "")
_ArrayAdd($f, "")
_ArrayAdd($f, "")
_ArrayAdd($f, "")
_ArrayAdd($f, "")
_ArrayAdd($f, "")
_ArrayAdd($f, "")
_ArrayAdd($f, "")
While 1
    $nMsg2 = GUIGetMsg()
    Switch $nMsg2
        Case $GUI_EVENT_CLOSE
            GUIDelete($Form1)
            GUISwitch($Form3)
            ExitLoop
            
        Case $font
            $f = _ChooseFont($fname, $fsize)
            _ArrayAdd($f, "")
            _ArrayAdd($f, "")
            _ArrayAdd($f, "")
            _ArrayAdd($f, "")
            _ArrayAdd($f, "")
            _ArrayAdd($f, "")
            _ArrayAdd($f, "")
            _ArrayAdd($f, "")
            _ArrayAdd($f, "")

        Case $apply
            IniWrite(@ScriptDir & "\ChattaData.chdt", "User", "Name", GUICtrlRead($unme))
            If GUICtrlRead($1s) = $GUI_CHECKED Then
                $sound = 1
            ElseIf GUICtrlRead($2s) = $GUI_CHECKED Then
                $sound = 2
            ElseIf GUICtrlRead($3s) = $GUI_CHECKED Then
                $sound = 3
            Else
                $sound = 0
            EndIf
            If GUICtrlRead($logchats) = $GUI_CHECKED Then
                IniWrite(@ScriptDir & "\ChattaData.chdt", "Log?", "Log...", 1)
            Else
                IniWrite(@ScriptDir & "\ChattaData.chdt", "Log?", "Log...", 0)
            EndIf
            IniWrite(@ScriptDir & "\ChattaData.chdt", "Sounds", "Sound", $sound)
            IniWrite(@ScriptDir & "\ChattaData.chdt", "Font", "FName", $f[2])
            IniWrite(@ScriptDir & "\ChattaData.chdt", "Font", "FColor", $f[7])
            GUIDelete($Form1)
            GUISwitch($Form3)
            ExitLoop

        Case $cancel
            GUIDelete($Form1)
            GUISwitch($Form3)
            ExitLoop
    EndSwitch
WEnd
;end Options
    EndSwitch
    Switch $tmsg
    Case $show
        GUISetState(@SW_SHOW)
    Case $exit
        Exit
    EndSwitch
WEnd
Edited by BananaFredSoft
Link to comment
Share on other sites

Source? I wont open any .exe's

Link to comment
Share on other sites

Well I checked it out, but I have a suggestion..

this would be make a good example script if you can make it database driven (instead of textbased)

now that this simple part is finished (the interface concept) you should consider improving it by allowing it to use

Excel, SQL(or mySQL), access or even oracle.. if you like it to work with any of these I should be able to provide you examplary code.. what about making this work with all of the above...

and yes source code is important because I allready could have started on it!

I'm sure you could get alot of ratings and replies on this thread..

The concept is nice, many companies could use a textbased or database driven chat application that is easy to set up

(unlike jabber for example)

that will ask you the minimal amount of questions before you can use it out of the box. (whoah, if it would pull information out of active directory that would also be verry interesting)

Link to comment
Share on other sites

Are you trying to open a .chat file?

Make sure that when you open a chat, .chat is at the end of the file name.

when i join i get a input box. i type and press enter and NOTHING happens

Link to comment
Share on other sites

  • 3 months later...

New update. Check out the original post. :)

Suggestions/comments welcome.

Edited by BananaFredSoft
Link to comment
Share on other sites

  • 1 month later...

This is great.. Been using it at our helpdesk all week.

I do have a wishlist.

well a 3 item list =p

1) To have the New/Join window Hide after you use New or join or just not have a item on the start bar.

2) To have a optin on right click of the systray to hide the chat window(s).

3) Not imporatant but would be nice, to have the Systray icon to Flash with an incomming message or pop a tooltip.

Link to comment
Share on other sites

dont ask 4 souce or you'll get a 2 day ban

Can i try to modifiy this source to become a web based app??

My post was back in May.

Link to comment
Share on other sites

This is great.. Been using it at our helpdesk all week.

I do have a wishlist.

well a 3 item list =p

1) To have the New/Join window Hide after you use New or join or just not have a item on the start bar.

2) To have a optin on right click of the systray to hide the chat window(s).

3) Not imporatant but would be nice, to have the Systray icon to Flash with an incomming message or pop a tooltip.

Thanks for the ideas- I'll start working on them right away. <_<

Link to comment
Share on other sites

Been fiddeling with it a bit. Needed word wraping for our longer winded people.

edidted Form1 and 2 to be

$Form2 = GUICreate($d & ".chat Chatta Chat", 518.5, 300, 357, 270, BitOR($ES_READONLY, $ES_MULTILINE))

Whitch works ok. Made the box a bit longer as some people think that they have to have 'yellow_and_pink_powar_ranjas_unite' for a username and it goes to far over. Only thing that is killin me is that it cuts off the last letter of each line that reaches the border in a multiline message.

Maybe you can see somthing I dont.

Posted the edited version.

$uname = IniRead(@ScriptDir & "\ChattaData.chdt", "User", "Name", "Unknown")
$chmw = IniRead(@ScriptDir & "\ChattaData.chdt", "Sounds", "Sound", 3)
$fsize = IniRead(@ScriptDir & "\ChattaData.chdt", "Font", "FColor", "00x999999")
$fname = IniRead(@ScriptDir & "\ChattaData.chdt", "Font", "FName", "Tahoma")
;FileInstall("E:\NewChatMessage1.wav", @ScriptDir & "\NewChatMessage1.wav")
;FileInstall("E:\NewChatMessage2.wav", @ScriptDir & "\NewChatMessage2.wav")
;FileInstall("E:\NewChatMessage3.wav", @ScriptDir & "\NewChatMessage3.wav")
AutoItSetOption("TrayAutoPause", 0)
#include <GUIConstants.au3>
#Include <GuiEdit.au3>
#include <Misc.au3>
#include <Array.au3>
$show = TrayCreateItem("Show Chatta")
$exit = TrayCreateItem("Exit Chatta")
$Form3 = GUICreate("Chatta", 169, 173, 281, 168)
$newchat = GUICtrlCreateButton("New", 8.5, 8.5, 153, 41, 0)
$joinbutton = GUICtrlCreateButton("Join", 8.5, 56, 153, 49, 0)
$opt = GUICtrlCreateButton("Options..", 8.5, 144, 153, 25, 0)
$hidewindows = TrayCreateItem("Hide All Windows")
$winshiding = 0
GUISetState(@SW_SHOW)

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

        Case $newchat
            GUISetState(@SW_HIDE)
      ;begin New Chat
        $d = FileSaveDialog("New Chat", "C:\", "Chatta Chats (*.chat)")
        If FileExists($d & ".chat") Then
            MsgBox(0, "Sorry", "You can't replace an existing chat.")
            Run(@ScriptDir & "\Chatta.exe")
            Exit
        EndIf
        If MsgBox(4, "Open Chat?", "Would you like to open this chat to the public?") = 7 Then
            IniWrite($d & ".chat", "Chat", "Open", 0)
            $allowed = InputBox("Chatta Allowed Chatters", "Enter the name of the chatter that you want to be allowed.")
            IniWrite($d & ".chat", "Chat", "Allowed user 1", $allowed)
            $allowed = InputBox("Chatta Allowed Chatters", "Enter the name of the second chatter that you want to be allowed.")
            IniWrite($d & ".chat", "Chat", "Allowed user 2", $allowed)
            $allowed = InputBox("Chatta Allowed Chatters", "Enter the name of the third chatter that you want to be allowed.")
            IniWrite($d & ".chat", "Chat", "Allowed user 3", $allowed)
            $allowed = InputBox("Chatta Allowed Chatters", "Enter the name of the third chatter that you want to be allowed.")
        Else
            IniWrite($d & ".chat", "Chat", "Open", 1)
        EndIf
    IniWrite($d & ".chat", "Users", "User 1", $uname)
$u1 = IniRead($d & ".chat", "Users", "User 1", "")
$u2 = IniRead($d & ".chat", "Users", "User 2", "")
$u3 = IniRead($d & ".chat", "Users", "User 3", "")
$Form2 = GUICreate($d & ".chat Chatta Chat", 518.5, 300, 357, 270, BitOR($ES_READONLY, $ES_MULTILINE))
$TextPut = GUICtrlCreateInput("", 8.5, 220, 241, 21)
GUISetState(@SW_SHOW)
Global $lr = ""
Global $lastsentuser = ""
$lrbefore = $lr
$gr = 0
$log = 0
$LastSent1 = ""
$lr1 = ""
$lr2 = ""
$lr3 = ""
$lr4 = ""
$lr5 = ""
$lru1 = ""
$lru2 = ""
$lru3 = ""
$lru4 = ""
$lru5 = ""
$lrc1 = ""
$lrc2 = ""
$lrc3 = ""
$lrc4 = ""
$lrc5 = ""
$z = ""
Global $fc5 
Global $fc4
Global $fc4 
Global $fc3
Global $fc3
Global $fc2
Global $fc2 
Global $fc1
Global $fc1 
Global $lrfs
Global $fn5 
Global $fn4
Global $fn4 
Global $fn3
Global $fn3 
Global $fn2
Global $fn2 
Global $fn1
Global $fn1 
global $lrfn
$time = @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC
While 1
    $lr = IniRead($d & ".chat", "Chat", "Last Sent-", "")
        If $lrbefore <> $lr Then
            If IniRead(@ScriptDir & "ChattaData.chdt", "Log?", "Log...", 0) = 1 Then
                IniWrite(@ScriptDir & "ChattaData.chdt", "Log?", "Log" & $gr + 1, $lr)
                $gr = $gr + 1
            EndIf
            $lastsentuser = IniRead($d & ".chat", "Chat", "Last Sent User", "")
            $lrfn = IniRead($d & ".chat", "Chat", "Last Sent Font Name", "Tahoma")
            $lrfc = IniRead($d & ".chat", "Chat", "Last Sent Font Color", 000000)
            $lr5 = $lr4
            $lr4 = $lr3
            $lr3 = $lr2
            $lr2 = $lr1
            $lr1 = $lr
            $lru5 = $lru4
            $lru4 = $lru3
            $lru3 = $lru2
            $lru2 = $lru1
            $lru1 = $lastsentuser
            $fc5 = $fc4
            $fc4 = $fc3
            $fc3 = $fc2
            $fc2 = $fc1
            $fc1 = $lrfc
            $fn5 = $fn4
            $fn4 = $fn3
            $fn3 = $fn2
            $fn2 = $fn1
            $fn1 = $lrfn
            GUICtrlDelete($lrc1)
            $lrc1 = GUICtrlCreateLabel($lru1 & " says: " & $lr1, 8.5, 146, 500, 30)
            GUICtrlSetFont($lrc1, 8.5, -1, -1, $fn1)
            GUICtrlSetColor($lrc1, $lrfc)
            GUICtrlDelete($lrc2)
            $lrc2 = GUICtrlCreateLabel($lru2 & " says: " & $lr2, 8.5, 116, 500, 30)
            GUICtrlSetFont($lrc2, 8.5, -1, -1, $fn2)
            GUICtrlSetColor($lrc2, $fc2)
            GUICtrlDelete($lrc3)
            $lrc3 = GUICtrlCreateLabel($lru3 & " says: " & $lr3, 8.5, 86, 500, 30)
            GUICtrlSetFont($lrc3, 8.5, -1, -1, $fn3)
            GUICtrlSetColor($lrc3, $fc3)
            GUICtrlDelete($lrc4)
            $lrc4 = GUICtrlCreateLabel($lru4 & " says: " & $lr4, 8.5, 56, 500, 30)
            GUICtrlSetFont($lrc4, 8.5, -1, -1, $fn4)
            GUICtrlSetColor($lrc4, $fc4)
            GUICtrlDelete($lrc5)
            $lrc5 = GUICtrlCreateLabel($lru5 & " says: " & $lr5, 8.5, 26, 500, 30)
            GUICtrlSetFont($lrc5, 8.5, -1, -1, $fn5)
            GUICtrlSetColor($lrc5, $fc5)
            If WinActive($d & ".chat Chatta Chat") = 0 Then
                $text = WinGetText($d & ".chat Chatta Chat")
                WinSetTitle($d & ".chat Chatta Chat", $text, "You recieved a message.")
                SoundPlay(@ScriptDir & "\NewChatMessage" & $chmw & ".wav")
            EndIf
            If $lastsentuser <> $uname Then
                TrayTip("Chatta", "New Message from " & $lastsentuser, 3)
            EndIf
        EndIf
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            If MsgBox(4, "Delete?", "Would you like to delete this chat? If you have Log Chats on, it will still be there in the chat log.") = 6 Then
                FileDelete($d & ".chat")
                GUIDelete($Form2)
                GUISwitch($Form3)
                ExitLoop
            Else
                GUIDelete($Form2)
                GUISwitch($Form3)
                ExitLoop
            EndIf

        Case $TextPut
            $LastSent1 = GUICtrlRead($TextPut)
            IniWrite($d & ".chat", "Chat", "Last Sent-", $LastSent1)
            IniWrite($d & ".chat", "Chat", "Last Sent User", $uname)
            GUICtrlDelete($TextPut)
            $TextPut = GUICtrlCreateInput("", 8.5, 220, 241, 21)
            ControlFocus($d & ".chat Chatta Chat", "", $TextPut)
            IniWrite($d & ".chat", "Chat", "Last Sent Font Name", $fname)
            IniWrite($d & ".chat", "Chat", "Last Sent Font Color", $fsize)
    EndSwitch
    $tmsg = TrayGetMsg()
    Switch $tmsg
        Case $hidewindows
            If $winshiding = 1 Then
                $winshiding = 0
                TrayItemSetText($hidewindows, "Hide Windows")
                GUISetState(@SW_SHOW, $Form3)
                GUISetState(@SW_SHOW, $Form2)
            Else
                $winshiding = 1
                TrayItemSetText($hidewindows, "Show Windows")
                GUISetState(@SW_HIDE, $Form3)
                GUISetState(@SW_HIDE, $Form2)
            EndIf
    EndSwitch
        $log = IniRead($d & ".chat", "Chat", "Last Sent-", $LastSent1)
        IniWrite(@ScriptDir & "ChattaData.chdt", "Log?", "Log" & $gr + 1, $gr)
        $lrbefore = $lr
        
WEnd
;end New Chat
            
        
    Case $joinbutton
        GUISetState(@SW_HIDE)
;begin Join Chat
$d = FileOpenDialog("Open Chat", "C:\", "Chatta Chats (*.chat)")
If @error = 1 Then
    MsgBox(0, "Sorry", "ERROR!!! ARGH!!!")
Else
If IniRead($d & ".chat", "Chat", "Open", 1) = 0 Then
    If IniRead($d & ".chat", "Chat", "Allowed user 1", "") <> $uname Then
        If IniRead($d & ".chat", "Chat", "Allowed user 2", "") <> $uname Then
            If IniRead($d & ".chat", "Chat", "Allowed user 3", "") <> $uname Then
                MsgBox(0, "Sorry", "This chat is private, and you are not on the allowed-user list.")
                Run(@ScriptDir & "\Chatta.exe")
                Exit
            EndIf
        EndIf
    EndIf
EndIf
If IniRead($d , "Users", "User 1", "") <> "" then
    If IniRead($d , "Users", "User 2", "") <> "" then
        If IniRead($d , "Users", "User 3", "") <> "" Then
            If IniRead($d , "Users", "User 4", "") <> "" Then
                If IniRead($d , "Users", "User 5", "") <> "" Then
                    MsgBox(0, "Sorry!", "This chat is full.")
                    Run(@ScriptDir & "\Chatta.exe")
                    Exit
                Else
                    IniWrite($d , "Users", "User 5", "")
                EndIf
            Else
            IniWrite($d , "Users", "User 4", "")
            EndIf
        Else
            IniWrite($d , "Users", "User 3", $uname)
        EndIf
    Else
        IniWrite($d , "Users", "User 2", $uname)
    EndIf
Else
    IniWrite($d , "Users", "User 1", $uname)
EndIf
$u1 = IniRead($d , "Users", "User 1", "")
$u2 = IniRead($d , "Users", "User 2", "")
$u3 = IniRead($d , "Users", "User 3", "")
$Form1  = GUICreate($d & ".chat Chatta Chat", 500.5, 300, 357, 270, BitOR($ES_READONLY, $ES_MULTILINE))
$TextPut = GUICtrlCreateInput("", 8.5, 220, 241, 21)
GUISetState(@SW_SHOW)
Global $lr = ""
Global $lastsentuser = ""
$lrbefore = $lr
$gr = 0
$log = 0
$LastSent1 = 0
$time = @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC
$LastSent1 = ""
$lr1 = ""
$lr2 = ""
$lr3 = ""
$lr4 = ""
$lr5 = ""
$lru1 = ""
$lru2 = ""
$lru3 = ""
$lru4 = ""
$lru5 = ""
$lrc1 = ""
$lrc2 = ""
$lrc3 = ""
$lrc4 = ""
$lrc5 = ""
$z = ""
Global $fc5 
Global $fc4
Global $fc4 
Global $fc3
Global $fc3 
Global $fc2
Global $fc2 
Global $fc1
Global $fc1 
Global $lrfs
Global $fn5 
Global $fn4
Global $fn4 
Global $fn3
Global $fn3 
Global $fn2
Global $fn2 
Global $fn1
Global $fn1 
global $lrfn
While 1
    If WinActive("You recieved a message.") = 1 Then
        $text = WinGetText("You recieved a message.")
        WinSetTitle("You recieved a message.", $text, $d & " Chatta Chat")
    EndIf
    $lr = IniRead($d , "Chat", "Last Sent-", "")
    If @MIN & @SEC > $time Then
        $time = @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC
        If FileExists($d) = 0 then
            MsgBox(0, "Sorry", "The person who created this chat has deleted it.")
            Run(@ScriptFullPath)
            Exit
        EndIf
    EndIf
    If $lrbefore <> $lr Then
            If IniRead(@ScriptDir & "ChattaData.chdt", "Log?", "Log...", 0) = 1 Then
                IniWrite(@ScriptDir & "ChattaData.chdt", "Log?", "Log" & $gr + 1, $lr)
                $gr = $gr + 1
            EndIf
            $lastsentuser = IniRead($d, "Chat", "Last Sent User", "")
            $lrfn = IniRead($d, "Chat", "Last Sent Font Name", "Tahoma")
            $lrfc = IniRead($d, "Chat", "Last Sent Font Color", 000000)
            $lr5 = $lr4
            $lr4 = $lr3
            $lr3 = $lr2
            $lr2 = $lr1
            $lr1 = $lr
            $lru5 = $lru4
            $lru4 = $lru3
            $lru3 = $lru2
            $lru2 = $lru1
            $lru1 = $lastsentuser
            $fc5 = $fc4
            $fc4 = $fc3
            $fc3 = $fc2
            $fc2 = $fc1
            $fc1 = $lrfc
            $fn5 = $fn4
            $fn4 = $fn3
            $fn3 = $fn2
            $fn2 = $fn1
            $fn1 = $lrfn
            GUICtrlDelete($lrc1)
            $lrc1 = GUICtrlCreateLabel($lru1 & " says: " & $lr1, 8.5, 146, 500, 30)
            GUICtrlSetFont($lrc1, 8.5, -1, -1, $fn1)
            GUICtrlSetColor($lrc1, $lrfc)
            GUICtrlDelete($lrc2)
            $lrc2 = GUICtrlCreateLabel($lru2 & " says: " & $lr2, 8.5, 116, 500, 30)
            GUICtrlSetFont($lrc2, 8.5, -1, -1, $fn2)
            GUICtrlSetColor($lrc2, $fc2)
            GUICtrlDelete($lrc3)
            $lrc3 = GUICtrlCreateLabel($lru3 & " says: " & $lr3, 8.5, 86, 500, 30)
            GUICtrlSetFont($lrc3, 8.5, -1, -1, $fn3)
            GUICtrlSetColor($lrc3, $fc3)
            GUICtrlDelete($lrc4)
            $lrc4 = GUICtrlCreateLabel($lru4 & " says: " & $lr4, 8.5, 56, 500, 30)
            GUICtrlSetFont($lrc4, 8.5, -1, -1, $fn4)
            GUICtrlSetColor($lrc4, $fc4)
            GUICtrlDelete($lrc5)
            $lrc5 = GUICtrlCreateLabel($lru5 & " says: " & $lr5, 8.5, 26, 500, 30)
            GUICtrlSetFont($lrc5, 8.5, -1, -1, $fn5)
            GUICtrlSetColor($lrc5, $fc5)
            If WinActive($d & " Chatta Chat") = 0 Then
                $text = WinGetText($d & " Chatta Chat")
                WinSetTitle($d & " Chatta Chat", $text, "You recieved a message.")
                SoundPlay(@ScriptDir & "\NewChatMessage" & $chmw & ".wav")
            EndIf
            If $lastsentuser <> $uname Then
                TrayTip("Chatta", "New Message from " & $lastsentuser, 3)
            EndIf
        EndIf
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
            GUIDelete($Form1)
            GUISwitch($Form3)
            ExitLoop

        Case $TextPut
            $LastSent1 = GUICtrlRead($TextPut)
            IniWrite($d , "Chat", "Last Sent-", $LastSent1)
            IniWrite($d , "Chat", "Last Sent User", $uname)
            GUICtrlDelete($TextPut)
            $TextPut = GUICtrlCreateInput("", 8.5, 220, 241, 21)
            ControlFocus($d & " Chatta Chat", "", $TextPut)
            IniWrite($d, "Chat", "Last Sent Font Name", $fname)
            IniWrite($d, "Chat", "Last Sent Font Color", $fsize)
    EndSwitch
    $tmsg = TrayGetMsg()
    Switch $tmsg
        Case $hidewindows
            If $winshiding = 1 Then
                $winshiding = 0
                TrayItemSetText($hidewindows, "Hide Windows")
                GUISetState(@SW_SHOW, $Form3)
                GUISetState(@SW_SHOW, $Form1)
            Else
                $winshiding = 1
                TrayItemSetText($hidewindows, "Show Windows")
                GUISetState(@SW_HIDE, $Form3)
                GUISetState(@SW_HIDE, $Form1)
            EndIf
    EndSwitch
    $log = IniRead($d , "Chat", "Last Sent-", $LastSent1)
    $lrbefore = $lr
WEnd
;end Join Chat
EndIf

    Case $opt
;begin Options
#include <GUIConstants.au3>

$Form1 = GUICreate("Chatta Options", 256, 234, 193, 115)
$apply = GUICtrlCreateButton("Apply", 8, 176, 113, 49, 0)
$cancel = GUICtrlCreateButton("Cancel", 128, 176, 121, 49, 0)
$unm = GUICtrlCreateLabel("Username:", 8, 8, 55, 17)
$unme = GUICtrlCreateInput($uname, 8, 32, 241, 21)
$logchats = GUICtrlCreateCheckbox("Log Chats", 8, 64, 161, 17)
$1s = GUICtrlCreateRadio("Message Sound 1", 8, 85)
$2s = GUICtrlCreateRadio("Message Sound 2", 8, 105)
$3s = GUICtrlCreateRadio("Message Sound 3", 8, 125)
$4s = GUICtrlCreateRadio("No Message Sound", 8, 145)
$font = GUICtrlCreateButton("Font...", 120, 85)
If $chmw = 1 Then
    GUICtrlSetState($1s, $GUI_CHECKED)
ElseIf $chmw = 2 Then
    GUICtrlSetState($2s, $GUI_CHECKED)
ElseIf $chmw = 3 Then
    GUICtrlSetState($3s, $GUI_CHECKED)
EndIf
    
If IniRead(@ScriptDir & "ChattaData.chdt", "Log?", "Log...", 0) = 1 Then
    GUICtrlSetState($logchats, $GUI_CHECKED)
EndIf
GUISetState(@SW_SHOW)
$sound = 0
$f = _ArrayCreate("")
_ArrayAdd($f, "")
_ArrayAdd($f, "")
_ArrayAdd($f, "")
_ArrayAdd($f, "")
_ArrayAdd($f, "")
_ArrayAdd($f, "")
_ArrayAdd($f, "")
_ArrayAdd($f, "")
_ArrayAdd($f, "")
While 1
    $nMsg2 = GUIGetMsg()
    Switch $nMsg2
        Case $GUI_EVENT_CLOSE
            GUIDelete($Form1)
            GUISwitch($Form3)
            ExitLoop
            
        Case $font
            $f = _ChooseFont($fname, $fsize)
            _ArrayAdd($f, "")
            _ArrayAdd($f, "")
            _ArrayAdd($f, "")
            _ArrayAdd($f, "")
            _ArrayAdd($f, "")
            _ArrayAdd($f, "")
            _ArrayAdd($f, "")
            _ArrayAdd($f, "")
            _ArrayAdd($f, "")

        Case $apply
            IniWrite(@ScriptDir & "\ChattaData.chdt", "User", "Name", GUICtrlRead($unme))
            If GUICtrlRead($1s) = $GUI_CHECKED Then
                $sound = 1
            ElseIf GUICtrlRead($2s) = $GUI_CHECKED Then
                $sound = 2
            ElseIf GUICtrlRead($3s) = $GUI_CHECKED Then
                $sound = 3
            Else
                $sound = 0
            EndIf
            If GUICtrlRead($logchats) = $GUI_CHECKED Then
                IniWrite(@ScriptDir & "\ChattaData.chdt", "Log?", "Log...", 1)
            Else
                IniWrite(@ScriptDir & "\ChattaData.chdt", "Log?", "Log...", 0)
            EndIf
            IniWrite(@ScriptDir & "\ChattaData.chdt", "Sounds", "Sound", $sound)
            IniWrite(@ScriptDir & "\ChattaData.chdt", "Font", "FName", $f[2])
            IniWrite(@ScriptDir & "\ChattaData.chdt", "Font", "FColor", $f[7])
            GUIDelete($Form1)
            GUISwitch($Form3)
            ExitLoop

        Case $cancel
            GUIDelete($Form1)
            GUISwitch($Form3)
            ExitLoop
    EndSwitch
WEnd
;end Options
    EndSwitch
    Switch $tmsg
    Case $show
        GUISetState(@SW_SHOW)
    Case $exit
        Exit
    EndSwitch
WEnd
Edited by MildWarlock
Link to comment
Share on other sites

Been fiddeling with it a bit. Needed word wraping for our longer winded people.

edidted Form1 and 2 to be

$Form2 = GUICreate($d & ".chat Chatta Chat", 518.5, 300, 357, 270, BitOR($ES_READONLY, $ES_MULTILINE))

Whitch works ok. Made the box a bit longer as some people think that they have to have 'yellow_and_pink_powar_ranjas_unite' for a username and it goes to far over. Only thing that is killin me is that it cuts off the last letter of each line that reaches the border in a multiline message.

Maybe you can see somthing I dont.

Posted the edited version.

Cool! Is it OK if I put your code in the main post? I'll make sure to give you credit.
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...