| :: How to use Microsoft Agents with a Web Site |
Author |
David Costelloe |
Language |
VB Script |
Operating
Systems |
Windows 95, 98 and NT |
| Example |
| ** Click here to go to David's example page ** |
| HTML |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<!-- These Pages are copyright (c), 1999-2000 Welford-Costelloe Consultants Inc
-->
<head>
<meta http-equiv="Content-Language" content="en-us">
<script LANGUAGE="VBScript">
<!--
Option Explicit
dim Peedy '* Holds Peedy
Object
dim Robby '* Holds Robby
Object
dim Merlin '* Holds Merlin
Object
dim Genie '* Holds Genie
Object
dim ScrLeft '* Holds X
coordinates
dim ScrTop '* Holds Y
Coordinates
dim GenieRequest '* Holds
Genie Requests
dim MerlinRequest '* Holds
Merlin Requests
dim PeedyRequest '* Holds
Peedy Requests
dim RobbyRequest '* Holds
Robby Requests
dim UserName '* Holds the
Name entered
dim AgentName '* Used to hold
the current AgentName
dim LoadMerlin '* Holds the
load from internet
dim LoadRobby '* holds the
local file ok
dim LoadGenie '* holds the
local file ok
dim LoadPeedy '* Holds the
load from internet
dim ObjName '* Holds the name
ID of the object
Sub MerlinWelcome()
If Merlin.Visible = False Then
Merlin.Show
End If
ScrLeft = (window.event.screenX - window.event.clientX)
ScrTop = (window.event.screenY - window.event.clientY)
Merlin.MoveTo ScrLeft, ScrTop
Merlin.Play "Explain"
Merlin.Speak "Hello " & UserName
Merlin.Speak "My name is \Emp\Merlin."
Merlin.Speak "and I am your host for today."
Merlin.Play "Surprised"
Merlin.Speak "Please check out the newest member \Emp\Peedy!"
ScrLeft = (window.event.screenX - window.event.clientX) _
+ (Meet_Agents.offsetleft)+ 140
ScrTop = (window.event.screenY - window.event.clientY) +
(Meet_Agents.offsettop)
Merlin.MoveTo ScrLeft, ScrTop
Merlin.Play "GestureRight"
Merlin.Speak "Click the button \Emp\Meet all the agents!"
Merlin.Play "Wave"
Merlin.Speak "Thank you once again for visiting."
Merlin.Speak "Enjoy our site!"
Merlin.Hide
end sub
Sub MerlinOnly()
On Error Resume Next
If Merlin.Visible = False Then
Merlin.Show
End If
Merlin.Speak "One moment Please.."
ScrLeft = (window.event.screenX - window.event.clientX)
ScrTop = (window.event.screenY - window.event.clientY)
Merlin.MoveTo ScrLeft, ScrTop
Merlin.Get "Animation", "Announce, Pleased,Wave,Explain,
GestureDown"
Status = "Locating Merlin's animations."
Merlin.Play "Announce"
Merlin.Speak "Thank you for visiting Welford-Costelloe Consultants
Inc Web Site."
ScrLeft = (window.event.screenX - window.event.clientX) _
+ (FrontPage_Form2.offsetleft) + 140
ScrTop = (window.event.screenY - window.event.clientY) +
(FrontPage_Form2.offsettop)
Merlin.MoveTo ScrLeft, ScrTop
Status = "Getting Merlin's next coordinates"
Merlin.Get "Animation", "GestureLeft"
Merlin.Play "GestureLeft"
Merlin.Speak "Please Enter your Name in the text box, " &
_
"and then Click the continue Button!"
Merlin.Speak "I will Leave, and await your entry."
Merlin.Hide
Status = "Done."
end sub
Sub Show_Agents_OnClick()
On Error Resume Next
If Merlin.Visible = True Then
Merlin.StopAll
End If
call LoadIntro()
end sub
'* Declare Variables
Sub LoadIntro()
If Not Merlin.Visible = True Then
Merlin.Show
End If
ScrLeft = (window.event.screenX - window.event.clientX)
ScrTop = (window.event.screenY - window.event.clientY)
Merlin.MoveTo ScrLeft, ScrTop
Merlin.Speak "Hello! | Hi There! | Good Day to you! | Its a grand
day! " & UserName
Merlin.Get "Animation","Announce,Blink,Pleased,
Explain"
Merlin.Play "Announce"
Merlin.Speak "We have good news!"
Merlin.Play "Pleased"
Merlin.Speak "I would like to introduce to you all The "
& _
"New Welford-Costelloe Consultants Inc.
Web Site."
Merlin.Play "Blink"
Merlin.Get "Animation", "Explain"
Merlin.Play "Explain"
Merlin.Speak "\Emp\" & UserName & " We have
among us\Pau=400\a " & _
"new, \Emp\ member and Microsoft
Agent!"
Set MerlinRequest = Merlin.Speak ("Joining me now in introducing
" & _
"the group to you\Pau=300\Please Welcome
Genie!")
Genie.Wait MerlinRequest
Genie.Get "Animation", "Announce, GestureLeft,
Blink,Explain"
Peedy.Get "Animation", "Announce, GestureLeft, "
& _
Blink,Explain,Pleased,GestureDown,Surprised,Wave"
If Genie.Visible = False Then
Genie.Show
End If
ScrLeft = 0
ScrTop = 0
Genie.MoveTo ScrLeft, ScrTop
Genie.Play "GestureDown"
Set GenieRequest = Genie.Speak ("Hello Merlin!\Pau=400\ and to you
also " & UserName)
Merlin.Wait GenieRequest
Merlin.Get "Animation", "GestureUp, Surprised"
Merlin.Play "GestureUp"
Merlin.Speak "Hello Genie"
Set MerlinRequest= Merlin.Play ("Blink")
Genie.Wait MerlinRequest
ScrLeft = (window.event.screenX - window.event.clientX)+ 100
ScrTop = (window.event.screenY - window.event.clientY)
Genie.MoveTo ScrLeft, ScrTop
Genie.Get
"Animation","GestureUp,Explain,Surprised,Announce, Wave"
Genie.Play "Announce"
Genie.Speak UserName & " Welcome to Welford-Costelloe
Consultants Inc Web site."
Genie.Play "Explain"
Robby.Get
"Animation","Blink,Announce,Explain,Pleased,Surprised,Wave"
Set GenieRequest = Genie.Speak ("I will now introduce to you,
\Emp\Robby!")
Robby.Wait GenieRequest
If Robby.Visible = False Then
Robby.Show
End If
ScrLeft = 0
ScrTop = 0
Robby.MoveTo ScrLeft, ScrTop
Robby.Play "Announce"
Set RobbyRequest = Robby.Speak ("Hello Merlin!\Pau=400\and Hello!
to you " & UserName)
Merlin.Wait RobbyRequest
Robby.Get "Animation","GestureDown"
Merlin.Play "GestureUp"
Merlin.Play "Blink"
Set MerlinRequest = Merlin.Speak ("Good Day Robby.")
Robby.Wait MerlinRequest
Robby.Play "GestureDown"
Set RobbyRequest = Robby.Speak ("and to you Genie, a very good
day.")
Genie.Wait RobbyRequest
Genie.Play "GestureUp"
Genie.Play "Blink"
Set GenieRequest = Genie.Speak ("Thank you very much
Robby!.")
Robby.Wait GenieRequest
ScrLeft = (window.event.screenX - window.event.clientX) + 200
ScrTop = (window.event.screenY - window.event.clientY)
Robby.MoveTo ScrLeft, ScrTop
Robby.Get "Animation","GestureRight"
Robby.Play "GestureRight"
Set RobbyRequest = Robby.Speak ("Genie!\Pau=400\ are we "
& _
"ready to introduce the new member")
Genie.Wait RobbyRequest
Genie.Play "Blink"
Genie.Speak "\Emp\Yes!\Pau=400\Lets introduce to you our
\Emp\Newest member!"
Set GenieRequest = Genie.Speak ("Peedy!")
Merlin.Get "Animation","Congratulate_2"
Merlin.Wait GenieRequest
Robby.Get "Animation","Congratulate"
Genie.Get "Animation", "Congratulate"
Set MerlinRequest = Merlin.Play ("Congratulate_2")
Genie.Wait MerlinRequest
Set GenieRequest = Genie.Play ("Congratulate")
Robby.Wait GenieRequest
Set RobbyRequest = Robby.Play ("Congratulate")
Peedy.Wait RobbyRequest
If Peedy.Visible = False Then
Peedy.Show
End If
ScrLeft = 0
ScrTop = 0
Peedy.MoveTo ScrLeft, ScrTop
Peedy.Speak "ah!, Hello " & UserName & "!"
ScrLeft = (window.event.screenX - window.event.clientX) + 300
ScrTop = (window.event.screenY - window.event.clientY)
Peedy.MoveTo ScrLeft, ScrTop
Peedy.Play "Announce"
Peedy.Speak "Thank you very much for the \Emp\warm
welcome,Merlin,Genie, and Robby."
Peedy.Speak "\Emp\" & UserName & " It is a
pleasure to " & _
"join this wonderful group!\Pau=500\I am
\Emp\honoured!"
Peedy.Play "Pleased"
Set PeedyRequest = Peedy.Speak ("And thank you " &
UserName & _
" for visiting Welford-Costelloe
Consultants Inc Web Site!")
Merlin.Wait PeedyRequest
Set MerlinRequest = Merlin.Speak("Thanks Peedy!, and thanks to you
guys for you help.")
Genie.Wait MerlinRequest
Set GenieRequest = Genie.Play ("Wave")
Robby.Wait GenieRequest
Set RobbyRequest = Robby.Play ("Wave")
Peedy.Wait RobbyRequest
Set PeedyRequest = Peedy.Play("Wave")
Merlin.Wait PeedyRequest
Merlin.Play "Explain"
Merlin.Speak "\Pau=900\\Emp\" & UserName & " We
hope you " & _
"have enjoyed us as much as we have
enjoyed you."
Merlin.Speak "Please come back and visit us again."
Merlin.Play "Wave"
Merlin.Speak "Feel free to check out the rest of the site.
Enjoy!"
Merlin.Speak "Please check also out free downloads section."
Peedy.Hide
Robby.Hide
Genie.Hide
Merlin.Hide
Set Genie = Nothing
Set Peedy = Nothing
Set Robby = Nothing
Set Merlin = Nothing
end sub
Sub LoadAgents()
On Error Resume Next
'* try to
load the agent from the local drive
Set LoadGenie =
Agent.Characters.Load("Genie","Genie.acs")
Set LoadRobby =
Agent.Characters.Load("Robby","Robby.acs")
Set LoadMerlin =
Agent.Characters.Load("Merlin","Merlin.acs")
Set LoadPeedy =
Agent.Characters.Load("Peedy","Peedy.acs")
'* ok or
not
If LoadGenie.Status <> 0 Then
'* Failed so got to Web
Set LoadGenie =
Agent.Characters.Load("Genie", _
"http://agent.microsoft.com/agent2/chars/genie/genie.acf")
Set Genie = Agent.Characters("Genie")
Status = "Loading Genie from Internet"
Genie.Get "State","Moving, Speaking,
Hiding, Showing"
Else
'* Success
Set Genie = Agent.Characters("Genie")
Status = "Loading Genie from Local drive"
End If
If LoadRobby.Status <> 0 Then
'* Failed so got to Web
Set LoadRobby =
Agent.Characters.Load("Robby", _
"http://agent.microsoft.com/agent2/chars/robby/robby.acf")
Set Robby = Agent.Characters("Robby")
Status = "Loading Robby from Internet"
Robby.Get "State","Moving, Speaking,
Hiding, Showing"
Else
'* Success
Set Robby = Agent.Characters("Robby")
Status = "Loading Robby from Local Drive"
End If
If LoadMerlin.Status <> 0 Then
'* Failed so got to Web
Set LoadMerlin =
Agent.Characters.Load("Merlin", _
"http://agent.microsoft.com/agent2/chars/merlin/merlin.acf")
Set Merlin = Agent.Characters("Merlin")
Status = "Loading Merlin from Internet"
Merlin.Get "State","Moving, Speaking,
Hiding, Showing"
Else
'* Success
Set Merlin = Agent.Characters("Merlin")
Status = "Loading Merlin from Local Drive"
End If
If LoadPeedy.Status <> 0 Then
'* Failed so got to Web
Set LoadPeedy =
Agent.Characters.Load("Peedy", _
"http://agent.microsoft.com/agent2/chars/peedy/peedy.acf")
Set Peedy = Agent.Characters("Peedy")
Status = "Loading Peedy from Internet"
Peedy.Get "State","Moving, Speaking,
Hiding, Showing"
Else
'* Success
Set Peedy = Agent.Characters("Peedy")
Status = "Loading Peedy from Local Drive"
End If
end sub
Sub Agent_RequestComplete(ByVal Request)
end sub
Sub Btn_UserName_OnClick()
On Error Resume Next
UserName = lcase(FrontPage_Form2.txtUserName.Value)
If UserName = "" then
Merlin.Speak "OK, I will adjust our speech
pattern to use no name!."
UserName = ""
End If
If MerlinLoaded = False then
Merlin.Show
MerlinLoaded = True
End if
call MerlinWelcome()
end sub
Function FIndObjectCord(ByVal ele)
' Function
provided by Nathan Dickerson
' Learning
Microsoft Agent
Dim xX, yY, TempHold
Set TempHold = ObjName
Do Until TempHold.TagName = "BODY"
Set TempHold = TempHold.offsetParent
xX = xX + TempHold.offsetLeft +
TempHold.ClientLeft
yY = yY + TempHold.offsetTop +
TempHold.ClientTop
Loop
ScrLeft = fakescreenleft + ObjName.clientLeft + ObjName.offsetLeft _
- document.body.scrollLeft + xX
ScrTop = fakescreentop + ObjName.clientTop + ObjName.offsetTop -
document.body.scrollTop + yY
End Function
Sub window_onUnload()
On Error Resume Next
If Merlin.Visible = True Then
Merlin.Hide
End If
If Genie.Visible = true Then
Genie.Hide
End If
If Robby.Visible = true Then
Robby.Hide
End If
If Peedy.Visible = True Then
Peedy.Hide
End If
Set Merlin = Nothing
Set Genie = Nothing
Set Robby = Nothing
Set Peedy = Nothing
Set GenieRequest = Nothing
Set RobbyRequest = Nothing
Set MerlinRequest = Nothing
Set PeedyRequest = Nothing
Agent.Connected = False
end sub
Sub window_onLoad()
On Error Resume Next
call LoadAgents()
call MerlinOnly()
end sub
-->
</script>
<OBJECT classid="clsid:D45FD31B-5C6E-11D1-9EC1-00C04FD7081F"
height=1 id=Agent style="LEFT: 0px; TOP: 0px"
width=1>
<PARAM NAME="_cx" VALUE="847">
<PARAM NAME="_cy"
VALUE="847"></OBJECT><OBJECT
classid="clsid:B8F2846E-CE36-11D0-AC83-00C04FD97575"
id=TruVoice
CODEBASE="#VERSION=6,0,0,0">
</OBJECT>
<meta name="VI60_defaultClientScript" content="VBScript">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Just For Fun</title>
<META name="description" content="Custom Software Development">
<META name="keywords" content="Software,Visual Basic,Protect
VB, Free Files,Free Downloads,Welford-Costelloe,Costelloe">
<meta name="Microsoft Theme" content="neon 000, default">
<meta name="Microsoft Border" content="b">
</head>
<body bgcolor="#000000" text="#FFFFFF" link="#CCFF66"
vlink="#00FFFF" alink="#FFCC33"><!--msnavigation--><table
border="0"
cellpadding="0" cellspacing="0"
width="100%"><tr><!--msnavigation--><td
valign="top"><!--mstheme--><font face="Verdana, Arial,
Helvetica">
<p align=" center">
<p align="center"><img border="0"
src="images/welford-costelloe%20logo.gif" width="384"
height="96">
<p align="center"><!--webbot bot="Navigation"
S-Type="global"
S-Orientation="horizontal" S-Rendering="graphics"
B-Include-Home="TRUE"
B-Include-Up="TRUE" U-Page S-Target startspan --><a
href="./"><img
src="_derived/home_cmp_neon000_gbtn.gif" width="95"
height="20"
border="0" alt="Home" align="middle"></a> <a
href="what's_new.htm"><img
src="_derived/up_cmp_neon000_gbtn.gif" width="95"
height="20" border="0"
alt="Up" align="middle"></a><!--webbot
bot="Navigation" endspan i-checksum="60096" --></p>
<!--msthemeseparator--><p align="center"><img
src="_themes/neon/neodrule.gif" width="600"
height="10"></p>
<h3 align="center"><!--mstheme--><font
color="#FFFF99">Just
For Fun!<!--mstheme--></font></h3>
<form METHOD="POST" NAME="Meet_Agents">
<div align="center"><center><p><input
TYPE="button"
VALUE="Meet All The Agents" NAME="Show_Agents"> </p>
</center></div>
</form>
<strong>
<p align="left" style="margin-left: 77px; margin-right:
77px"><font color="#FF0080">Note:</font><font
color="#FFFF00">
</font><font color="#8000FF">For first time users - As
Merlin calls the animations from
the internet, due to Internet traffic you may need to wait. <em>Merlin</em>
will announce to you when he is ready to leave, until
then please be patient while the
animations are downloaded.</font></p>
<!--webbot BOT="GeneratedScript" PREVIEW=" " startspan
--><script Language="VBScript"><!--
function FrontPage_Form2_onsubmit()
Set theForm = document.FrontPage_Form2
checkOK =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠ
;ŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâ
ãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ"
+ " "+ Chr(8) + Chr(10) + Chr(12) +
Chr(13)
checkStr = theForm.txtUserName.value
allValid = True
For i = 1 to len(checkStr)
ch = Mid(checkStr, i, 1)
If (InStr(checkOK, ch) = 0) Then
allValid = False
Exit For
End If
Next
If (Not allValid) Then
MsgBox "Please enter only letter and
whitespace characters
in the ""User
Name"" field.", 0, "Validation Error"
theForm.txtUserName.focus()
FrontPage_Form2_onsubmit = False
Exit Function
End If
FrontPage_Form2_onsubmit = True
End Function
--></script><!--webbot
BOT="GeneratedScript" endspan --><form
METHOD="POST" name="FrontPage_Form2">
<p align="center"><font color="#00FFFF">Enter your
name:</font><font color="#FF0080">
<!--webbot bot="Validation" S-Display-Name="User Name"
S-Data-Type="String"
B-Allow-Letters="TRUE" B-Allow-WhiteSpace="TRUE" --><input
TYPE="text" SIZE="20" ID="EnterName"
NAME="txtUserName">
<input TYPE="button" VALUE="Continue"
NAME="Btn_UserName"> </font></strong></p>
</form>
<strong><font color="#FF0080">
<p align="left">
<!--msthemeseparator--><p align="center"><img
src="_themes/neon/neodrule.gif" width="600"
height="10"></p>
<p align="left"> </font></strong> |
|
 |
|
 |