Sign in to follow this  
Followers 0
RazerM

Error Help

4 posts in this topic

here is my script

#NoTrayIcon
#include <GUIConstants.au3>
Dim $voice = ObjCreate("Sapi.SpVoice")
$Error = ObjEvent("AutoIt.Error","ErrFunc")
GUICreate("Microsoft Sam", 600, 500) 
$text = GUICtrlCreateInput("Text to speak", 10, 10, 580, 50, $ES_MULTILINE)
$speak = GUICtrlCreateButton("Speak", 10, 65)
GUICtrlCreateGroup("Options", 10, 100, 580, 170)
$rate = GUICtrlCreateSlider(20, 150, 280, 30, $TBS_TOP + $TBS_AUTOTICKS)
GUICtrlSetLimit($rate, 50, -50)
GUICtrlSetData($rate, 0)
$volume = GUICtrlCreateSlider(300, 150, 280, 30, $TBS_TOP+ $TBS_AUTOTICKS)
GUICtrlSetLimit($volume, 100, 1)
GUICtrlSetData($volume, 100)
GUICtrlCreateLabel("Slow", 20, 185)
GUICtrlCreateLabel("Normal", 140, 185)
GUICtrlCreateLabel("Fast", 270, 185)
GUICtrlCreateLabel("Quiet", 310, 185)
GUICtrlCreateLabel("Loud", 550, 185)
GUICtrlCreateLabel("Voice:", 20, 233)
$voiceC = GUICtrlCreateCombo("Microsoft Sam", 60, 230, 100)
GUICtrlSetData($voiceC, "Microsoft Mike|Microsoft Mary|LH Michael|LH Michelle")
GUISetState()

While 1
    SetExtended(1)
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $speak
            Speak(GUICtrlRead($text), GUICtrlRead($voiceC), GUICtrlRead($rate)/10, GUICtrlRead($volume))
    EndSwitch
WEnd

Func Speak($Text, $SapiVoice, $Rate = 1, $Vol = 100)
$voice.Rate = $Rate
$voice.Volume = $Vol
$voice.Voice = $voice.GetVoices("Name=" & $SapiVoice, "Language=409").Item(0)
$voice.Speak($Text)
EndFunc

Func ErrFunc()
    MsgBox(48, "Error","This machine doesn't have " & GUICtrlRead($voiceC) & " installed")
EndFunc

I had to add an ObjEvent to stop my program quitting if the selected voice isn't installed on that computer. How do i stop the MsgBox in ErrFunc from appearing twice?


My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites



#NoTrayIcon
#include <GUIConstants.au3>
Dim $voice = ObjCreate("Sapi.SpVoice")
$Error = ObjEvent("AutoIt.Error", "ErrFunc")
GUICreate("Microsoft Sam", 600, 500)
$text = GUICtrlCreateInput("Text to speak", 10, 10, 580, 50, $ES_MULTILINE)
$speak = GUICtrlCreateButton("Speak", 10, 65)
GUICtrlCreateGroup("Options", 10, 100, 580, 170)
$rate = GUICtrlCreateSlider(20, 150, 280, 30, $TBS_TOP + $TBS_AUTOTICKS)
GUICtrlSetLimit($rate, 50, -50)
GUICtrlSetData($rate, 0)
$volume = GUICtrlCreateSlider(300, 150, 280, 30, $TBS_TOP + $TBS_AUTOTICKS)
GUICtrlSetLimit($volume, 100, 1)
GUICtrlSetData($volume, 100)
GUICtrlCreateLabel("Slow", 20, 185)
GUICtrlCreateLabel("Normal", 140, 185)
GUICtrlCreateLabel("Fast", 270, 185)
GUICtrlCreateLabel("Quiet", 310, 185)
GUICtrlCreateLabel("Loud", 550, 185)
GUICtrlCreateLabel("Voice:", 20, 233)
$voiceC = GUICtrlCreateCombo("Microsoft Sam", 60, 230, 100)
GUICtrlSetData($voiceC, "Microsoft Mike|Microsoft Mary|LH Michael|LH Michelle")
GUISetState()
;~ SetExtended(1)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $speak
            Speak(GUICtrlRead($text), GUICtrlRead($voiceC), GUICtrlRead($rate) / 10, GUICtrlRead($volume))
    EndSwitch
WEnd

Func Speak($text, $SapiVoice, $rate = 1, $Vol = 100)
    $voice.Rate = $rate
    If @error Then Return
    $voice.Volume = $Vol
    If @error Then Return
    Local $t_voice = $voice.GetVoices ("Name=" & $SapiVoice, "Language=409").Item (0)
    If @error Then Return
    $voice.Voice = $t_voice
    If Not @error Then $voice.Speak ($text)
EndFunc  ;==>Speak

Func ErrFunc()
    MsgBox(48, "Error", "This machine doesn't have " & GUICtrlRead($voiceC) & " installed")
    SetError(1)
EndFunc  ;==>ErrFunc


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Thank you


My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites

Thank you

yw

btw, these 2 lines were generating the 2 error messages

$voice.Voice = $voice.GetVoices("Name=" & $SapiVoice, "Language=409").Item(0)
$voice.Speak($Text)

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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