Sign in to follow this  
Followers 0
seesoe

a3_chat.au3

12 posts in this topic

hhhmmm how should i start off, ok got it.

hello, this thread is about a3_chat.au3 script. im not sure if there has ever been a development on something like this or what, but this is a chating program writen with autoit. now i don't konw much codeing my self but i have seen the codes for other autoit scripts and know that can be done and what can't be done, i will try to pull codes from some work that zerocool has done to make this autoit chat.

here is the way this system will work,

it will need to folowing to work

1. you will need a copy of SAPI on both computers download and install the Microsoft SAPI SDK 5.1

2. you will need a commen global file named com.con to be hosted on the web*or com.txt depending on the server host*

3. a copy of the finished a3_chat.au3 on one computer

4. another copy of the finished a3_chat.au3 on another computer

5. a copy of the already finished ftp.au3

ok so this is how its gonna work, on my computer i have a3_chat.au3 running, *its a simple GUI* i hold down the botton and talk into my mic, when im done talking all that i have said will be translated into text and that will be sent to the commen com.con file that is web hosted.

then on your computer you will also have the simple GUI a3_chat.au3 running, and when ever it picks up text that is writen in the com.con file it will be read out loud by microsoft sam or what ever you set it to.

i have some codes that i was allowed to play with writen by zerocool the first one, that is the main code that has most of the things that could be pulled fromit is talk.au3 i think all that needs to be done is put the sapi codes into it insted of getting the codes from a php file

talk.au3

HotKeySet ( "{ESC}",  "e")
;AutoItSetOption ( "TrayIconHide", 1 )
While 1
InetGet ( "http://'location of com.con'.com/com.con", "temp.html", 1)
sleep(100)
$read = FileRead ( "temp.html")
if $read <> "" Then
InetGet ( "http://'location of talk.php'.com/talk.php?talk=1", "", 1)
_Talk($read)
endif
sleep(100)
Wend
func e()
exit
endfunc

Func _Talk($sText)
    $tempFile = @TempDir & '\talktemp.vbs' ; Set the temp file
    FileWriteLine($tempFile, 'Dim Talk' & @CRLF & _
    'Set Talk = WScript.CreateObject("SAPI.SpVoice")' & _
    @CRLF & 'Talk.Speak "' & $sText & '"'); Add contents to the temp file
    RunWait('Wscript.exe talktemp.vbs', @TempDir); Run the VBScript
    FileDelete($tempFile)
EndFunc

here is the SAPI au3 version codes writen by theguy0000

AutoItSetOption ( "TrayAutoPause", 0)
Local $o_speech = ObjCreate ("SAPI.SpVoice")
$voice = $o_speech.GetVoices().Item(0)
$o_speech.Voice = $voice
$speed = 2
$silent = 1
Global $text
While 1
    Sleep(100)
    gettext()
    If $text <> "" Then
        If $text = "exit" Then
            Exit
        ElseIf $text = "Set Voice Sam" Then
            $voice = $o_speech.GetVoices().Item(0)
            $o_speech.Voice = $voice
            _TalkOBJ ("You have selected Sam", 0, $silent)
        ElseIf $text = "Set Voice Mike" Then
            $voice = $o_speech.GetVoices().Item(1)
            $o_speech.Voice = $voice
            _TalkOBJ ("Mike, reporting for duty.", 0, $silent)
        ElseIf $text = "Set Voice Mary" Then
            $voice = $o_speech.GetVoices().Item(2)
            $o_speech.Voice = $voice
            _TalkOBJ ("Mary here.", 0, $silent)
        ElseIf $text = "Set Voice Bla" Or $text = "Set Voice Blah" Then
            $voice = $o_speech.GetVoices().Item(3)
            $o_speech.Voice = $voice
            _TalkOBJ ("You have selected Blah", 0, $silent)
        ElseIf $text = "Silence" Then
            $silent = 0
            _TalkOBJ("Shhhh!", $voice, $silent)
        ElseIf $text = "Speak" Then
            $silent = 1
            _TalkOBJ("I'm here to talk", $voice, $silent)
        ElseIf $text = "Talk Faster" Then
            $speed = $speed+3
        Else
            _TalkOBJ(SR_reply ($text), 0, $silent)
        EndIf
    EndIf
WEnd

Func OnAutoItExit ( )
    FileDelete ( @ScriptDir & "\heard.txt" )
EndFunc

Func gettext()
RunWait(@ScriptDir & "\write.exe")
    $file = FileOpen ( "heard.txt", 0 )
    $text = FileRead ($file )
    FileClose ( $file )
    $file = FileOpen ( "heard.txt", 2 )
    FileWrite ($file, "")
    FileClose ( $file )
EndFunc

Func _TalkOBJ($say, $rate=0, $talk=1)
    If $rate <> 0 Then $rate = $speed
    TrayTip ($voice.GetAttribute("Name"), $say, 1)
    If $talk <> 0 Then $o_speech.Speak ('<rate speed="'&$rate&'">'&$say&'</rate>')
EndFunc

Func SR_reply($something)
    Switch $something
        Case "hi"
            Return "hello"
        Case "hello"
            Return "Hi there!"
        Case "test"
            Return "What the heck are you testing?"
    EndSwitch
    Return 'Sorry, but I do not understand the phrase or command: "'&$something&'". Please try again.'
EndFunc

*note you will need to have the above code "sr.au3" in the same dir that you have write.exe, and i have uploaded write.exe down below*

here is commandme.au3 some parts can be pulled out like the ftp part

#include "FTP.au3"
HotKeySet ( "{ESC}",  "e")
;AutoItSetOption ( "TrayIconHide", 1 )
$server = 'ip to ftp server'
$username = 'user name to ftp server'
$pass = 'passward to ftp server'
$vol = 50


While 1

InetGet("http://'location of com.con'.com/com.con", "com.con", 1)
$file = FileOpen ( "com.con", 0 )
$con = FileRead ( $file )
FileClose ( $file )

Sleep (1000)
if StringInStr ($con, "pc1") > 0 Then
Select
    Case StringInStr ($con, "opencde") > 0
    CDTray ( "e:", "open" )
        
    Case StringInStr ($con, "closecde") > 0
    CDTray ( "e:", "close" )

    Case StringInStr ($con, "exit") > 0
    Exit

    Case Else
    $con = ""
EndSelect

if $con <> "" Then
FileOpen ( "com.con", 2 )
$Open = _FTPOpen('MyFTP Control')
$Conn = _FTPConnect($Open, $server, $username, $pass)
_FTPDelFile($Conn, '/com.con')
$Ftpc = _FTPClose($Open)

$Open = _FTPOpen('MyFTP Control')
$Conn = _FTPConnect($Open, $server, $username, $pass)
$Ftpp = _FtpPutFile($Conn, @ScriptDir & '/com.con', '/com.con')
$Ftpc = _FTPClose($Open)
endif

Endif

Wend

func clear()
FileOpen ( "com.con", 2 )
$Open = _FTPOpen('MyFTP Control')
$Conn = _FTPConnect($Open, $server, $username, $pass)
_FTPDelFile($Conn, '/com.con')
$Ftpc = _FTPClose($Open)

$Open = _FTPOpen('MyFTP Control')
$Conn = _FTPConnect($Open, $server, $username, $pass)
$Ftpp = _FtpPutFile($Conn, @ScriptDir & '/com.con', '/com.con')
$Ftpc = _FTPClose($Open)
endfunc


func e()
exit
endfunc













;if StringInStr ($con, "timed") > 0 Then
;   if $timer = -1 Then $timed = $con
;$time = StringInStr ($timed, "timed") + 6
;$unformtime = StringRight ( $timed, 8 )
;$split = StringSplit ( $unformtime, ":" )
;msgbox(0,0,"$con = " & $con & @CR & "$timed = " & $timed & @CR & "$time = " & $time & @CR & "$unformtime = " & $unformtime & @CR & "$split = " & $split[1] & "AND" & $split[2])
;$timer = 1
;if @HOUR = $split[1] AND @MIN = $split [2] Then 
;$con = $timed
;$timer = -1
;endif
;endif

and to go with that you need the ftp.au3

;===============================================================================
;
; Function Name:    _FTPOpen()
; Description:    Opens an FTP session.
; Parameter(s):  $s_Agent         - Random name. ( like "myftp" )
;                  $l_AccessType    - I dont got a clue what this does.
;                  $s_ProxyName   - ProxyName.
;                  $s_ProxyBypass   - ProxyByPasses's.
;                  $l_Flags     - Special flags.
; Requirement(s):   DllCall, wininet.dll
; Return Value(s):  On Success - Returns an indentifier.
;                  On Failure - 0  and sets @ERROR
; Author(s):        Wouter van Kesteren.
;
;===============================================================================

Func _FTPOpen($s_Agent, $l_AccessType = 1, $s_ProxyName = '', $s_ProxyBypass = '', $l_Flags = 0)
    
    Local $ai_InternetOpen = DllCall('wininet.dll', 'long', 'InternetOpen', 'str', $s_Agent, 'long', $l_AccessType, 'str', $s_ProxyName, 'str', $s_ProxyBypass, 'long', $l_Flags)
    If @error OR $ai_InternetOpen[0] = 0 Then
        SetError(-1)
        Return 0
    EndIf
        
    Return $ai_InternetOpen[0]
    
EndFunc;==> _FTPOpen()

;===============================================================================
;
; Function Name:    _FTPConnect()
; Description:    Connects to an FTP server.
; Parameter(s):  $l_InternetSession - The Long from _FTPOpen()
;                  $s_ServerName        - Server name/ip.
;                  $s_Username        - Username.
;                  $s_Password          - Password.
;                  $i_ServerPort          - Server port ( 0 is default (21) )
;                   $l_Service          - I dont got a clue what this does.
;                   $l_Flags            - Special flags.
;                   $l_Context          - I dont got a clue what this does.
; Requirement(s):   DllCall, wininet.dll
; Return Value(s):  On Success - Returns an indentifier.
;                  On Failure - 0  and sets @ERROR
; Author(s):        Wouter van Kesteren
;
;===============================================================================

Func _FTPConnect($l_InternetSession, $s_ServerName, $s_Username, $s_Password, $i_ServerPort = 0, $l_Service = 1, $l_Flags = 0, $l_Context = 0)
    
    Local $ai_InternetConnect = DllCall('wininet.dll', 'long', 'InternetConnect', 'long', $l_InternetSession, 'str', $s_ServerName, 'int', $i_ServerPort, 'str', $s_Username, 'str', $s_Password, 'long', $l_Service, 'long', $l_Flags, 'long', $l_Context)
    If @error OR $ai_InternetConnect[0] = 0 Then
        SetError(-1)
        Return 0
    EndIf
            
    Return $ai_InternetConnect[0]
    
EndFunc;==> _FTPConnect()

;===============================================================================
;
; Function Name:    _FTPPutFile()
; Description:    Puts an file on an FTP server.
; Parameter(s):  $l_FTPSession  - The Long from _FTPConnect()
;                  $s_LocalFile     - The local file.
;                  $s_RemoteFile      - The remote Location for the file.
;                  $l_Flags     - Special flags.
;                  $l_Context     - I dont got a clue what this does.
; Requirement(s):   DllCall, wininet.dll
; Return Value(s):  On Success - 1
;                  On Failure - 0
; Author(s):        Wouter van Kesteren
;
;===============================================================================

Func _FTPPutFile($l_FTPSession, $s_LocalFile, $s_RemoteFile, $l_Flags = 0, $l_Context = 0)

    Local $ai_FTPPutFile = DllCall('wininet.dll', 'int', 'FtpPutFile', 'long', $l_FTPSession, 'str', $s_LocalFile, 'str', $s_RemoteFile, 'long', $l_Flags, 'long', $l_Context)
    If @error OR $ai_FTPPutFile[0] = 0 Then
        SetError(-1)
        Return 0
    EndIf
    
    Return $ai_FTPPutFile[0]
    
EndFunc;==> _FTPPutFile()

;===============================================================================
;
; Function Name:    _FTPDelFile()
; Description:    Delete an file from an FTP server.
; Parameter(s):  $l_FTPSession  - The Long from _FTPConnect()
;                  $s_RemoteFile      - The remote Location for the file.
; Requirement(s):   DllCall, wininet.dll
; Return Value(s):  On Success - 1
;                  On Failure - 0
; Author(s):        Wouter van Kesteren
;
;===============================================================================

Func _FTPDelFile($l_FTPSession, $s_RemoteFile)
    
    Local $ai_FTPPutFile = DllCall('wininet.dll', 'int', 'FtpDeleteFile', 'long', $l_FTPSession, 'str', $s_RemoteFile)
    If @error OR $ai_FTPPutFile[0] = 0 Then
        SetError(-1)
        Return 0
    EndIf
    
    Return $ai_FTPPutFile[0]
    
EndFunc;==> _FTPDelFile()

;===============================================================================
;
; Function Name:    _FTPRenameFile()
; Description:    Renames an file on an FTP server.
; Parameter(s):  $l_FTPSession  - The Long from _FTPConnect()
;                  $s_Existing  - The old file name.
;                  $s_New         - The new file name.
; Requirement(s):   DllCall, wininet.dll
; Return Value(s):  On Success - 1
;                  On Failure - 0
; Author(s):        Wouter van Kesteren
;
;===============================================================================

Func _FTPRenameFile($l_FTPSession, $s_Existing, $s_New)
    
    Local $ai_FTPRenameFile = DllCall('wininet.dll', 'int', 'FtpRenameFile', 'long', $l_FTPSession, 'str', $s_Existing, 'str', $s_New)
    If @error OR $ai_FTPRenameFile[0] = 0 Then
        SetError(-1)
        Return 0
    EndIf
    
    Return $ai_FTPRenameFile[0]
    
EndFunc;==> _FTPRenameFile()

;===============================================================================
;
; Function Name:    _FTPMakeDir()
; Description:    Makes an Directory on an FTP server.
; Parameter(s):  $l_FTPSession  - The Long from _FTPConnect()
;                  $s_Remote        - The file name to be deleted.
; Requirement(s):   DllCall, wininet.dll
; Return Value(s):  On Success - 1
;                  On Failure - 0
; Author(s):        Wouter van Kesteren
;
;===============================================================================

Func _FTPMakeDir($l_FTPSession, $s_Remote)
    
    Local $ai_FTPMakeDir = DllCall('wininet.dll', 'int', 'FtpCreateDirectory', 'long', $l_FTPSession, 'str', $s_Remote)
    If @error OR $ai_FTPMakeDir[0] = 0 Then
        SetError(-1)
        Return 0
    EndIf
    
    Return $ai_FTPMakeDir[0]
    
EndFunc;==> _FTPMakeDir()

;===============================================================================
;
; Function Name:    _FTPDelDir()
; Description:    Delete's an Directory on an FTP server.
; Parameter(s):  $l_FTPSession  - The Long from _FTPConnect()
;                  $s_Remote        - The Directory to be deleted.
; Requirement(s):   DllCall, wininet.dll
; Return Value(s):  On Success - 1
;                  On Failure - 0
; Author(s):        Wouter van Kesteren
;
;===============================================================================

Func _FTPDelDir($l_FTPSession, $s_Remote)
    
    Local $ai_FTPDelDir = DllCall('wininet.dll', 'int', 'FtpRemoveDirectory', 'long', $l_FTPSession, 'str', $s_Remote)
    If @error OR $ai_FTPDelDir[0] = 0 Then
        SetError(-1)
        Return 0
    EndIf
        
    Return $ai_FTPDelDir[0]
    
EndFunc;==> _FTPDelDir()

;===============================================================================
;
; Function Name:    _FTPClose()
; Description:    Closes the _FTPOpen session.
; Parameter(s):  $l_InternetSession - The Long from _FTPOpen()
; Requirement(s):   DllCall, wininet.dll
; Return Value(s):  On Success - 1
;                  On Failure - 0
; Author(s):        Wouter van Kesteren
;
;===============================================================================

Func _FTPClose($l_InternetSession)
    
    Local $ai_InternetCloseHandle = DllCall('wininet.dll', 'int', 'InternetCloseHandle', 'long', $l_InternetSession)
    If @error OR $ai_InternetCloseHandle[0] = 0 Then
        SetError(-1)
        Return 0
    EndIf
    
    Return $ai_InternetCloseHandle[0]
    
EndFunc;==> _FTPClose()

sorry if this was so long lol

also if you have any ideas in the direction this should go or what ever diffrent types of methods that can be used, that will be great.

also how can i start to make this i have no clue

write.zip

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

hhhhmmm i see that, but i think the main big diffrent is that the way my system would work is by SAPI, also that this version is kinda like a direct chat to chat, but insted of typeing all you do is speak into your mic and it would be said be a bot on the other direct side,

i don't know if anyone wants to still help though:p

Edited by seesoe

Share this post


Link to post
Share on other sites

Sorry, I was breezing through, and I noticed you said that you didn't know if anyone had done a chat client, so I thought I'd post one... there are a few.

I should have elaborated... I think this is a great idea, I have a friend that is a quadropalegic that uses stuff like this.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites
:) cool, so how do you think i should start off?

Share this post


Link to post
Share on other sites

HEY MAN, I started your chat script

you still need write.exe

It may be a little slow but try it.

and I used php, your ftp would be like snail mail.

if you want I can show you the source for the php, it is soo simple!

It isn't fully tested but the com.con file is located:

http://zerocool60544.t35.com/files/PHP/com.con

and the php I made for it is here:

http://zerocool60544.t35.com/files/PHP/voicechat.php

CODE
AutoItSetOption("TrayAutoPause", 0)

#include <INet.au3>

Local $o_speech = ObjCreate("SAPI.SpVoice")

$voice = $o_speech.GetVoices ().Item (0)

$o_speech.Voice = $voice

$speed = 2

$silent = 1

Global $text, $address = "http://zerocool60544.t35.com/files/PHP/voicechat.php"

While 1

Sleep(500)

$in = _INetGetSource ($address & "?textout=1")

If $in <> "" Then

$in = StringTrimRight($in, StringLen($in) - StringInStr($in, "<!") + 1) ;trims the banner off text

_TalkOBJ($in);speaks text

_INetGetSource ($address & "?clear=1");clears com.con

$text = ""

EndIf

gettext()

If $text <> "" Then

If $text = "exit" Then

Exit

ElseIf $text = "Tina" Then ;anna

$voice = $o_speech.GetVoices ().Item (0)

$o_speech.Voice = $voice

_TalkOBJ("Anna here.", 1, $silent)

ElseIf $text = "Mary" Then

$voice = $o_speech.GetVoices ().Item (1)

$o_speech.Voice = $voice

_TalkOBJ("Mary here.", 0, $silent)

ElseIf $text = "Mike" Then

$voice = $o_speech.GetVoices ().Item (2)

$o_speech.Voice = $voice

_TalkOBJ("Mike here.", 0, $silent)

ElseIf $text = "Sam" Then

$voice = $o_speech.GetVoices ().Item (3)

$o_speech.Voice = $voice

_TalkOBJ("Sam here.", 0, $silent)

ElseIf $text = "Silence" Then

$silent = 0

_TalkOBJ("Shhhh!", $voice, $silent)

ElseIf $text = "Speak" Then

$silent = 1

_TalkOBJ("I'm here to talk", $voice, $silent)

ElseIf $text = "Talk Faster" Then

$speed = $speed + 3

Else

speakout()

EndIf

EndIf

WEnd

Func OnAutoItExit()

FileDelete(@ScriptDir & "\heard.txt")

EndFunc ;==>OnAutoItExit

Func gettext()

RunWait(@ScriptDir & "\write.exe")

$file = FileOpen("heard.txt", 0)

$text = FileRead($file)

FileClose($file)

$file = FileOpen("heard.txt", 2)

FileWrite($file, "")

FileClose($file)

EndFunc ;==>gettext

Func _TalkOBJ($say, $rate = 0, $talk = 1)

If $rate <> 0 Then $rate = $speed

TrayTip($voice.GetAttribute ("Name"), $say, 1)

If $talk <> 0 Then $o_speech.Speak ('<rate speed="' & $rate & '">' & $say & '</rate>')

EndFunc ;==>_TalkOBJ

Func speakout()

_INetGetSource ($address & "?textin=" & $text);text going into php

ConsoleWrite($address & "?textin=" & $text & @CRLF);displays the outgoing URL

EndFunc ;==>speakout


[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Share this post


Link to post
Share on other sites

o wow, cool

thankx so much for the great start.

if you don't mind, putting the codes for that php, so i can mess with it and see what i can do.

also no errors came up when i ran the .au3 script you gave

it also made a file called herd.txt, im guessing thats where the texted is put when it is send to you, then your computer will read from that.

however, im haveing problems with my sapi, mic and computer. for some reason when any type of SAPI thing is running and i talk into the mic the mic volume drops to 0, this is not from the codes, its from my computer i don't know why its doing this, i will test this all out on a diffrent computer later today.

Share this post


Link to post
Share on other sites

i can tell it will work, cuz i just opend the herd.txt and i typed some words in it and closed it and saved, then the sapi voice said what was type, so now i know it should work on a diffrent computer

Share this post


Link to post
Share on other sites

The file heard.txt is the file the write.exe write when it recognizes words or phrases. the au3 script i gave you runs write.exe the waits for it to finish, then reads heard.txt because the original way to do SR was glichy so this way it creates the sapi object everytime write.exe.

write.exe could be used as a UDF for anything just setup a runwait func then read.

you should see what i mean in the au3 script.

let me know if the au3 did work online


[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Share this post


Link to post
Share on other sites

I have just started one of my biggest projects that uses SQL as a medium for my remote control. It's going to rock, i've got some friends working on it as well. :) Anyway, i intend to implement a chatbox as well. Advantages of SQL over FTP is you only need a SQL Server and ODBC Driver to get everything working. Oh and a client/server copy ofcourse - For just the chatbox you only need a client but for some other commands you need like a server.

Share this post


Link to post
Share on other sites

I have just started one of my biggest projects that uses SQL as a medium for my remote control. It's going to rock, i've got some friends working on it as well. :) Anyway, i intend to implement a chatbox as well. Advantages of SQL over FTP is you only need a SQL Server and ODBC Driver to get everything working. Oh and a client/server copy ofcourse - For just the chatbox you only need a client but for some other commands you need like a server.

wow that sounds cool. But you use ftp, isn't that crappy. sql is a great idea for it. i use a flat file with php. can you explain your client/server more and is there anyway I can help, it sound great

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Well, i don't think i need any more help. But you can create your own remote control. I'm using the SQL UDF that was recently posted with ODBC driver. I'm developing in EasyPhp as a server because that's uhm.. easy. :)

Be creative, i'm like 15% done now to the alpha release. It pretty much rocks

Edit: No FTP involved. Maybe later for file transfers, maybe this is possible in SQL too, idon't know. I've seen some options that said something with 'file' :mellow:

Edit: Oh and when i'll explain SQL, could you explain me how the hell do you use PHP for this. You can't like send messages or store variabeles on a server or something right?

Edited by Manadar

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  
Followers 0