Click here to Skip to main content
15,885,546 members
Articles / Programming Languages / VBScript

Using Microsoft Agent Control 2.0 - Merlin

Rate me:
Please Sign up or sign in to vote.
4.55/5 (13 votes)
21 Jun 2004CPOL3 min read 108.8K   4.5K   20   5
Shows the main features of Microsoft Agent Control 2.0

Introduction

In this tutorial, I will be showing you how to make a small program that will help you understand certain aspects regarding Microsoft Agent. In this case. we will be using the Merlin model, because he comes with Windows XP. If you do not have Windows XP, then don't worry. The source code download includes the model and all the installs required to use it (2 small 1MB or so files”), which must be distributed with your program in order for it to work properly on other machines. So let's get started.

First of all, download the source file and install, “INSTALL FIRST.exe” and “INSTALL SECOND.exe”. Once that is done, put “MERLIN.ACS” in the same folder as the one your project is in. So then, let's start coding.

Start a new project if you haven't already done so, and make sure wherever you save it, it is in the same directory as “MERLIN.ACS”. Go to your form and right click the toolbox and press “Components…” you will see a screen much like this one:

Components

As you can see here, I have already selected Microsoft Agent Control 2.0. So, unless it is already done, tick the box, then press OK.

Now you will see the Agent Control in the toolbox (secret agent guy). Go to your form design view, and click the Agent Control, and draw it anywhere in your form (it is invisible to the user).

Next draw a ComboBox near the top in the center of the form, and name it Animation, and set text to nothing. Now, draw a TextBox underneath the ComboBox and name it Speech, set its text to nothing. After that, draw a CommandButton at the bottom, in the center and name it, “btnDoIt”, and set its caption to “Do It!”. Now just add a Label next to the Animation ComboBox and set its caption to “Animation:”. Add another Label next to the Speech TextBox and set its caption to “Speak:”.

Your form should look something like this:

Form

Now, to the code. Choose Form, Load and you will see...

VB.NET
Private Sub Form_Load()
End Sub

... appear in the code. In between “Private Sub Form_Load()” and “End Sub”, type:

VB.NET
Dim CharPath As String

' Activate Merlin
CharPath = "" ' The path is the root directory for your project

' Load the characters specified in path
ctlAgent.Characters.Load "Merlin", CharPath & "merlin.acs"
Set Merlin = ctlAgent.Characters("Merlin")

' Display Merlin on the screen
Merlin.Show

' Add the Character Animations to the ComboBox
Animation.AddItem ("Acknowledge")
Animation.AddItem ("Announce")
Animation.AddItem ("Blink")
Animation.AddItem ("Congratulate")
Animation.AddItem ("DoMagic1")
Animation.AddItem ("DoMagic2")
Animation.AddItem ("Explain")
Animation.AddItem ("GestureDown")
Animation.AddItem ("GestureLeft")
Animation.AddItem ("GestureRight")
Animation.AddItem ("GetAttention")
Animation.AddItem ("LookUpBlink")
Animation.AddItem ("MoveDown")
Animation.AddItem ("MoveLeft")
Animation.AddItem ("MoveRight")
Animation.AddItem ("MoveUp")
Animation.AddItem ("Pleased")
Animation.AddItem ("Process")
Animation.AddItem ("Read")
Animation.AddItem ("Sad")
Animation.AddItem ("Search")
Animation.AddItem ("Show")
Animation.AddItem ("Think")
Animation.AddItem ("Wave")
Animation.AddItem ("Write")

This simply adds every animation the Merlin has into the ComboBox, after activating and showing the Merlin Model. Next double-click the “Do It!” button and type:

VB.NET
   Set Merlin = ctlAgent.Characters("Merlin") ' Load Merlin to memory
   If Animation.Text = "" Then                ' If the Animation ComboBox has 
                                              ' nothing selected
      MsgBox ("No Animation Selected")        ' Give an error
   ElseIf something has been chosen in the ComboBox
      Merlin.Play Animation.Text   ' Have Merlin play the selected animation
   End If

   If Speech.Text = "" Then    ' If no text has been entered into the TextBox
      MsgBox ("No Text Entered to speak") ‘ Give an error
   Else                        ' If text has been entered
      Merlin.Speak Speech.Text ' Have Merlin say whatever is written in the 
                               'TextBox
   End If
End Sub

Now when you run the program, if all goes well (if not, see possible errors later on in this tutorial), then when the form appears, so should Merlin, and you can choose any of his animations, and type in anything for him to say, and he will do it. Pretty cool huh?

POSSIBLE ERRORS

One error I had was to name my project “Merlin”, and that made an error because the model was named Merlin, and whenever I set Merlin’s properties, the compiler thought I was referring to the project.

Also, if you don't install those two files, either the character won't show up, or you won't be able to hear anything he says, you'll just see the text.

I hope you enjoyed this tutorial. If you have any questions or suggestions, feel free to email me at spiderfreak3000@msn.com.

History

  • 21st June, 2004: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionFiles can not be opened by winrar, Pin
itsQ14-May-12 5:43
itsQ14-May-12 5:43 
GeneralAcitive X Controls Pin
n.vinoth24-Jul-07 23:10
n.vinoth24-Jul-07 23:10 
GeneralFile Damaged Pin
raju77777772-Nov-06 18:07
raju77777772-Nov-06 18:07 
GeneralFile Damaged Pin
raju77777772-Nov-06 18:06
raju77777772-Nov-06 18:06 
GeneralZIP file damaged Pin
PC-Alex25-Nov-04 23:33
PC-Alex25-Nov-04 23:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.