Using Microsoft Agent in C#

In this code snippet, I am going to explain how to use Microsoft Agent Control in C#. Microsoft Agent is a new technology, which allows Programmer to create and use animated characters that can interact with end users. It also supports the Microsoft Speech API, which allows the character to speak with the user. The characters are floating type, and can be placed or moved anywhere on the screen by the user or the programmer at any time. These characters contain lot of animations.

Before starting to code, you will need the Microsoft Agent Control installed. Next, you have to download the characters. There are four type of characters are available for download. They are

Genie Merlin Peedy Robby
1.6 MB exe 1.8 MB exe 3.3 MB exe 2.2 MB exe

In this Code, I am going to use Genie character in Microsoft Agent Control.

Step 1

Create a new Visual C# Project -- Windows Application

Step 2

Right click on Toolbox, select Customize Toolbox Option, select Microsoft Agent Control 2.0 from the Com Component List, click on Select button and press Ok button to add the control to your project.

Step 3

Drag Microsoft Agent Control from Toolbox and drop it in your project and also Place two buttons in your form to activate Speak and Think Methods of the Microsoft Agent Character.

Step 4

Declare a global AgentObjects.IAgentCtlCharacterEx type variable called genie with Public modifier

public AgentObjects.IAgentCtlCharacterEx genie;

Step 5

In the Form Load event, Write the following code to load genie character and assign the character to a variable called Genie.


Step 6

Write the following code in Button1 click event to trigger speak Method of Character.

genie.Speak("Test Message","");

Step 7

Write the following code in Button2 click event to trigger Think Method of Character.

genie.Think("Test Message");

Genie think


You can also use Left and Top property of the character to set the position.

You might also like...


M M Harinath


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook