AutoHotkey Community

It is currently May 25th, 2012, 8:40 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: June 16th, 2007, 2:27 pm 
Offline

Joined: April 29th, 2006, 10:31 am
Posts: 29
Location: Sweden
I have a VB-script that triggers the computers speech synthesis and speaks whatever I pass to the script. Now I want to use this from an AHK script but I can't get it to work and I don't know why...

This
Code:
Run, C:\Scripts\speak.vbs, %Name%

(the variable %Name% is not empty and works fine with other commands) gives me

Code:
---------------------------
Windows Script Host
---------------------------
Script:   C:\Scripts\speak.vbs
Line:   4
Char:   1
Error:   Subscript out of range
Code:   800A0009
Source:    Microsoft VBScript runtime error

but writing

Code:
c:\scripts\speak.vbs testing

in a dos prompt works just fine - the word "testing" is spoken.

What am I missing...?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2007, 2:56 pm 
You don't need VBS for that...

TTS() Text To Speech using COM

:wink:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2007, 3:05 pm 
Offline

Joined: April 29th, 2006, 10:31 am
Posts: 29
Location: Sweden
I know there are some AHK scripts for TTS but this VB script is already used by other applications and it would be very nice to use it with AHK as well.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2007, 7:22 pm 
Offline

Joined: April 28th, 2004, 1:12 pm
Posts: 349
Code:
run cscript.exe "%a_workingdir%\test.vbs"


or

Code:
run cmd /c cscript.exe "%a_workingdir%\test.vbs"


The only problem is that the command prompt window shows. You might be able to use use CMDret to avoid that-

CMDret - AHK functions


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2007, 8:05 pm 
The basic scripts should be :
the AHK one :
Code:
VBSScript := "D:\LineCol.vbs"
Line := 10
Row := 24
RunWait, cscript.exe //nologo "%VBSScript%" "%Line%" "%Row%",,Hide

Use RunWait to ... wait for the VBS script to finish to be executed, else use Run.
the Hide parameter ... hide the command prompt window.
The VBS one (LineCol.vbs):
Code:
If WScript.Arguments.Count <> 2 Then
   msgbox "Not OK"
Else
   Line = WScript.Arguments.Item(0)
   Row = WScript.Arguments.Item(1)m(2)
End If

msgbox "Param from command line : " & Line & "," & Row

Thats OK if you don't need to retreive results.
If you need to get back results, you can use CMDret or pass back the result with the clipboard. For that I use the COM DLL of AutoIt, AutoItX.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 17th, 2007, 9:44 am 
Offline

Joined: April 29th, 2006, 10:31 am
Posts: 29
Location: Sweden
Thanks guys,

Code:
Run, c:\windows\system32\cscript.exe c:\scripts\speak.vbs "%Name%",, hide

did the trick.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 17th, 2007, 2:47 pm 
just a few comments :
1) It works too without the need to specify the path of cscript.exe
2) I use the notation "%Name%" for the parameters to be able to send parameters with space in them. If you are shure that there isn't any space character in your parameters, ou can use the notation Name instead (without "% and %"...


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 17th, 2007, 3:00 pm 
Offline

Joined: April 29th, 2006, 10:31 am
Posts: 29
Location: Sweden
Supercalifragilistic wrote:
just a few comments :
1) It works too without the need to specify the path of cscript.exe
2) I use the notation "%Name%" for the parameters to be able to send parameters with space in them. If you are shure that there isn't any space character in your parameters, ou can use the notation Name instead (without "% and %"...

1. It does.
2. There are spaces in %Name%, therefore I use quotation marks.

A follow-up question; is there anyway to trigger an environment variable containing the path to a VB-script? If I run
Code:
%tts% "this is a test"

from a dos prompt, the words are spoken. How to run it from an AHK script?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 17th, 2007, 5:48 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8647
Location: Salem, MA
remove #NoEnv from the top of the script, or you can use EnvGet to get where tts is.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 17th, 2007, 6:12 pm 
Offline

Joined: April 29th, 2006, 10:31 am
Posts: 29
Location: Sweden
I don't have #NoEnv and I still haven't found a way to trigger %tts% from AHK.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 17th, 2007, 6:36 pm 
m1m3r wrote:
A follow-up question; is there anyway to trigger an environment variable containing the path to a VB-script? If I run
Code:
%tts% "this is a test"

from a dos prompt, the words are spoken. How to run it from an AHK script?

I don't understand well what you want. May be it's because I'm not native language english... Please show the full command you enter under dos prompt.
If the question is how to transfert the content of an environnement variable to a vbscript, the answer is : like the others params.
For instance :
Code:
VBSScript := "D:\An example.vbs"
RunWait, cscript.exe //nologo "%VBSScript%" "%A_WinDir%",,Hide

May be I didn't understood your request.

If you want to make the PC speak, try this : AHK script :
Code:
VBSScript := "D:\Speak to me.vbs"
TextToSpeak := "Hello you"
RunWait, cscript.exe //nologo "%VBSScript%" "%TextToSpeak%",,Hide

VBScript :
Code:
Dim say

If WScript.Arguments.Count <> 1 Then
   msgbox "Not OK"
Else
   TextToSpeach = WScript.Arguments.Item(0)
   Set say = CreateObject("SAPI.SpVoice")
   say.speak TextToSpeach
End If


** Not tested ** (As I didn't install text-to-speach on py PC) ... but should work...

Tell me if it's what you whant and if it is OK...


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 17th, 2007, 7:15 pm 
Offline

Joined: April 29th, 2006, 10:31 am
Posts: 29
Location: Sweden
English isn't my native language either... 8)

First, I have this in Windows XP;

http://img338.imageshack.us/my.php?image=image1rv4.jpg

Now, if I enter this;

http://img338.imageshack.us/my.php?image=image2ha4.jpg

the computer's speech synthesis says "this is a test".


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 17th, 2007, 10:08 pm 
I must say I didn't knew the first dialog box you shown, "Edit system variable"
I tried :
Code:
EnvGet, OutputVar, tts
msgbox %OutputVar%
to see if there is an environement variable called tts, it isn't the case.
I seen the (affected ?) value of this variable is the path and the name of your vbs file.
Of course in Windows, if you double click a vbs file, it is executed.
I think that is what is done by :
Code:
%tts% "this is a test"
So what you done via the Run dialog box is the same as to execute your script (c:\scripts\speak.vbs) with "this is a test" as parameter.
Code:
%tts% "this is a test"
is the same as to write in the Window's Run dialog
Code:
c:\scripts\speak.vbs "this is a test"
(It should be usefull to see the content of the VBS script itself...)
But in AHK (as far as I know),
Code:
c:\scripts\speak.vbs "this is a test"
can't work. You must specify the program used to run the vbs file. So to run your script you should write something like that :
Code:
VBSScript := "c:\scripts\speak.vbs"
TextToSpeak := "this is a test"
RunWait, cscript.exe //nologo "%VBSScript%" %TextToSpeak%",,Hide


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 17th, 2007, 10:10 pm 
Hope it helps. I go to sleep. Bye. :D :D :D


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 17th, 2007, 10:13 pm 
I forgot a "
Code:
RunWait, cscript.exe //nologo "%VBSScript%" "%TextToSpeak%",,Hide


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey and 72 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group