Click here to Skip to main content
13,900,395 members
Click here to Skip to main content
Add your own
alternative version


82 bookmarked
Posted 22 May 2001

Creating Cool Agent User Interfaces

, 14 Mar 2002
Rate this:
Please Sign up or sign in to vote.
This article describes using Microsoft agent to create user interfaces that display characters, like Office 2000 Office Assistants.
<!-- Download Links -->



Microsoft Office 2000 uses animated characters, which it calls Office Assistants, to help users and provide assistance. With Microsoft Agent, you can add such characters to your own applications. You can even use the Office Assistants themselves – like The Genius or F1. Characters designed for use with Agent can do a variety of tasks – like speech synthesis and recognition, in addition to displaying a variety of animations.


To be able to use this technology, you must have:

  1. The Microsoft Agent Core components.
  2. The Microsoft Agent Characters – Genie, Merlin, Robby, and Peedy.
  3. The Lernout and Hauspie Text-to-Speech engines for at least US English.
  4. The Microsoft Speech API 4.0a runtime.
  5. The Microsoft Speech Recognition Engine.

All these components are available from In addition, to use the Microsoft Office characters, you must have Office 2000. Office 97 characters are not compatible with Agent.

Using Microsoft Agent with the .NET Framework

Microsoft Agent is provided as an ActiveX control DLL. To use it within .NET, you can use the AxImp.exe utility provided with the .NET Framework SDK. Create a folder where you want to keep the imported libraries, and then use the command:

aximp %systemroot%\msagent\agentctl.dll

The makefile included in the download does this for you. This command should create two files: AxAgentObjects.dll and AgentObjects.dll. You are now ready to use Agent with .NET.

Programming Agent

Agent programming is easy because it relies completely on COM, and we don’t have to mess around with PInvoke or something. The first step to using Agent is to add the Agent ActiveX control in AxAgentObjects.dll to your project. Put it anywhere on a form; it is invisible at runtime. Next, you should add a member variable of type AgentObjects.IAgentCtlCharacterEx (from AgentObjects.dll) to your class. You should import the AgentObjects namespace into your application; this simplifies several tasks. Essentially, you must, at a minimum:

  1. Load the character you want, and provide a descriptive name to refer to it. In the Hello World sample, this is accomplished by the line AxAgent.Characters.Load("Genie", (object)"GENIE.ACS");
  2. Set your character variable to the character you just loaded. In the Hello World sample, this is accomplished by the line Character = AxAgent.Characters["Genie"];
  3. Set the correct language to use: Character.LanguageID = 0x409; sets the language to US English.
  4. Show the character: Character.Show(null);

These steps shall simply load and display the character.

Hello World Sample

The mandatory Hello World sample requires the Genie character. The sample simply loads the character and displays him. You can also make him say something. To make the character talk, the character’s speak method is called, like this:

if(TextToSpeak.Text.Length == 0)  // Don't speak a zero-length
  return;                         // string.

//Make the character speak.
Character.Speak(TextToSpeak.Text, null);

As you can see, it’s very simple to use Agent.

Using Speech Recognition

Unlike the office assistants, you can make Agent characters talk and also respond to voice commands. Any commands you add shall also be available in the character’s context menu. Speech recognition is, by default, enabled only when you hold down the scroll lock key. All you have to do is to add new commands to the character object’s Commands collection. Then, you must add an event handler for the Agent control’s Command event. A boxed IAgentCtlUserInput object is supplied to the event handler as a parameter. You can access the command recognised by the IAgentCtlUserInput object’s Name property.

Interactive Hello World Sample

The Interactive Hello World sample demonstrates basic speech recognition, as well as playing animation. First, the control and the character (Robby) are loaded and initialised, and then two commands are added:

protected void LoadButton_Click(object sender, System.EventArgs e)
  // Load the Robby character.
  AxAgent.Characters.Load("Robby", (object)"ROBBY.ACS");
  Character = AxAgent.Characters["Robby"];
  StatusLabel.Text = Character.Name + " loaded.";
  // Set the language to US English.
  Character.LanguageID = 0x409;

  // Display the character.

  LoadButton.Enabled = false;

  // Display name for the commands.
  Character.Commands.Caption = "Hello World";

  Character.Commands.Add("Hello",  // Command name
    (object)"Say Hello",  // Display name
    (object)"([say](hello | hi) | good (day | morning | evening))", // SR String
    (object)true,  // Enabled
    (object)true);  // Visible

  Character.Commands.Add("Goodbye",  // Command name
    (object)"Goodbye",  // Display name
    (object)"(bye | goodbye | exit | close | quit)", // SR String
    (object)true,  // Enabled
    (object)true);  // Visible

  PromptLabel.Visible = true;

The speech recognition strings offer several options that the user can say; for example, saying ‘goodbye’, ‘bye’ and ‘close’ have the same effect. In all cases, the command name is passed to the event handler, so you don’t have to account for the various variations of the recognised string. In the event handler, a test is done for the command:

protected void AxAgent_Command(object sender, AxAgentObjects._AgentEvents_CommandEvent e)
  IAgentCtlUserInput ui;
  ui = (IAgentCtlUserInput)e.userInput;
  if(ui.Name == "Hello")
    Character.Speak((object)"Hello. My name is Robby." +
      " Pleased to meet you.", null);

    PromptLabel.Text = "Say goodbye to dismiss Robby.";
  if(ui.Name == "Goodbye")
    Character.Speak((object)"It was nice talking to" +
      " you. Goodbye.", null);


Animations are played with the character object’s play method.

The AgentDemo Application

If you see the Microsoft Agent site, you will see a Visual Basic sample that enumerates all animations present in a character. The AgentDemo application also does the same thing, only in C#. You can load all Agent and Microsoft Office characters and see a list of animations. Here’s a screenshot (with the Office 2000 F1 character loaded):

This app is kinda redundant now, because Microsoft ships just such a sample with Beta 2. I just converted what I had done for Beta 1 to Beta 2 code.

A Note About Your Applications

Many people think that the Office Assistants are irritating. You must take care not to make your characters irritating, but instead helpful, and always provide an easily accessible option to turn them off.


15 Mar 2002 - updated source files.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Nikhil Dabas
President NikSci
India India
No Biography provided

You may also be interested in...


Comments and Discussions

Questionmultilanguage support of speech api how?? Pin
29181195-Mar-09 1:43
member29181195-Mar-09 1:43 
AnswerRe: multilanguage support of speech api how?? Pin
Nikhil Dabas5-Mar-09 2:45
memberNikhil Dabas5-Mar-09 2:45 
GeneralMS Agent, why Scroll lock Pin
Muammar©10-May-07 21:41
member Muammar©10-May-07 21:41 
GeneralPARSERS Pin
Anonymous25-Dec-04 8:29
memberAnonymous25-Dec-04 8:29 
Generalrecongnition Pin
maitre cesar27-Apr-03 2:08
membermaitre cesar27-Apr-03 2:08 

can anyone help me about the speech recognition.
I don't have the message "robby is listenning for hello world" ( same if inserts the medium button.)
If i would like to use a other language what I put for LanguageID.

Generalclass Pin
Anonymous23-Apr-03 23:16
memberAnonymous23-Apr-03 23:16 
Generalaximp Pin
maitre cesar22-Apr-03 2:43
membermaitre cesar22-Apr-03 2:43 
GeneralRe: aximp Pin
Stephane Rodriguez.22-Apr-03 2:46
memberStephane Rodriguez.22-Apr-03 2:46 
QuestionAgent output to voice modem? Pin
bardentech9-Oct-02 18:22
memberbardentech9-Oct-02 18:22 
AnswerRe: Agent output to voice modem? Pin
Nikhil Dabas10-Oct-02 10:23
memberNikhil Dabas10-Oct-02 10:23 
GeneralScroll lock button Pin
happys24-Jul-02 3:26
memberhappys24-Jul-02 3:26 
GeneralRe: Scroll lock button Pin
macromark20-May-03 19:47
membermacromark20-May-03 19:47 
GeneralRe: Scroll lock button Pin
kikosii11-Dec-03 4:47
memberkikosii11-Dec-03 4:47 
GeneralMSAgent voice recognition Pin
Anonymous23-Jul-02 6:21
memberAnonymous23-Jul-02 6:21 
GeneralRe: MSAgent voice recognition Pin
happys24-Jul-02 3:28
memberhappys24-Jul-02 3:28 
GeneralMs agent Pin
17-Apr-02 3:58
suss17-Apr-02 3:58 
GeneralRe: Ms agent Pin
Michael P Butler17-Apr-02 4:04
memberMichael P Butler17-Apr-02 4:04 
QuestionHas anyone actually DONE anything with Agents ? Pin
Jim Crafton17-Mar-02 6:07
memberJim Crafton17-Mar-02 6:07 
AnswerRe: Has anyone actually DONE anything with Agents ? Pin
Nikhil Dabas17-Mar-02 22:26
memberNikhil Dabas17-Mar-02 22:26 
AnswerRe: Has anyone actually DONE anything with Agents ? Pin
Michael P Butler17-Mar-02 22:49
memberMichael P Butler17-Mar-02 22:49 
GeneralRe: Has anyone actually DONE anything with Agents ? Pin
24-Mar-02 2:29
suss24-Mar-02 2:29 
AnswerRe: Has anyone actually DONE anything with Agents ? Pin
Anonymous6-Aug-02 3:23
memberAnonymous6-Aug-02 3:23 
GeneralRe: Has anyone actually DONE anything with Agents ? Pin
Jim Crafton6-Aug-02 3:30
memberJim Crafton6-Aug-02 3:30 
GeneralRe: Has anyone actually DONE anything with Agents ? Pin
Bui Huy Kien12-Dec-02 16:11
memberBui Huy Kien12-Dec-02 16:11 
GeneralRe: Has anyone actually DONE anything with Agents ? Pin
Anonymous11-Apr-05 10:21
memberAnonymous11-Apr-05 10:21 

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.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01 | 2.8.190306.1 | Last Updated 15 Mar 2002
Article Copyright 2001 by Nikhil Dabas
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid