Agent 技术,通过运行该技术就可以在自己的程序中使用很有趣的精灵了。
Microsoft Agent核心组建
Microsoft Agent的四个精灵:吉尼(Genie)、么林(Merlin)、罗比(Robby)以及皮蒂(Peedy)
//在创建程序的用户界面以前我们必须先导入Agent Control这个ActiveX控件,该控件在你安装好系统要求中的项后便有了。下面是导入的方法:选择菜单"工具->自定义工具箱",并选择Microsoft Agent Control 2.0组件// (vb.net中可能无需此步)
Private agentController As AgentObjects.Agent
Private agentCharacter As AgentObjects.IAgentCtlCharacter
private IAgentCtlCharacterEx Character;(这就是我们要用到的精灵的对象)。
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' The Agent object is used to open a connection to the Agent server,
' load the character, and then associate the character with the
' variable referencing the IAgentCtlCharacter interface. From then
' on you program against the agentCharacter.
agentController = New AgentObjects.Agent()
With agentController
.Connected = True
.Characters.Load("merlin", "merlin.acs") /导入精灵么林(Merlin)
agentCharacter = .Characters("merlin")
End With
' 使用位置属性将精灵放置在窗体的左上角.
With agentCharacter
.MoveTo(CShort(Me.Location.X + 420), CShort(Me.Location.Y + 130))
.Show()
.Play("Announce") // Announce 是精灵的一种行为“吹喇叭”
.Speak("Hello, my name is Merlin. " & _
"Welcome to the Office Automation Demo!")
.Play("GestureRight") // GestureRight是精灵的一种行为“请”
.Play("wave") // GestureRight是精灵的一种行为“招手”
'You can make Merlin's speech sound more natural by inserting speech
' output tags like Pau (Pause), Chr (Character of the Voice),
' Emp (Emphasis) or Spd (Speed). Surround each name-value pair with a
' backslash character.
.Speak("Make me say something,\pau=300\or\pau=500\...")
.MoveTo(CShort(Me.Location.X + 340), CShort(Me.Location.Y + 250))
.Play("GestureRight")
.Speak("...try out some of my animations.")
End With
End Sub