It is currently April 26th, 2024, 4:57 am

Vbs. Script

Get help with creating, editing & fixing problems with skins
Executieve Assassin
Posts: 7
Joined: December 29th, 2014, 8:49 am
Location: Perth Western Australia

Vbs. Script

Post by Executieve Assassin »

Hi All,

It seems that Rainmeter does not support Vbs. Scripts either that or I am doing something wrong. (good possibility) Just wondering if there is a way around this somehow ?

What I am trying to achieve is a simple button that when clicked, the computers narrator will read the Vbs.script file. Relatively simple idea but I am having issues getting around it.

I would appreciate some assistance if possible. Thanking you in advance :)
User avatar
jsmorley
Developer
Posts: 22630
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Vbs. Script

Post by jsmorley »

Should work fine.

Speak.vbs:

Code: Select all

Dim speaks, speech
speaks=WScript.Arguments.Item(0)
Set speech=CreateObject("sapi.spvoice")
speech.Speak speaks
Speak.ini:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[MeasureName]
Measure=Plugin
Plugin=SysInfo
SysInfoType=USER_NAME

[MeterSpeak]
Meter=String
FontSize=11
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Say Hello
LeftMouseUpAction=["#CURRENTPATH#Speak.vbs" "Hello [MeasureName]"]
DynamicVariables=1
Or:

Speak.vbs:

Code: Select all

Dim speaks, speech
speaks="Two roads diverged in a yellow wood, And sorry I could not travel both And be one traveler, long I stood And looked down one as far as I could To where it bent in the undergrowth; Then took the other, as just as fair, And having perhaps the better claim, Because it was grassy and wanted wear; Though as for that the passing there Had worn them really about the same, And both that morning equally lay In leaves no step had trodden black. Oh, I kept the first for another day! Yet knowing how way leads on to way, I doubted if I should ever come back. I shall be telling this with a sigh Somewhere ages and ages hence: Two roads diverged in a wood, and I took the one less traveled by, And that has made all the difference."
Set speech=CreateObject("sapi.spvoice")
speech.Speak speaks
Speak.ini:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[MeterPoem]
Meter=String
FontSize=11
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=The Road Not Taken
LeftMouseUpAction=["#CURRENTPATH#Speak.vbs"]
Executieve Assassin
Posts: 7
Joined: December 29th, 2014, 8:49 am
Location: Perth Western Australia

Re: Vbs. Script

Post by Executieve Assassin »

Nice Job Champ. Not sure what I was doing wrong lack of sleep or to much alcohol who knows:)

would the "playstop" function work in stopping the script being read ?
any ideas on how best to achieve that ?

I'm hoping to post my counter terrorism information skin by the start of feb.
User avatar
jsmorley
Developer
Posts: 22630
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Vbs. Script

Post by jsmorley »

Executieve Assassin wrote:Nice Job Champ. Not sure what I was doing wrong lack of sleep or to much alcohol who knows:)

would the "playstop" function work in stopping the script being read ?
any ideas on how best to achieve that ?

I'm hoping to post my counter terrorism information skin by the start of feb.
No, nothing to do with Rainmeter once you launch the .vbs script. I think the best you could do would be to use some command line utility to kill the wscript.exe process while it is executing.

Here is one you could use:
StopScript.zip
It's a simple AutoIt app I just knocked out:

Code: Select all

While ProcessExists('wscript.exe')
	ProcessClose('wscript.exe')
WEnd

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[MeterPoem]
Meter=String
FontSize=11
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=The Road Not Taken
LeftMouseUpAction=["#CURRENTPATH#Speak.vbs"]

[MeterStop]
Meter=String
Y=3R
FontSize=11
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Stop
LeftMouseUpAction=["#CURRENTPATH#ScriptStop.exe"]
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22630
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Vbs. Script

Post by jsmorley »

BTW, I'm not a big fan of .vbs for this. I'm really not a big fan of .vbs in general...

The issue is that you can only run that script once at a time, or it produces an error trying to initialize the speech functionality in Windows. It's not easy to deal with that, since if you have your action "kill" it, then run it, Rainmeter is just too fast for that to work. It in effect runs both commands; the "kill" and the "launch" as quickly as it can, and before the AutoIt app can "stand itself up" and check for the process, it already exists from the second part of the action, so it happily kills it and the effect is that the .vbs is never executed.

I think you might want to look at this:

http://rainmeter.net/forum/viewtopic.php?p=91761#p91761

as an alternative.