Library code snippets
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.
axAgent1.Characters.Load("Genie","Genie.acs");
genie=axAgent1.Characters["Genie"];
Step 6
Write the following code in Button1 click event to trigger speak Method of Character.
genie.Show(false);
genie.Speak("Test Message","");
genie.Hide(true);
Step 7
Write the following code in Button2 click event to trigger Think Method of Character.
genie.Show(false);
genie.Think("Test Message");
genie.Hide(true);
You can also use Left and Top property of the character to set the position.
Related articles
Related discussion
-
Query Tool to Excel using C# and .NET
by BarbaMariolino (1 replies)
-
looking for help on asp
by cladironbeard (2 replies)
-
Socket Programming in C# - Part 1
by graumanoz (23 replies)
-
LINQ in Action
by naser1 (0 replies)
-
Creating a Windows Service in VB.NET
by Templario55 (107 replies)
Related podcasts
-
Object-Oriented Programming in Ruby
In this episode, I talk with Scott Bellware about object-oriented programming in Ruby, and Ruby's object model. This is taken from a private conversation, and the audio quality suffers at times. Much thanks to Scott for allowing this to be released.This episode of the Alt.NET Podcast is bro...
Events coming up
-
Aug
28
St. Louis Day of .NET
St. Charles, United States
Technical conference with be 2 full days of content with over 40 sessions from local and national speakers, with topics such as:•.NET languages: C#, VB.NET•Technologies: WPF, Silverlight, WCF•Development tools: Visual Studio, TFS, Expression Blend
That works well... I implemented those with few easy steps...... looks like magic....
we can use this stuff while implementing some games or fun related applications....
But when the message appears it doesnt stay too long...
i tried by commenting genie.hide(true);
but only the genie was persistent not the message.....
Is there any way to make the message to stay for little more duration?
Regards
Shafeer
Hi,
Nice article.I found it very useful. Thanx a lot...![Exclamation [:)]](/emoticons/emotion-1a.gif)
Regards,
donet_guru.
This thread is for discussions of Using Microsoft Agent in C#.