Click here to Skip to main content
Licence CPOL
First Posted 3 Mar 2000
Views 166,640
Bookmarked 62 times

Programming the MS Agent Control

By | 3 Mar 2000 | Article
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)

    About the Author

    Santosh Rao

    Architect

    India India

    Member

    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


    Sign Up to vote   Poor Excellent
    Add a reason or comment to your vote: x
    Votes of 3 or less require a comment

    Comments and Discussions

     
    You must Sign In to use this message board. (secure sign-in)
     
    Search this forum  
     FAQ
        Noise  Layout  Per page   
      Refresh
    Questionthanks for you share Pinmemberxiangxiangli3:42 28 May '12  
    GeneralExist a decompiler for a file compile with MS Agent (.acf file) PinmemberTheCodeVB11:48 13 Feb '11  
    GeneralAstonished to Pinmemberbahgat youw3:54 20 Mar '09  
    GeneralUser interaction Pinmemberfrwa11:49 9 Jan '09  
    QuestionHow would you list all the available voices? Pinmemberprudnik6:02 18 Dec '07  
    So far I like your wrapper, but when it comes to listing all available voices neither your programm, nor that of another article on this site on the same subject gives an answer. Maybe it is too simple? So far I could only spot solutions in Visual Basic.
    Any solutions on this subject should in my view answer some simple questions first:
     
    1. is MS agent available on a computer?
    2. what are the available characters?
    3. what are the available voices/languages (I am not sure if there is a distinction, I believe a voice can speak different languages, but then a voice would be almost the same as a character, whereas the idea is to have characters be able to have different voices, which is maybe somewhat odd)
    4. What are the gestures/animations, that a character can do?
     
    Your program answers önly question 4. Why?
    prudnik 18.12.07
    prudnik

    QuestionThermal measurement project Pinmemberisraa mohammed23:23 23 Nov '07  
    GeneralConext menu in MS Agent control Pinsussneetu gahlot19:23 23 Sep '05  
    GeneralBorland C++ BuilderX compatible? (how to) PinmemberMillyard11:48 16 Mar '05  
    Generaldisplay indexed msg Pinmemberbayue17:18 27 Dec '04  
    Generaladd ms agent to my webpage without uploding it Pinmemberbayue16:40 27 Dec '04  
    Generalautomaticly recording Pinmembermenag3:19 2 Nov '04  
    QuestionHow to mix animation with speech PinsussAnonymous8:51 13 May '04  
    Generalordinal 5076 PinsussAnonymous7:14 18 Nov '03  
    GeneralRe: ordinal 5076 PinsussAnonymous22:47 21 Mar '05  
    GeneralAssertion with Dev 7... PinmemberLilMoke18:06 25 Oct '03  
    GeneralRe: Assertion with Dev 7... PinmemberLilMoke4:11 26 Oct '03  
    GeneralSame Compile Error Pinmemberalan935:10 30 Sep '03  
    GeneralOrdinal 5077 & 5076 PinmemberSanjin11:44 17 Dec '02  
    GeneralRe: Ordinal 5077 & 5076 PinmemberTeisDraiby10:16 27 Dec '02  
    GeneralRe: Ordinal 5077 & 5076 PinmemberBill94420:05 21 Sep '03  
    GeneralRe: Ordinal 5077 & 5076 PinsussAnonymous8:44 23 Jun '03  
    GeneralGreat Job! PinmemberPaul Kissel20:20 13 Dec '02  
    GeneralSome help!! PinsussAnonymous17:37 11 Oct '02  
    QuestionWhy did Error happen when I added ActiveX control? PinmemberAnonymous17:22 8 Jul '02  
    GeneralMS Access versus MS Agent PinmemberRobert Goyvaerts12:13 21 May '02  

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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 | Mobile
    Web02 | 2.5.120529.1 | Last Updated 4 Mar 2000
    Article Copyright 2000 by Santosh Rao
    Everything else Copyright © CodeProject, 1999-2012
    Terms of Use
    Layout: fixed | fluid