Click here to Skip to main content
12,295,791 members (25,069 online)
Click here to Skip to main content
Add your own
alternative version

Stats

191.2K views
5K downloads
64 bookmarked
Posted

Programming the MS Agent Control

, 3 Mar 2000 CPOL
Rate this:
Please Sign up or sign in to vote.
Programming an animated agent similar to the office assistant.
  • Download demo project - 21 Kb
  • Download source files - 44 Kb
  • Introduction to the Microsoft Agent

    Microsoft has introduced the new MS Agent Control. This control is very similar to the office assistant that we see in MS Office Applications. This control can seamlessly integrate into existing applications with a lot of ease due to good programming support that is available. It richly enhances the user interface and has seemingly wide applications as it is even scriptable in to Web Pages for which it is actually meant and supposed to have good performance on the internet because of low band width requirements.

    The control is available as an OCX interface and COM programming support is also provided.

    Key appreciable features are:

    • Text To Speech Conversion Support
    • Speech Recognition Engine

    The MS Agent is distributed in to several components (put into a single file AGENT.CPP and AGENT.H in the sample):

    • Request
    • Agent (control)
    • Characters (collection)
    • Character Commands (collection)
    • Command
    • Balloon
    • AnimationNames (collection)
    • SpeechInput
    • AudioOutput
    • CommandsWindow
    • PropertySheet

    The best place to go to refer to the documentation is at Microsoft's site.


    Programming

    I wished to make a control like the office agent almost a year back. But then I knew I had to do it on my own and I gave up at ease. All I wished was an API interface to the Agent and the prayer was answered even without asking.

    I wished to share with you this information as I felt all might find this information quite useful. I really don’t deserve any credit for this code as I have just referred MSDN, Microsoft Web site and MS Samples. But I will surely be glad to help if you need any help from me.

    This sample is provided so that you can check it out and the MFC Wrapper class that I have written encapsulates quite a few details and can be useful in case it helps you.

    Steps that I followed were to download the following and I could install it without problems:

    1. Download the Microsoft Agent core components
    2. Download Agent Interface files. Unzip the header files to your DevStudio/VisualStudio VC/Include folder.
    3. Download MS Agent Characters. (Peedy and Genie are really cute characters)
      (Note: - After installation characters will be available in your $Windows\MSAgent\Chars directory)
    4. Download the Text to Speech engines.
    5. Download the Speech Recognition engines. (I have not yet checked this out)
    6. Download the Speech control panel.
    7. Optionally download:
      • Agent Character Editor
      • Linguistic information sound editing Tool
      • The Microsoft Site offers lot of code samples and documentation to download.
    8. Download the End User Downloads
    9. Download the Developer Downloads


    Sample Screen of the test application


    The MFC Wrapper: CMsAgentWrapper

    CMsAgentWrapper does not have a base class. A CMsAgentWrapper object consists of a CAgentCtlEx MS Agent.

    Data Members

    • CAgentCtlEx m_obAgent - the the Agent Control Object.
    • CStringArray m_szAnimationsArray - an array of supported Animations.
    • BOOL m_bStopBeforePlay - determines whether Previous Animation should be stopped before playing next Animation
    • BOOL m_bAgentReady - determines whether the Agent Character Loaded.

    Construction/Destruction

    • CMsAgentWrapper();
    • virtual ~CMsAgentWrapper();

    Initialization and Cleanup

    BOOL Create(UINT uId, CWnd *pParentWnd = NULL, DWORD dwStyle = WS_CHILDWINDOW, BOOL bRaiseRequestErrors = FALSE);
    Creates the MS Agent Wrapper control for the given id.

    BOOL Exit();
    Closes the Agent Control.

    BOOL LoadCharacter(CString pszCharFilename);
    Loads a Character File. (Note: - After installation characters will be available in your $Windows\MSAgent\Chars directory)

    BOOL Move(int iX, int iY);
    Moves the Microsoft Agent Character Absolute screen coordinated X,Y Location taking into account the agent size.

    BOOL Speak(CString szSpeakText, BOOL bBalloonEnabled = TRUE, BOOL bBalloonSizeToText = TRUE, BOOL bBalloonAutoPace = TRUE, BOOL bBalloonAutoHide = TRUE);
    The specified text is shown in a message box and if a sound card and Text to speech support is installed the given text is spoken out. Setting Auto Pace to FALSE makes the text displayed in the message box appear at once rather than a word at a time.

    BOOL SetSoundEffectsOn(BOOL bSoundEffectsOn = TRUE);
    Sets sound support for the agent.

    BOOL Stop();
    Requests the Agent to stop animations.

    BOOL Show();
    Requests the Agent Server to show the selected character.

    BOOL Hide();
    Requests the Agent Server to hide the selected character.

    BOOL ActivateApp(BOOL bActive);
    Requests the Agent Server to hide/select the selected character. This function is ideal to be used to activate and deactivate the Agent when the parent activates and deactivates.

    LPCTSTR GetCharacter>();
    Gets the Name of the Character not correctly implemented yet.

    void SetStopBeforePlay(BOOL bStopBeforePlay = TRUE);
    Decides whether the previous animation should be stopped before playing the next animation.

    BOOL GetStopBeforePlay();
    Retrieves the setting specifying whether previous animation should be stopped before playing the next animation.

    int GetSizeOfAnimations();
    Retrieves the number of supported animations for the given Microsoft Agent Control.

    CString GetAnimationIndex(int i);
    Retrieves the name of the specified supported animations by index.

    BOOL Play(int iAnim = 0, BOOL bStop = TRUE);
    Plays the Animation at the specified index. bStop specifies whether the previous animation has to be stopped before playing the current animation.


    Additional Resources

    License

    This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Share

    About the Author

    Santosh Rao
    Architect
    India India
    1993 started with Computers

    BE(Computer Science) and MS (Software Systems)

    Industry Experience: 10 Years

    C, C++, VC++(MFC), .NET, C#, MTS, Queuing, ASP.NET, AJAX, Java, J2EE, SunOne, JMS

    Banking, Insurance & Pension,Health Care

    You may also be interested in...

    Comments and Discussions

     
    Questionthanks for you share Pin
    xiangxiangli28-May-12 3:42
    memberxiangxiangli28-May-12 3:42 
    GeneralExist a decompiler for a file compile with MS Agent (.acf file) Pin
    TheCodeVB13-Feb-11 11:48
    memberTheCodeVB13-Feb-11 11:48 
    GeneralAstonished to Pin
    bahgat youw20-Mar-09 3:54
    memberbahgat youw20-Mar-09 3:54 
    GeneralUser interaction Pin
    frwa9-Jan-09 11:49
    memberfrwa9-Jan-09 11:49 
    QuestionHow would you list all the available voices? Pin
    prudnik18-Dec-07 6:02
    memberprudnik18-Dec-07 6:02 
    QuestionThermal measurement project Pin
    israa mohammed23-Nov-07 23:23
    memberisraa mohammed23-Nov-07 23:23 
    GeneralConext menu in MS Agent control Pin
    neetu gahlot23-Sep-05 19:23
    sussneetu gahlot23-Sep-05 19:23 
    GeneralBorland C++ BuilderX compatible? (how to) Pin
    Millyard16-Mar-05 11:48
    memberMillyard16-Mar-05 11:48 
    Generaldisplay indexed msg Pin
    bayue27-Dec-04 17:18
    memberbayue27-Dec-04 17:18 
    Generaladd ms agent to my webpage without uploding it Pin
    bayue27-Dec-04 16:40
    memberbayue27-Dec-04 16:40 
    Generalautomaticly recording Pin
    menag2-Nov-04 3:19
    membermenag2-Nov-04 3:19 
    QuestionHow to mix animation with speech Pin
    Anonymous13-May-04 8:51
    sussAnonymous13-May-04 8:51 
    Generalordinal 5076 Pin
    Anonymous18-Nov-03 7:14
    sussAnonymous18-Nov-03 7:14 
    GeneralRe: ordinal 5076 Pin
    Anonymous21-Mar-05 22:47
    sussAnonymous21-Mar-05 22:47 
    GeneralAssertion with Dev 7... Pin
    LilMoke25-Oct-03 18:06
    memberLilMoke25-Oct-03 18:06 
    GeneralRe: Assertion with Dev 7... Pin
    LilMoke26-Oct-03 4:11
    memberLilMoke26-Oct-03 4:11 
    GeneralSame Compile Error Pin
    alan9330-Sep-03 5:10
    memberalan9330-Sep-03 5:10 
    GeneralOrdinal 5077 & 5076 Pin
    Sanjin17-Dec-02 11:44
    memberSanjin17-Dec-02 11:44 
    GeneralRe: Ordinal 5077 & 5076 Pin
    TeisDraiby27-Dec-02 10:16
    memberTeisDraiby27-Dec-02 10:16 
    GeneralRe: Ordinal 5077 & 5076 Pin
    Bill94421-Sep-03 20:05
    memberBill94421-Sep-03 20:05 
    GeneralRe: Ordinal 5077 & 5076 Pin
    Anonymous23-Jun-03 8:44
    sussAnonymous23-Jun-03 8:44 
    GeneralGreat Job! Pin
    Paul Kissel13-Dec-02 20:20
    memberPaul Kissel13-Dec-02 20:20 
    GeneralSome help!! Pin
    Anonymous11-Oct-02 17:37
    sussAnonymous11-Oct-02 17:37 
    QuestionWhy did Error happen when I added ActiveX control? Pin
    Anonymous8-Jul-02 17:22
    memberAnonymous8-Jul-02 17:22 
    GeneralMS Access versus MS Agent Pin
    Robert Goyvaerts21-May-02 12:13
    memberRobert Goyvaerts21-May-02 12:13 
    GeneralCompile error Pin
    Abhishek Jain8-Apr-02 7:00
    memberAbhishek Jain8-Apr-02 7:00 
    GeneralRe: Compile error Pin
    Franz Brunner1-Nov-03 23:29
    memberFranz Brunner1-Nov-03 23:29 
    GeneralCompile error Pin
    Abhishek Jain8-Apr-02 6:55
    memberAbhishek Jain8-Apr-02 6:55 
    GeneralRe: Compile error Pin
    wingswings8-Jun-03 17:34
    memberwingswings8-Jun-03 17:34 
    GeneralCompile error Pin
    CosmoS2k10-Feb-02 13:25
    memberCosmoS2k10-Feb-02 13:25 
    QuestionHow to know whether or not MS Agent is installed? Pin
    Bui Huy Kien23-Jan-02 17:54
    memberBui Huy Kien23-Jan-02 17:54 
    QuestionHow to add buttons to balloon text Pin
    Amit Dey11-Nov-01 12:36
    memberAmit Dey11-Nov-01 12:36 
    AnswerRe: How to add buttons to balloon text Pin
    Anonymous1-Sep-05 21:16
    sussAnonymous1-Sep-05 21:16 
    QuestionHow wait until Agent's queue is empty Pin
    Frun29-Oct-01 1:14
    memberFrun29-Oct-01 1:14 
    Generalprogramme error Pin
    Anonymous20-Oct-01 19:17
    memberAnonymous20-Oct-01 19:17 
    GeneralRe: programme error Pin
    Santosh Rao20-Oct-01 19:56
    memberSantosh Rao20-Oct-01 19:56 
    QuestionHow to get userinput ? Pin
    Dani Grauch14-Jan-01 22:31
    memberDani Grauch14-Jan-01 22:31 
    AnswerRe: How to get userinput ? Pin
    frwa9-Jan-09 12:53
    memberfrwa9-Jan-09 12:53 
    GeneralAdded Variable Definitions Pin
    Michael Barnhart26-Sep-00 6:15
    sussMichael Barnhart26-Sep-00 6:15 
    GeneralTake note of licensing... Pin
    Paul Selormey3-Mar-00 20:35
    sussPaul Selormey3-Mar-00 20:35 
    GeneralRe: Take note of licensing... Very Important Pin
    Santosh Rao5-Mar-00 22:20
    sussSantosh Rao5-Mar-00 22:20 
    GeneralRe: Take note of licensing... Pin
    Anonymous23-Mar-01 9:17
    memberAnonymous23-Mar-01 9:17 

    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.

    | Advertise | Privacy | Terms of Use | Mobile
    Web02 | 2.8.160525.2 | Last Updated 4 Mar 2000
    Article Copyright 2000 by Santosh Rao
    Everything else Copyright © CodeProject, 1999-2016
    Layout: fixed | fluid