nake89 Posted September 4, 2005 Share Posted September 4, 2005 I just want to get the basic idea on how to make an IM. I have looked at alot of scripts and all I see ist TCP and UDF. And I dont have a clue on what they are since they arent displayed in the autoit help-file... THANK YOU! Link to comment Share on other sites More sharing options...
therks Posted September 4, 2005 Share Posted September 4, 2005 Actually they ARE in the AutoIt helpfile (and it's UDP, not UDF). You just probably need the beta version of AutoIt. Check my signature for links. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
themax90 Posted September 4, 2005 Share Posted September 4, 2005 (edited) If you need more help, check my signature for my fileman and download either AutoIt Archive.zip which has 20+ scripts experimenting with it, or download PIM 1.0 which deals with it..... You will need the beta. http://www.autoitscript.com/autoit3/files/beta/autoit/It's quite simple:expandcollapse popupDim $ConnectedSocket = -1, $port = 200 ;Creates a Socket variable for reading nad port variable TCPStartup() ;Turns on Transmission Control Protocol services $OriginalSocket = TCPListen("127.0.0.1", $port) ;Allows incoming connections and creates a Socket Identifier #include <GuiConstants.au3> GUICreate("Basic IM", 215, 165, (@DesktopWidth - 215) / 2, (@DesktopHeight - 165) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $history = GUICtrlCreateLabel("", 10, 10, 200, 90, $SS_SUNKEN) $Output = GUICtrlCreateInput("", 10, 110, 200, 20) $Connect = GUICtrlCreateButton("Connect To...", 10, 140, 100, 20) $Send = GUICtrlCreateButton("Send", 110, 140, 100, 20) GUISetState() While 1 $msg = GUIGetMsg() ;If there is no connection, then check for one... If $ConnectedSocket = -1 Then $ConnectedSocket = TCPAccept($OriginalSocket) EndIf ;If you receive any data then tell..... $InData = TCPRecv($ConnectedSocket, 999) If $InData <> "" And $InData <> "~~bye" Then ;InData is valid, write to gui. GUICtrlSetData($history, GUICtrlRead($history) & @CRLF & ">" & $InData) ElseIf $InData = "~~bye"Then TCPCloseSocket($ConnectedSocket) $ConnectedSocket = -1 EndIf If $msg = $GUI_EVENT_CLOSE Then ExitLoop ElseIf $msg = $Send And $ConnectedSocket <> - 1 Then $OutData = GUICtrlRead($Output) GUICtrlSetData($Output, "") GUICtrlSetData($history, GUICtrlRead($history) & @CRLF & "<" & $OutData) TCPSend($ConnectedSocket, $OutData) ElseIf $msg = $Connect And $ConnectedSocket = -1 Then $IpAddress = InputBox("Connect to....", "Input IpAddress to connect to.....", "", " ", "200", "130", "-1", "-1") If @error = 0 Then;OK - The string returned is valid $ConnectedSocket = TCPConnect($IpAddress, $port) EndIf EndIf WEnd Func OnAutoItExit() TCPCloseSocket($ConnectedSocket) TCPCloseSocket($OriginalSocket) TCPShutdown EndFunc ;==>OnAutoItExitUsing this you cannot connect to yourself, unless you have two windows open and use the second window. It's the same as PIM 1.0, read here:http://www.autoitscript.com/forum/index.php?showtopic=15402Also if behind a router it will not work unless you forward the port data.UDP(User Datagram Protocol) works the same way only with different calls, and I havn't experimented with Server/Client hybrid in UDP yet.I hope this helps!AutoIt SmithP.S. I just made that Basic in 5 minutes so it's relitivly easy, although I do know TCP functions like the back of my hand now since the past month has been nothing but that. My Remote Server deals with input call strings, check it out here:http://www.autoitscript.com/forum/index.php?showtopic=15408 Edited September 4, 2005 by AutoIt Smith Link to comment Share on other sites More sharing options...
themax90 Posted September 4, 2005 Share Posted September 4, 2005 I don't think UDP can do im like TCP, it seems the way they developed the UDP functions is that it was for Server to Client only. I got this code so for but the original connecting client wont receive information.... expandcollapse popupDim $port = 200, $CSocket = -1 UDPStartUp () $OriginalSocket = UDPBind("127.0.0.1", $port) #include <GuiConstants.au3> GUICreate("Basic IM", 215, 165, (@DesktopWidth - 215) / 2, (@DesktopHeight - 165) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $history = GUICtrlCreateLabel("", 10, 10, 200, 90, $SS_SUNKEN) $Output = GUICtrlCreateInput("", 10, 110, 200, 20) $Connect = GUICtrlCreateButton("Connect To...", 10, 140, 100, 20) $Send = GUICtrlCreateButton("Send", 110, 140, 100, 20) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit ElseIf $msg = $Send Then $OutData = GUICtrlRead($Output) GUICtrlSetData($Output, "") GUICtrlSetData($history, GUICtrlRead($history) & @CRLF & "<" & $OutData) UDPSend($OriginalSocket, $OutData) ElseIf $msg = $Connect Then $IpAddress = InputBox("Connect to....", "Input IpAddress to connect to.....", "", " ", "200", "130", "-1", "-1") If @error = 0 Then;OK - The string returned is valid $CSocket = UDPOpen($IpAddress, $port) UDPSend($CSocket, "~~connect") GUICtrlSetData($history, "New Connection!") EndIf EndIf $InData = UDPRecv($OriginalSocket, 999) If $InData <> "" And $InData <> "~~connect" And $InData <> "~~bye" Then GUICtrlSetData($history, GUICtrlRead($history) & @CRLF & ">" & $InData) ElseIf $InData = "~~connect" Then GUICtrlSetData($history, "New Connection!") ElseIf $InData = "~~bye" Then UDPCloseSocket($OriginalSocket) If $CSocket <> - 1 Then UDPCloseSocket($CSocket) $OriginalSocket = UDPBind("127.0.0.1", $port) EndIf WEnd Func OnAutoItExit() If $CSocket <> - 1 Then UDPCloseSocket($CSocket) UDPCloseSocket($OriginalSocket) UDPShutdown () EndFunc ;==>OnAutoItExit I gotta leave my internet station for a few weeks so be back in a few. AutoIt Smith Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now