Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Start VB-script with parameter


  • Please log in to reply
25 replies to this topic
m1m3r
  • Members
  • 29 posts
  • Last active: Mar 08 2012 08:59 PM
  • Joined: 29 Apr 2006

I must say I didn't knew the first dialog box you shown, "Edit system variable"

I was unclear - I've added this variable myself.

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.

Correct.

So to run your script you should write something like that :

VBSScript := "c:\scripts\speak.vbs"
TextToSpeak := "this is a test"
RunWait, cscript.exe //nologo "%VBSScript%" %TextToSpeak%",,Hide

Which is pretty much the way I'm already doing it. What I would like to know is if there's any way to use a custom system variable something like this;

ExecuteSystemVariable, TTS "%name%"


m1m3r
  • Members
  • 29 posts
  • Last active: Mar 08 2012 08:59 PM
  • Joined: 29 Apr 2006

It should be usefull to see the content of the VBS script itself...

Dim voic
Dim intValue

intValue = Wscript.Arguments.Item(0)
Set voic = WScript.CreateObject("SAPI.SpVoice")
Set voic.voice = voic.GetVoices("", "Language=809").Item(0)
voic.Speak("" + intValue + "")
Set voic = nothing


engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
like I said, EnvGet...
EnvGet, tts, tts

then you can use %tts% anywhere

m1m3r
  • Members
  • 29 posts
  • Last active: Mar 08 2012 08:59 PM
  • Joined: 29 Apr 2006

like I said, EnvGet...

EnvGet, tts, tts

then you can use %tts% anywhere

envget, tts, tts
name="this is a test"

run, %tts%, "%name%"
gives me the same error from the vbscript as in my first post... :(

engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
envget, tts, tts
name=this is a test

run, %tts%, "%name%"


:?:

m1m3r
  • Members
  • 29 posts
  • Last active: Mar 08 2012 08:59 PM
  • Joined: 29 Apr 2006
Same result...

engunneer
  • Moderators
  • 9162 posts
  • Last active: Sep 12 2014 10:36 PM
  • Joined: 30 Aug 2005
I was blind - the problem is obvious now that I see it

envget, tts, tts
name= this is a test

run, %tts% "%name%"

no Comma!, the comma made %name% the working directory, which is less useful.

Supercalifragilistic
  • Guests
  • Last active:
  • Joined: --

What I would like to know is if there's any way to use a custom system variable something like this;

ExecuteSystemVariable, TTS "%name%"

Sorry I don't know the answer to that question. I hope that engunneer gave you the answer you was waiting for.
Just an other thing :
By doing like this (generate the VBS file from AHK and execute it), you haven't to transmit parameter :
VBSScript := "c:\scripts\speak.vbs"
intValue := "this is a test"

VBSfile =
(Join`n
Dim voic
Dim intValue

Set voic = WScript.CreateObject("SAPI.SpVoice")
Set voic.voice = voic.GetVoices("", "Language=809").Item(0)
voic.Speak("%intValue%")
Set voic = nothing
)

IfExist, %VBSScript%
FileDelete, %VBSScript%
FileAppend, %VBSfile%, %VBSScript%
RunWait, cscript.exe //nologo %VBSScript%,,Hide
FileDelete, %VBSScript%


m1m3r
  • Members
  • 29 posts
  • Last active: Mar 08 2012 08:59 PM
  • Joined: 29 Apr 2006

I was blind - the problem is obvious now that I see it

envget, tts, tts
name= this is a test

run, %tts% "%name%"

no Comma!, the comma made %name% the working directory, which is less useful.

I've tried all variations of comma placement, if I omit the comma after %tts% I get;

Error: Failed attempt to launch program or document:
Action: <c:\scripts\speak.vbs "his is a test">
Params: <>

The current thread will exit.

Specifically: The system cannot find the file specified.

	Line#
	001: EnvGet,tts,TTS
	002: name = "this is a test"
--->  004: Run,%tts% "%name%"
	005: Exit


m1m3r
  • Members
  • 29 posts
  • Last active: Mar 08 2012 08:59 PM
  • Joined: 29 Apr 2006

What I would like to know is if there's any way to use a custom system variable something like this;

ExecuteSystemVariable, TTS "%name%"

Sorry I don't know the answer to that question. I hope that engunneer gave you the answer you was waiting for.
Just an other thing :
By doing like this (generate the VBS file from AHK and execute it), you haven't to transmit parameter :
VBSScript := "c:\scripts\speak.vbs"
intValue := "this is a test"

VBSfile =
(Join`n
Dim voic
Dim intValue

Set voic = WScript.CreateObject("SAPI.SpVoice")
Set voic.voice = voic.GetVoices("", "Language=809").Item(0)
voic.Speak("%intValue%")
Set voic = nothing
)

IfExist, %VBSScript%
FileDelete, %VBSScript%
FileAppend, %VBSfile%, %VBSScript%
RunWait, cscript.exe //nologo %VBSScript%,,Hide
FileDelete, %VBSScript%

Will try it later today.

I believe most Windows computers come with at least Microsoft Sam as speech synthesis so if you want you can make a VB script like mine and give it a try.

Ian
  • Guests
  • Last active:
  • Joined: --
Heya,
I have the following codeing in a .vbs file.

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "C:\Test.exe" & Chr(34), 0
Set WshShell = Nothing

Running this code excutes the test.exe hiding the promopt but without 3 paramters the exe fails. Normally this could be passed by a .bat or shortcut such as

Shortcut "C:\Test.exe" 10 1024 1024
Bat Start C:\Test.exe 10 1024 1024.

Could anyone tell me how i could put these 3 numbers into the vbs coding so my .exe will work.