Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using MS Agent WSH VBScript (Sample)

314 views
Skip to first unread message

Ian Morrish

unread,
Aug 6, 1998, 3:00:00 AM8/6/98
to
To run this you will nedd to have the Agent installed. You can get it
from...
http://www.microsoft.com/workshop/c-frame.htm?902348731230#/workshop/imedia/
agent/default.asp

Dim AgentControl
On Error Resume Next
Set AgentControl = CreateObject("Agent.Control.1")
If IsObject(AgentControl) Then 'it loaded ok
AgentControl.Connected = True
Dim merlin
On Error Resume Next
AgentControl.Characters.Load "merlin", "C:\Program Files\Microsoft
Agent\characters\merlin.acs"
set merlin= AgentControl.Characters ("merlin")
merlin.Get "state", "Showing"
merlin.Get "state", "Speaking"
merlin.MoveTo 10, 10
merlin.Show
merlin.Get "state", "Moving"
merlin.MoveTo 257, 177
merlin.Speak ("Isn't it about time you started doing some real work?")
merlin.Hide
End If
wscript.echo "What do you think?"

Regards,
Ian Morrish
http://wsh.glazier.co.nz WSH FAQ
http://ils.glazier.co.nz (NetMeeting)
http://www.glazier.co.nz

Christoph Sperle

unread,
Aug 6, 1998, 3:00:00 AM8/6/98
to
Hi Ian,

Thats really GREAT!!!

I have a lot of fun with this toy (I am afraid, my boss does not). But I've
2 Questions on it:

1. Why does nothing happen, when the last line :"WScript.echo "..." is
deleted?

2. How to connect the Agent-Events.

Thanks,
christoph.

Ian Morrish schrieb in Nachricht ...

Matt Sinkovits

unread,
Aug 6, 1998, 3:00:00 AM8/6/98
to
Hi Ian,

Extremely Cool, thanks for pointing out and sharing this technology. I can
see a lot of uses for this agent technology.


Matt Sinkovits


Ian Morrish wrote in message ...

Ian Morrish

unread,
Aug 7, 1998, 3:00:00 AM8/7/98
to
The Agent requires a container. This is normally the browser. If you remove
the echo from the script the agent is destroyed when the script finishes
execution.
A way around this would be to sit in a loop waiting for an agent event which
you would define in a sub.
I'll work on an example...Christoph Sperle wrote in message ...

>Hi Ian,
>
>Thats really GREAT!!!
>
>I have a lot of fun with this toy (I am afraid, my boss does not). But I've
>2 Questions on it:
>
>1. Why does nothing happen, when the last line :"WScript.echo "..." is
>deleted?
>
>2. How to connect the Agent-Events.
>
>Thanks,
>christoph.
>
>Ian Morrish schrieb in Nachricht ...

Ian Morrish

unread,
Aug 8, 1998, 3:00:00 AM8/8/98
to
I just found this cool application for creating Agent scripts...
http://www.bellcraft.com/mash.html

Ian Morrish
WSH FAQ http://wsh.glazier.co.nz
Home page http://www.glazier.co.nz
NetMeeting http://ils.glazier.co.nz
callto:ils.glazier.co.nz/i...@glazier.co.nz
Ian Morrish wrote in message ...

Marc Rosenberg

unread,
Aug 10, 1998, 3:00:00 AM8/10/98
to
I was playing around with progress bars for long copy procedures (I use WSH
to make backups) and Ian's post gave me a better idea.

I combined Ian's sample along with the pause function from
http://sams.prohosting.com/cwashington/scripts/vbscripts/index.html
to use Merlin (the agent) as a progress indicator for a file copy procedure.
Merlin pops up to tell you the copy is in progress and waits around to let
you know when it is finished.

Thanks!!!

Here's the code....

Set WSHShell = WScript.CreateObject("WScript.Shell")
Set fs = CreateObject("Scripting.FileSystemObject")

' set d to a: drive and check if a disk is inserted
Set d = fs.GetDrive("a:")
Do while d.IsReady = false
test=msgbox("Please insert a disk in Drive A:",1,"Drive Not Ready")
If test = vbCancel Then WScript.Quit
loop
' Ian Morrish's code sample to set Merlin into action


Dim AgentControl
On Error Resume Next
Set AgentControl = CreateObject("Agent.Control.1")
If IsObject(AgentControl) Then 'it loaded ok
AgentControl.Connected = True
Dim merlin
On Error Resume Next
AgentControl.Characters.Load "merlin", "C:\Program Files\Microsoft
Agent\characters\merlin.acs"
set merlin= AgentControl.Characters ("merlin")
merlin.Get "state", "Showing"
merlin.Get "state", "Speaking"
merlin.MoveTo 10, 10
merlin.Show

merlin.Speak ("Copying myfile")


merlin.Get "state", "Moving"
merlin.MoveTo 257, 177

End If

' copy the file to a:

Fs.CopyFile "c:\My Documents\myfile.txt", "A:\"

' execution will continue here after copy is complete
merlin.Speak ("Copy complete!")

' pause (from Clarence Washington) function
' to allow the last speak to complete
pause(3)

Function Pause(x)
StartTime = cint(second(time))
i = 0
Do
i = i + 1
loop While cint(second(time)) < StartTime + cint(x)
End Function

0 new messages