Windows - controlando o agente
|Top Previous Next|
I Needed To KNow Some Info. About MS-Agent And How To Use It ?
Hello dear readers, in this tutorial I will show you a little bit how the Microsoft Agent works and what is it. Note that I'm not a specialist on this subject and I don't know much about the Agent, all things I will teach you I just learned from experimenting with the Microsoft Agent. Nevertheless, I think this could be a useful tutorial for you since I will tell you the basics you need to know.
What is Microsoft Agent?
Microsoft Agent is an ActiveX Control (OCX) that makes you able to control little dudes that can do all sorts of things and can even speak. The Microsoft Agent looks very similar to the "Office Assistant" included with Microsoft Office 97 and above. You have several characters you can use with Microsoft Agent, you can even make your own Agent character with a special program from Microsoft! I'll give you links to all those programs later. We're very lucky Microsoft made everything free! The most fameous Agent character is Merlin the wizard I believe. I also made an agent character myself called: Monitor.
Programming with the Microsoft Agent
First of all you'll need to place import the Microsoft Agent ActiveX Control, after is has been imported you can place an instance on your form. Then we've to declare a global class in the var section of the unit.
var MyAgent: IAgentCtlCharacterEx;
Next, you create your Agent character in the FormCreate event, your agent will be based on a ACS file. As I told before, you can also create those ACS files yourself with a special program from Microsoft. In the code below it is assumed the Agent ActiveX control is called Agent1 and the Agent character's path is c:\agent\agent.acs
MyAgent := Agent1.Characters.Character('myagent');
After the Agent is created you should make it visible to the user. You can do that easily:
The agent is now visible, and what can we do now? If you've installed the Microsoft Text2Speech Engine then you can let the Agent talk using this code:
MyAgent.Speak('Look! I can speak!','');
Or you can use this when you want one of the sentences seperated by the | - character to be spoken. In the example below the Agent will say either "Hello" OR "Hi".
You can also move the agent to any location on the screen, note the Agent will be displayed directly on the screen and not on the form the ActiveX Control is on.
The last parameter specifies the speed of the Agent.
Instead of let the agent speak you can also let him think, you will then get a cloud-like balloon just like in comic books and the text won't be spoken out loud. You can also use the Pipe character ( the | character) with the Think method. It works the same way as with the speak method.
When you want the Agent to dissappear again you should use the Hide method.
Inside the ACS file there're a couple of animations for the character defined, each animation has it's own name. You can play a specific animation using the Play method. OF course you then have to know a valid animationname for that character.
That were all the basics off the Microsoft Agent control! As you now see, it's all quite easy!
Where can I download the stuff I need?
All the stuff you need you can get at CNet's www.download.com .