Jump to content
Sign in to follow this  
Crome_BAD

Chat Program

Recommended Posts

Crome_BAD

Hey guys, i was wondering if anyony could help with this program. Im not very familiar with the AU3Xtra.dll so, any help would be nice.

#include <GUICONSTANTS.AU3>

HotKeySet( "{ENTER}", "TCPSend")
HotKeySet( "{ESC}", "TCPShutdown")

Global $connectip = "127.0.0.1"
Global $port = "65534"

Main()

Func Main()
   
   GUICreate( "Crome's Chat Program", 300, 400, -1, -1, "", $WS_EX_CLIENTEDGE)
   
   $start = GUICtrlCreateButton( "Start", 5, 5, -1, -1, $BS_FLAT)
   
   Global $sendtext = GUICtrlCreateInput( "", 5, 70, 150, 20)
   
   GUISetState()
   
   While 1
      
      $msg = GUIGetMsg()
      
      If $msg = $GUI_EVENT_CLOSE Then
         Exit
      EndIf
      
      If $msg = $start Then
         TCPStart()
      EndIf
      
      WEnd
EndFunc
   
Func TCPStart()
   
   Global $tcpstart = DLLCall( "AU3Xtra.dll", "int", "TCPStartUp" )
   If $tcpstart = @error Then
      MsgBox( 0, "Error", "Unable To Start TCP Abilities")
      Exit
   EndIf
   
   TCPConnect()
EndFunc

Func TCPConnect()
   
   Global $tcpconnect = DLLCall( "AU3Xtra.dll", "int", "TCPConnect", "str", $connectip, "int", $port)
   If $tcpconnect = @error Then
      Msgbox( 0, "Error", "Unable To Connect To " & $connectip)
      TCPShutdown()
   EndIf
   
   GUICtrlCreateLabel( "Connected...", 5, 40)
   TCPListen()
EndFunc

Func TCPListen()
   
   Global $tcplisten = DLLCall( "AU3Xtra.dll", "int", "TCPListen", "str", "127.0.0.1", "int", $port )
   If $tcplisten = @error Then
      MsgBox( 0, "Error", "Cannot Listen On 127.0.0.1")
      TCPShutdown()
   EndIf
   
   TCPRecv()
EndFunc

Func TCPRecv()
   
   Do   
      
      Global $tcprecv = DLLCall( "AU3Xtra.dll", "int", "TCPRecv", "int", $tcplisten, "str", "", "int", 1024 )
      
   Until $tcprecv = @error
   
   TCPShutdown()
EndFunc

Func TCPSend()
   
   $read = GUICtrlRead( $sendtext)
   
   DLLCall( "AU3Xtra.dll", "int", "TCPSend", "int", $tcpconnect, "str", $read)
   Sleep(1500)
   TCPRecv()
EndFunc

Func TCPShutdown()
   
   DLLCall( "AU3Xtra.dll", "int", "TCPShutDown" ,"int", $tcpstart)
   
   Stop()
EndFunc

Func Stop()
   
   Exit
EndFunc

Also, anyone kno where to update scite? lol ive got the new au3 def but scite doesent pick them up, and i cant run scripts through it, so i havta compile everytime i want to run 1, real big pain...

Peace,

Crome_BAD

Share this post


Link to post
Share on other sites
Jos

Also, anyone kno where to update scite? lol ive got the new au3 def but scite doesent pick them up, and i cant run scripts through it, so i havta compile everytime i want to run 1, real big pain...

Peace,

Crome_BAD

<{POST_SNAPBACK}>

There is a special SciTE installer available on its own SciTE4AutoIt3 's home page that contains everything needed to code AutoIt3 scripts with SciTE:

http://www.autoitscript.com/autoit3/scite


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Crome_BAD

Just about to edit this post....lol i found it, ty tho.

Also, i ran the program on 2 cp's, both say unable to connect to either its IP address, or 127.0.0.1.....

Edited by Crome_BAD

Share this post


Link to post
Share on other sites
layer

maybe you have the router ip address... here! go to here and use these as the ip's

http://www.whatismyip.com/

just a suggestion :idiot:


FootbaG

Share this post


Link to post
Share on other sites
Crome_BAD

yes, lol but i fixed it alittle to connect to localhost (will be changed with time) but now i have a the problem of it not recieving text...lol any ideas..?

Share this post


Link to post
Share on other sites
layer

recieving test from? where?


FootbaG

Share this post


Link to post
Share on other sites
Crome_BAD

Lol hold up and ill put it on another cp also, and test it form there

Share this post


Link to post
Share on other sites
Einzeinbleth

IMO AutoIt is not good for creating chat program .. i created one in Delphi, and also, you dont need to have any installed program :] just connect via telnet to pc where program is running, and then everybody who is there connected will receive your messages :idiot:

if someone want test: telnet 83.27.120.64 6120 [in win 98 disable "local echo" in terminal-> preferences...] and a program with source:

http://www.wroclaw.mm.pl/~einzeinbleth/chat.zip

sorry for offtopic

Einzeinbleth

Share this post


Link to post
Share on other sites
layer

well, i think it could be done, who cares if it's not perfect... someone has got to start the wheel of AutoIt Instant Messaging! a few dllcalls here and there!and poof,,, right>?


FootbaG

Share this post


Link to post
Share on other sites
Crome_BAD

Hmmm ill check that out

Share this post


Link to post
Share on other sites
Crome_BAD

Thats right layer, it would be nice, im trying hard, lol but i cant get the tcp functions to work for my liking. lol. Im trying to figure out wat order it goes in...

1. TCP Start (Duh)

2. TCP Connect Maybe?

3. TCP Listen

4. TCP Send\Recieve

5. TCP Shutdown

I think larry posted a example server/client code, but i cant seem to find it.

(Really tired, newborn keeps me up all night:P)

Peace,

Crome_BAD

EDIT: Found the RIGHT example code, studing it now...lol

Edited by Crome_BAD

Share this post


Link to post
Share on other sites
Crome_BAD

Heres Some new code, try this, its for a server. I think it will only run on WinXP, im running WinME and the program locks up, arg. If you guys have any luck, let me kno.

#include <GUICONSTANTS.AU3>

HotKeySet( "{ESC}", "TCPShutDown")

Main()

Func Main()
   
   GUICreate( "Cromes Messenger", 300, 300, -1, -1, "", $WS_EX_CLIENTEDGE)
   
   $start = GUICtrlCreateButton( "Start", 5, 5, -1, -1, $BS_FLAT)
   
   Global $sendtext = GUICtrlCreateInput( "", 5, 250, 290, 20)
   
   GUISetState()
   
   While 1
      
      $msg = GUIGetMsg()
      
      If $msg = $start Then
         TCPStartServer()
      EndIf
      
   WEnd
EndFunc

Func TCPStartServer()
   
   $tcpstart = DLLCall( "AU3Xtra.dll", "int", "TCPStartUp" )
   If @error Or $tcpstart[0] = 0 Then
      MsgBox( 4096, "Error", "Unable To Start TCP Abilities")
      Stop()
   Else
   TCPListen()
   EndIf
EndFunc

Func TCPListen()
   
   $tcplisten = DLLCall( "AU3Xtra.dll", "int", "TCPListen","str", "127.0.0.1","int", 65432 )
   If @error Then
      MsgBox( 4096, "Error", "Unable To Connect To 127.0.0.1")
      TCPShutDown()
   Else
   Global $socket = $tcplisten[0]
   TCPRec()
   EndIf
EndFunc

Func TCPRec()
   
   Do
      
  $tcprecv = DLLCall( "AU3Xtra.dll", "int", "TCPRecv","int", $socket,"str", "","int", 1024 )
  
   Until @error
   
   TCPShutDown()
EndFunc

Func TCPShutDown()
                            
   DLLCall( "AU3Xtra.dll", "int", "TCPShutDown","int", $socket)
   Stop()
EndFunc

Func Stop()
   
   Exit
EndFunc

Peace,

Crome_BAD

The Client Code im workin on works fine, not sure y....

Edited by Crome_BAD

Share this post


Link to post
Share on other sites
zcoacoaz

i have been making a chat program called ez chat for about 2 months now, it has plugins, themes, you can have as many conversations as your comp can handle send files, and im working on more, when i finish the next build i will send you the client if you want


[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

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  

×