
JavaScript_Freek
Active Members-
Posts
315 -
Joined
-
Last visited
Content Type
Forums
Downloads
Forum Articles
Events
Everything posted by JavaScript_Freek
-
Looking pretty good. I like this! :-)
-
Sorry, I wouldn't know.
-
Line Break in TCP
JavaScript_Freek replied to JavaScript_Freek's topic in AutoIt General Help and Support
No, see the post above yours. -
Ok thanks, so... how is the code? Cool? Needs improving? Etc?
-
Line Break in TCP
JavaScript_Freek replied to JavaScript_Freek's topic in AutoIt General Help and Support
User says: Hihihi User2 says: hi! Because when I do this... it's like: User says: Hihihi User2 says: hi! In one line... -
Line Break in TCP
JavaScript_Freek replied to JavaScript_Freek's topic in AutoIt General Help and Support
Any feedback on this? -
Yeah that's still a bug I am working. Just comment the "hotkey" for {ENTER}. Trying to find a way around it. One, thing I am trying to find out how to do is online users. That will be a challenge.
-
Eh, it's okay. Found the solution! Thanks!
-
Sorry. But, I don't think thats the answer. :S
-
I am trying to make it so when someone quits the application it says "user has logged off". But then I get this error: (Line 114) Help, why does this happen? ; ********************* ; SIMPLE LAN Chat ; By Javascript_Freek ; version 1.5a ; ********************* #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <ButtonConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <File.au3> Opt("GUIOnEventMode", 1) Global $reachserver, $reachdata, $linedata, $chatarea, $userlist, $lanchat_gui, $username Global $sel, $rename, $menu1, $ms_, $reachcast ; CREATE THE GUI $lanchat_gui = GUICreate("LAN CHAT v1.5a", 380, 345, -1, -1) ; WHERE YOUR USERNAME IS STORED Dim $inifile = "username.ini" ; LOADING USERNAME loadname() Global $username ; LOGGED IN AS If $username = "" Then GUICtrlCreateLabel("Welcome!" & $username, 8, 7, 200) Else GUICtrlCreateLabel("Logged in as: " & $username, 8, 7, 200) Endif ; CHAT AREA $chatarea = GUICtrlCreateListView("", 8, 32, 250, 257, $LVS_LIST, $WS_EX_CLIENTEDGE) _GUICtrlListView_SetColumnWidth($chatarea, 0, 100) _GUICtrlListView_SetExtendedListViewStyle($chatarea, $LVS_EX_FULLROWSELECT) _GUICtrlListView_SetView($chatarea, 3) ; USERS ONLINE LIST $userlist = GUICtrlCreateListView("", 270, 32, 105, 257, $LVS_LIST, $WS_EX_CLIENTEDGE) _GUICtrlListView_SetColumnWidth($userlist, 0, 100) _GUICtrlListView_SetView($userlist, 3) ; THE INPUT OF YOUR MSGS $input = GUICtrlCreateInput("", 8, 296, 250, 21) ; SEND BUTTON $Button1 = GUICtrlCreateButton("send", 270, 296, 105, 21, 0) GUICtrlSetOnEvent(-1, "sendmsg") ; MENU $nFileMenu = GUICtrlCreateMenu("File") $nExititem2 = GUICtrlCreateMenuItem("New Name", $nFileMenu) GUICtrlSetOnEvent(-1, "renameyou") $nExititem = GUICtrlCreateMenuItem("Exit", $nFileMenu) GUICtrlSetOnEvent(-2, "quit") $aFileMenu = GUICtrlCreateMenu("About") $aAboutitem = GUICtrlCreateMenuItem("About", $aFileMenu) GUICtrlSetOnEvent(-3, "about") ; ALLOWS THE PROGRAM TO CLOSE GUISetOnEvent($GUI_EVENT_CLOSE, "quit") GUISetState() ;LOADS USERNAME $username = "" loadname() ; NO USERNAME FOUND, LOAD THIS If $username = "" Then $username = InputBox("Welcome to the LAN Chat", "Create a username", "") Global $username If $username = "" Then MsgBox(48,"No namer!","You didn't put anything down for your new name. See ya!") Exit Else IniWrite($inifile, "me", 0, $username) Endif Endif ; GETS IP ADDRESS AND DECLARES A VARIABLE $varIP = @IPAddress1 ; STARTS UP UDP UDPStartup() ; CREATES A SOCKET BOUND TO AN INCOMING CONNECTION $reachserver = UDPBind($varIP, 65335) Sleep(1000) ; SPLITS IP ADDRESS AND DECARES VARIABLES $divideIP = StringSplit($varIP, ".") $newaddress = $divideIP[1] & "." & $divideIP[2] & "." & $divideIP[3] & "." & "255" ; OPENS THE SOCKET CONNECTED TO AN EXITISING SERVER USING YOUR SPLIT UP IP ADDRESS $reachcast = UDPOpen($newaddress, 65335) While 1 ;RECIEVING THE DATA FROM AN OPEN SOCKET $reachdata = UDPRecv($reachserver, 50) ; YOU RECEIVED SUCCESSFULL, SO RUN THIS If $reachdata <> "" Then $tmp = StringSplit($reachdata, "|") $linedata = $tmp[2] ; If the user who typed the message is NOT you... call this function! If StringInStr($linedata, $username) = 0 And StringInStr($tmp[1], ".") <> 4 Then $str = StringSplit($linedata, "|") $last = $str[0] _GUICtrlListView_AddItem($chatarea, $str[$last] & " says: " & $tmp[1]) _FileWriteLog("logs.txt", $str[$last] & " says: " & $tmp[1]) EndIf EndIf ; SETTING THE HOTKEY OF SENDING MSGS BY PRESSING ENTER HotKeySet("{ENTER}", "sendmsg") Sleep(50) WEnd ; FUNCTION LOADS FILE FROM CREATED INI Func loadname() $username = IniRead($inifile, "me", 0, "") EndFunc ;FUNCTION TO SEND MESSAGES Func sendmsg() If GUICtrlRead($input) = "" Then Msgbox(64, "Error", "You did not send anything.") Else UDPSend($reachcast, GUICtrlRead($input) & "|" & $username) _GUICtrlListView_AddItem($chatarea, $username & " says: " & GUICtrlRead($input)) _FileWriteLog("logs.txt", $username & " says: " & GUICtrlRead($input)) Endif GUICtrlSetData($input, "") _GUICtrlListView_Scroll($chatarea, 0, 150) EndFunc ; QUITTING PROGRAM FUNCTION Func quit() UDPSend($reachcast,$username &" has logged off.") Sleep(1000) UDPCloseSocket($varIP) UDPShutdown() Exit EndFunc ;RENAMING YOURSELF MESSAGE BOX INSTRUCTIONS Func renameyou() MsgBox(64,"To change your name","Where you have launched this application, find username.ini."& @LF &"Inside you can edit your username."& @LF &"Before you edit your username, please exit this program.") EndFunc ; ABOUT THIS PROGRAM MESSAGE BOX Func about() MsgBox(64,"About LAN Chat","Who can connect here? Whoever is on the same LOCAL AREA NETWORK as you. You can connect and chat to others who are usually in the same building or near area.") EndFunc
-
Simple LAN Chat Hello everyone, recently, I embarked upon a cool task. Creating a SIMPLE LAN Chat. Users launch this application and chat with others who are on the same LAN. This is very basic and can be easy to understand. I have made several comments within this chat so you know whats happening. One thing I hope to add to this is ONLINE USERS. You, yourself, can add to this as well. This is more of a learning tool to see how LAN chats work. One last thing, pressing ENTER also sends messages. Enjoy. (PS, I may have left some not needed includes. ) ; ********************* ; SIMPLE LAN Chat ; By Javascript_Freek ; version 1.4b ; ********************* #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <ButtonConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <File.au3> Opt("GUIOnEventMode", 1) Global $reachserver, $reachdata, $linedata, $chatarea, $usersonline, $lanchat_gui, $username ; CREATE THE GUI $lanchat_gui = GUICreate("LAN CHAT v1.4b", 380, 345, -1, -1) ; WHERE YOUR USERNAME IS STORED Dim $inifile = "username.ini" ; LOADING USERNAME loadname() Global $username ; LOGGED IN AS If $username = "" Then GUICtrlCreateLabel("Welcome!" & $username, 8, 7, 200) Else GUICtrlCreateLabel("Logged in as: " & $username, 8, 7, 200) Endif ; CHAT AREA $chatarea = GUICtrlCreateListView("", 8, 32, 365, 257, $LVS_LIST, $WS_EX_CLIENTEDGE) _GUICtrlListView_SetColumnWidth($chatarea, 0, 100) _GUICtrlListView_SetExtendedListViewStyle($chatarea, $LVS_EX_FULLROWSELECT) _GUICtrlListView_SetView($chatarea, 3) ; THE INPUT OF YOUR MSGS $input = GUICtrlCreateInput("", 8, 296, 250, 21) ; SEND BUTTON $Button1 = GUICtrlCreateButton("send", 270, 296, 105, 21, 0) GUICtrlSetOnEvent(-1, "sendmsg") ; MENU $nFileMenu = GUICtrlCreateMenu("File") $nExititem2 = GUICtrlCreateMenuItem("New Name", $nFileMenu) GUICtrlSetOnEvent(-1, "renameyou") $nExititem = GUICtrlCreateMenuItem("Exit", $nFileMenu) GUICtrlSetOnEvent(-2, "quit") $aFileMenu = GUICtrlCreateMenu("About") $aAboutitem = GUICtrlCreateMenuItem("About", $aFileMenu) GUICtrlSetOnEvent(-3, "about") ; ALLOWS THE PROGRAM TO CLOSE GUISetOnEvent($GUI_EVENT_CLOSE, "quit") GUISetState() ;LOADS USERNAME $username = "" loadname() ; NO USERNAME FOUND, LOAD THIS If $username = "" Then $username = InputBox("Welcome to the LAN Chat", "Create a username", "") Global $username If $username = "" Then MsgBox(48,"No namer!","You didn't put anything down for your new name. See ya!") Exit Else IniWrite($inifile, "me", 0, $username) Endif Endif ; GETS IP ADDRESS AND DECLARES A VARIABLE $varIP = @IPAddress1 ; STARTS UP UDP UDPStartup() ; CREATES A SOCKET BOUND TO AN INCOMING CONNECTION $reachserver = UDPBind($varIP, 65335) Sleep(1000) ; SPLITS IP ADDRESS AND DECARES VARIABLES $divideIP = StringSplit($varIP, ".") $newaddress = $divideIP[1] & "." & $divideIP[2] & "." & $divideIP[3] & "." & "255" ; OPENS THE SOCKET CONNECTED TO AN EXITISING SERVER USING YOUR SPLIT UP IP ADDRESS $reachcast = UDPOpen($newaddress, 65335) While 1 ;RECIEVING THE DATA FROM AN OPEN SOCKET $reachdata = UDPRecv($reachserver, 50) ; YOU RECEIVED SUCCESSFULL, SO RUN THIS If $reachdata <> "" Then $tmp = StringSplit($reachdata, "|") $linedata = $tmp[2] ; If the user who typed the message is you... call this function! If StringInStr($linedata, $username) = 0 And StringInStr($tmp[1], ".") <> 4 Then $str = StringSplit($linedata, "|") $last = $str[0] _GUICtrlListView_AddItem($chatarea, $str[$last] & " says: " & $tmp[1]) _FileWriteLog("logs.txt", $str[$last] & " says: " & $tmp[1]) EndIf EndIf ; SETTING THE HOTKEY OF SENDING MSGS BY PRESSING ENTER HotKeySet("{ENTER}", "sendmsg") Sleep(50) WEnd ; FUNCTION LOADS FILE FROM CREATED INI Func loadname() $username = IniRead($inifile, "me", 0, "") EndFunc ;FUNCTION TO SEND MESSAGES Func sendmsg() If GUICtrlRead($input) = "" Then Msgbox(64, "Error", "You did not send anything.") Else UDPSend($reachcast, GUICtrlRead($input) & "|" & $username) _GUICtrlListView_AddItem($chatarea, $username & " says: " & GUICtrlRead($input)) Endif GUICtrlSetData($input, "") _GUICtrlListView_Scroll($chatarea, 0, 150) EndFunc ; QUITTING PROGRAM FUNCTION Func quit() Sleep(1000) UDPCloseSocket($varIP) UDPShutdown() Exit EndFunc ;RENAMING YOURSELF MESSAGE BOX INSTRUCTIONS Func renameyou() MsgBox(64,"To change your name","Where you have launched this application, find username.ini."& @LF &"Inside you can edit your username."& @LF &"Before you edit your username, please exit this program.") EndFunc ; ABOUT THIS PROGRAM MESSAGE BOX Func about() MsgBox(64,"About LAN Chat","Who can connect here? Whoever is on the same LOCAL AREA NETWORK as you. You can connect and chat to others who are usually in the same building or near area.") EndFunc
-
I tried looking in the Help file but could not find it... what does <> mean?
-
What are those? Are those some kind of functions or something that they do? Also, are there more of these?
-
LAN Chatting
JavaScript_Freek replied to JavaScript_Freek's topic in AutoIt General Help and Support
Where can I bump topics? :S Anyways, this topic stall stands for me. -
Line Break in TCP
JavaScript_Freek replied to JavaScript_Freek's topic in AutoIt General Help and Support
Thank you yucatan. :-) But where it says "speaks". Where I put it after the the input... it does not work. Such as Func sendit() UDPSend($contactcast, GUICtrlRead($input) & "|" & $me) _GUICtrlListView_AddItem($hlistview, $me & " speaks: " & GUICtrlRead($input) & @CRLF) _GUICtrlListView_AddItem($hlistview,"") GUICtrlSetData($input, "") _GUICtrlListView_Scroll($hlistview, 0, 150) EndFunc ;==>sendit -
LAN Chatting
JavaScript_Freek replied to JavaScript_Freek's topic in AutoIt General Help and Support
All I really see are TCPs. I need UPDs for LAN Chat. -
LAN Chatting
JavaScript_Freek replied to JavaScript_Freek's topic in AutoIt General Help and Support
Err, Ok. Yes, I would like the basics. Nothing fancy. -
Hello, I am not new to AutoIt. I have a basic grasp of the GUI controls and other things. I BARELY know anything dealing with TCP. I want to create a simple and basic LAN chat. I want users to be able to launch the script and be chatting with others who have launched it as well. Where would be a good place to start? Yes, I tried searching. But most programs are either broken or not what I want. What I DON'T want... Something that requires you to start server than client. Thank you.
-
When you type a short message such as "hi" then type "hi" again, you will see that there is no line break. For example load the .au3 below ... make your username a short one and send a short message... How do I add a line break after someone "speaks". #include<Array.au3> #include<GuiListView.au3> #include<Misc.au3> #include<GUIConstantsEx.au3> #include<ListViewConstants.au3> #include<WindowsConstants.au3> #include<StructureConstants.au3> #include <ButtonConstants.au3> #include <Sound.au3> Opt("GUIOnEventMode", 1) #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=chat.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Global $contactserver, $buddy, $contactdata, $msgdata, $sel, $rename, $menu1, $ms_ Global $hlistview, $c_list, $chat_gui, $buttoncontext, $buttonitem, $msg, $me Dim $buddy[1] Dim $inifile = @MyDocumentsDir & "\chat.ini" load() Global $me $chat_gui = GUICreate("LAN Chat v1.2", 512, 390, 526, 146, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_ACCEPTFILES, $WS_EX_TOPMOST)) GUICtrlCreateLabel("Who's online?", 325, 7, 100) $c_list = GUICtrlCreateListView("", 325, 28, 183, 347, $LVS_LIST, $WS_EX_CLIENTEDGE) _GUICtrlListView_SetColumnWidth($c_list, 0, 100) _GUICtrlListView_SetExtendedListViewStyle($c_list, $LVS_EX_FULLROWSELECT) _GUICtrlListView_SetView($c_list, 3) _GUICtrlListView_AddItem($c_list, $me) $input = GUICtrlCreateInput("Welcome " & $me, 8, 350, 250, 25) $Button1 = GUICtrlCreateButton("send", 263, 350, 54, 25, 0) GUICtrlSetOnEvent(-1, "sendit") $hlistview = GUICtrlCreateListView("", 8, 28, 306, 315, $LVS_LIST, $WS_EX_CLIENTEDGE) _GUICtrlListView_AddItem($hlistview, $me & " has signed on.") _GUICtrlListView_SetColumnWidth($hlistview, 0, 100) _GUICtrlListView_SetExtendedListViewStyle($hlistview, $LVS_EX_FULLROWSELECT) _GUICtrlListView_SetView($hlistview, 3) GUISetOnEvent($GUI_EVENT_CLOSE, "quit") GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState() $me = "" load() If $me = "" Then $me = InputBox("Who Are you", "Your name", "") Global $me IniWrite($inifile, "me", 0, $me) _GUICtrlListView_AddItem($c_list, $me) _ArrayAdd($buddy, $me) Endif $PrivateIP = @IPAddress1 ; Start The UDP Services ;============================================== UDPStartup() ; Bind to a SOCKET ;============================================== $contactserver = UDPBind($PrivateIP, 65335) Sleep(1000) ;create multicast address $splitaddress = StringSplit($PrivateIP, ".") $changeaddress = $splitaddress[1] & "." & $splitaddress[2] & "." & $splitaddress[3] & "." & "255" ;send packet $contactcast = UDPOpen($changeaddress, 65335) AdlibEnable("check", 1000) While 1 $contactdata = UDPRecv($contactserver, 50) If StringInStr($contactdata, "|") > 0 Then $str = StringSplit($contactdata, "|") If $contactdata <> "" And StringInStr($str[1], ".") = 4 And StringInStr($str[1], ".", 0, 2) = 8 Then $ar = _ArraySearch($buddy, $str[2]) If @error Then ConsoleWrite("Adding via Buddy") _ArrayAdd($buddy, $str[2]) _GUICtrlListView_AddItem($c_list, $str[2]) Else $c = _GUICtrlListView_GetItemText($c_list, $ar - 1) If StringInStr($c, "On-line") = 0 Then _GUICtrlListView_SetItemText($c_list, $ar - 1, $str[2] & " On-line") If $str[2] <> $me Then _GUICtrlListView_AddItem($hlistview, $str[2] & " has signed on") _SoundPlay("C:\Windows\Media\Speech on.wav",0) EndIf EndIf EndIf EndIf If $contactdata <> "" Then $tmp = StringSplit($contactdata, "|") $msgdata = $tmp[2] If StringInStr($msgdata, $me) = 0 And StringInStr($tmp[1], ".") <> 4 And StringInStr($tmp[2], "Has signed") = 0 Then $str = StringSplit($msgdata, "|") $last = $str[0] _SoundPlay("Windows Shutdown.wav", 0) _GUICtrlListView_AddItem($hlistview, $str[$last] & " says: " & $tmp[1]) _GUICtrlListView_Scroll($hlistview, 0, 50) ElseIf StringInStr($msgdata, $me) = 0 And StringInStr($tmp[1], ".") <> 4 And StringInStr($tmp[2], "Has signed") > 0 Then $str = StringSplit($msgdata, "|") $last = $str[0] If StringInStr($tmp[2], "Has signed off") > 0 Then _GUICtrlListView_AddItem($hlistview, $tmp[1] & " " & $str[$last]) _GUICtrlListView_Scroll($hlistview, 0, 50) $ar = _ArraySearch($buddy, $tmp[1]) _GUICtrlListView_SetItemText($c_list, $ar - 1, $tmp[1] & " Off-line") EndIf EndIf EndIf If _IsPressed("OD") Then sendit() Sleep(50) WEnd Func check() If $me <> "" Then UDPSend($contactcast, @IPAddress1 & "|" & $me) EndFunc ;==>check Func quit() _GUICtrlListView_AddItem($hlistview, $me & " has signed off.") _GUICtrlListView_DeleteItem($c_list, $me) _SoundPlay("C:\Windows\Media\Speech Off.wav",0) AdlibDisable() Sleep(1000) UDPSend($contactcast, $me & "|Has signed off") UDPCloseSocket($PrivateIP) UDPShutdown() For $i = 1 To UBound($buddy) - 1 IniWrite($inifile, "contacts", $i - 1, $buddy[$i]) Next Exit EndFunc ;==>quit Func load() $me = IniRead($inifile, "me", 0, "") $var = IniReadSection($inifile, "contacts") If Not @error Then For $x = 1 To $var[0][0] If $var[$x][1] <> @IPAddress1 Then _GUICtrlListView_AddItem($c_list, $var[$x][1] & " Off-line") _ArrayAdd($buddy, $var[$x][1]) Else If $me <> "" Then _GUICtrlListView_AddItem($c_list, $me & " Off-line") _ArrayAdd($buddy, $me) EndIf EndIf Next EndIf EndFunc ;==>load Func sendit() ConsoleWrite("SEND" & @LF) UDPSend($contactcast, GUICtrlRead($input) & "|" & $me) _GUICtrlListView_AddItem($hlistview, $me & " speaks: " & GUICtrlRead($input)) _GUICtrlListView_AddItem($hlistview,"") GUICtrlSetData($input, "") _GUICtrlListView_Scroll($hlistview, 0, 150) EndFunc ;==>sendit Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $tNMHDR, $iCode, $tInfo, $iItem $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $iCode = DllStructGetData($tNMHDR, "Code") Switch $iCode Case $NM_RCLICK $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $sel = DllStructGetData($tInfo, "Index") ConsoleWrite("Right click") Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) If $iItem = _GUICtrlListView_GetColumnCount($hListView) - 1 Then Return 1 ConsoleWrite("double click") EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func rename() ConsoleWrite("func rename") EndFunc ;==>rename
-
Maybe it's cause I'm on Windows Vista! I shall let you back with my info on the new version.
- 247 replies
-
I am guessing this only work on "localhost". I tried connecting to my server on my website and I have provided the right details but I keep getting "Cannot connect to Localhost."
-
I tried this with my brother. Everytime I hovered over his name.. a tooltip came up,. Regardless, when I attempted to double click (beating the tooltip showing up), nothing would happen.
- 247 replies
-
The File->Exit won't work.And I only want USERNAME.
-
Line 32givesmeanerror.