'
'  This script uses the Microsoft Agent character Peedy
'  to remind you of an event. You can pass it arguments
'  in the form of quoted strings. The character will
'  display each string and read it aloud, in sequence.
'
'  Examples:
'     peedy.vbs "You have a meeting at 10 o'clock."
'     peedy.vbs "You have a meeting." "It's at 10 o'clock."
'
'  Multiple strings each enclosed in quotation marks
'  will be read in separate steps.
'
'  To run this script, you need to have the Agent
'  software installed, which is free from Microsoft.
'
'  http://www.microsoft.com/msagent/
'
'  As of 19 June 2003, you could download the core
'  components and the Peedy character file from:
'
'  http://www.microsoft.com/msagent/downloads/user.asp
'     Core
'        http://activex.microsoft.com/activex/controls/agent2/MSagent.exe
'     Peedy
'        http://download.microsoft.com/download/a/f/5/af572f68-b83e-4e2c-8b0f-fd5fadf588e7/Peedy.exe
'
'  There are many other animations you can use with the
'  Play() command, including:
'
'      Blink
'      RestPose
'      Alert       - raise eyebrows
'      Uncertain   - shrug
'      Explain     - spread wings
'      Pleased     - teeth sparkle
'      Think       - hand to mouth, look up
'
'  There are also other Agent characters, including:
'
'     Genie
'     Merlin
'     Robby
'
'  They each have their own set of animation commands.
'

Dim agent
Set agent = CreateObject("Agent.Control.2")
agent.Connected = True
agent.Characters.Load "Peedy", "peedy.acs"

Dim peedy
Set peedy = agent.Characters("Peedy")

peedy.LanguageID = &H0409              ' use English

peedy.MoveTo 250, 200
peedy.Show

WaitForRequest peedy.Play("Greet")     ' fly in
WaitForRequest peedy.Play("Announce")  ' message flies in

if (WScript.Arguments.Count = 0) then
   peedy.Speak "Hello! You're supposed to remember something."
else
   for i = 0 to WScript.Arguments.Count - 1
      peedy.Speak WScript.Arguments(i)
   next
end if

WaitForRequest peedy.Play("Wave")
WaitForRequest peedy.Play("Hide")      ' fly off

peedy.Hide

agent.Characters.Unload("Peedy")
agent.Connected = False

'
'  Subroutine that waits for the passed request to complete.
'
sub WaitForRequest(req)
   do while ((req.Status = 2) or (req.Status = 4))
      WScript.Sleep 500
   loop
end sub
