Click here to Skip to main content
Licence CPOL
First Posted 21 Jun 2004
Views 67,356
Downloads 2,373
Bookmarked 18 times

Using Microsoft Agent Control 2.0 - Merlin

By | 21 Jun 2004 | Article
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...

Private Sub Form_Load()
End Sub

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

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:

   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)

About the Author

spiderfreak3000



United Kingdom United Kingdom

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionFiles can not be opened by winrar, PinmemberitsQ5:43 14 May '12  
GeneralAcitive X Controls Pinmembern.vinoth23:10 24 Jul '07  
GeneralFile Damaged Pinmemberraju777777718:07 2 Nov '06  
GeneralFile Damaged Pinmemberraju777777718:06 2 Nov '06  
GeneralZIP file damaged PinmemberPC-Alex23:33 25 Nov '04  

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

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 22 Jun 2004
Article Copyright 2004 by spiderfreak3000
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid