Click to return to the Microsoft Agent home page    
Web Workshop  |  Streaming & Interactive Media  |  Microsoft Agent

Programming the Microsoft Agent Server Interface


ActiveX® technology for interactive software agents

Microsoft Corporation

October 1998

DownloadDownload this document in Microsoft Word (.DOC) format (zipped, 73K).

Contents
Introduction
Adding Microsoft Agent Functionality to Your Application
Loading Character and Animation Data
Creating a Notification Sink
Accessing Services Using Java
Accessing Speech Services
Reference

Introduction

Microsoft Agent provides services that enable you to program animated characters from an application. These services are implemented as an OLE Automation server. OLE Automation enables an application to control another application's object programmatically. This document assumes an understanding of the Component Object Model (COM) and OLE. For an introduction of these services, see the Programming Interface Overview. Sample programs are available at the Microsoft Agent Web site at http://msdn.microsoft.com/msagent/.

Adding Microsoft Agent Functionality to Your Application

To access Microsoft Agent's server interfaces, Agent must already be installed on the target system. If you want to install Microsoft Agent as part of your application, you must have a valid distribution license for Agent. You can access the License Agreement from the Microsoft Agent Web site.

You can then download Agent's self-installing cabinet file from the Web site (using the Save rather than the Run option). You can include this file in your installation setup program. Whenever it is executed, it will automatically install Agent on the target system. For further details on installation, see the Microsoft Agent Distribution License Agreement. Installation other than using Agent's self-installing cabinet file, such as attempting to copy and register Agent component files, is not supported. This ensures consistent and complete installation. Note that the Microsoft Agent self-installing file will not install on Microsoft Windows 2000 (NT5) because that version of the operating system already includes its own version of Agent.

To successfully install Agent on a target system, you must also ensure that the target system has a recent version of the Microsoft Visual C++ runtime (Msvcrt.dll), Microsoft registration tool (Regsvr32.dll), and Microsoft COM dlls. The easiest way to ensure that the necessary components are on the target system is to require that Microsoft Internet Explorer 3.02 or later is installed. Alternatively, you can install the first two components which are available as part of Microsoft Visual C++. The necessary COM dlls can be installed as part of the Microsoft DCOM update, available at the Microsoft Web site. You can find further information and licensing information for these components at the Microsoft Web site.

Agent's language components can be installed the same way. Similarly, you can use this technique to install the ACS format of the Microsoft characters available for distribution from the Microsoft Agent Web site. The character files automatically install to the Microsoft Agent \Chars subdirectory.

Because Microsoft Agent's components are designed as operating system components, Agent may not be uninstalled. Similarly, where Agent is already installed as a part of the Windows operating system, the Agent self-installing cabinet may not install.

Once installed, to call Agent's interfaces, create an instance of the server and request a pointer to a specific interface that the server supports using the standard COM convention. In particular, the COM library provides an API function, CoCreateInstance, that creates an instance of the object and returns a pointer to the requested interface of the object. Request a pointer to the IAgent or IAgentEx interface in your CoCreateInstance call or in a subsequent call to QueryInterface.

The following code illustrates this in C/C++:

hRes = CoCreateInstance(CLSID_AgentServer,
                     NULL,
                     CLSCTX_SERVER,
                     IID_IAgentEx,
                     (LPVOID *)&pAgentEx);

If the Microsoft Agent server is running, this function connects to the server; otherwise, it starts up the server.

Note that the Microsoft Agent server interfaces often include extended interfaces that include an "Ex" suffix. These interfaces are derived from, and therefore include all the functionality of, their non-Ex counterparts. If you want to use any of the extended features, use the Ex interfaces.

Functions that take pointers to BSTRs allocate memory using SysAllocString. It is the caller's responsibility to free this memory using SysFreeString.

TopBack to top

Loading Character and Animation Data

Once you have a pointer to the IAgentEx interface, you can use the Load method to load a character and retrieve its |AgentCharacterEx interface. There are three different possibilities for the Load path of a character. The first is compatible with Microsoft Agent 1.5 where the specified path is the full path and filename of a character file. The second possibility is to specify the filename only, in which case, Agent looks in its Chars directory. The last possibility is to supply an empty Variant parameter that causes the default character to be loaded.

   // Create a variant to store the filename of the character to load

const LPWSTR kpwszCharacter = L"merlinACS";

   VariantInit(&vPath);

   vPath.vt = VT_BSTR;
   vPath.bstrVal = SysAllocString(kpwszCharacter);

   // Load the character

   hRes = pAgentEx->Load(vPath, &lCharID, &lRequestID);

   // Get its IAgentCharacterEx interface

   hRes = pAgentEx->GetCharacterEx(lCharID, &pCharacterEx);

You can use this interface to access the character's methods:

   // Show the character.  The first parameter tells Microsoft
   // Agent to show the character by playing an animation.

   hRes = pCharacterEx->Show(FALSE, &lRequestID);

   // Make the character speak

   bszSpeak = SysAllocString(L"Hello World!");

   hRes = pCharacterEx->Speak(bszSpeak, NULL, &lRequestID);

   SysFreeString(bszSpeak);

When you no longer need Microsoft Agent services, such as when your client application shuts down, release its interfaces. Note that releasing the character interface does not unload the character. Call the Unload method to do this before releasing the IAgentEx interface:

// Clean up

if (pCharacterEx) {

   // Release the character interface

   pCharacterEx->Release();

   // Unload the character.  NOTE:  releasing the character
   // interface does NOT make the character go away.  You must
   // call Unload.

   pAgentEx->Unload(lCharID);
}
   
// Release the Agent

pAgentEx->Release();

VariantClear(&vPath);

TopBack to top

Creating a Notification Sink

To be notified of events by Microsoft Agent, you must implement either the IAgentNotifySink or the IAgentNotifySinkEx interface, and create and register an object of that type following COM conventions:

// Create a notification sink

pSinkEx = new AgentNotifySinkEx;

pSinkEx->AddRef();

// And register it with Microsoft Agent

hRes = pAgentEx->Register((IUnknown *)pSinkEx, &lNotifySinkID);

Remember to unregister your notification sink when your application shuts down and releases Microsoft Agent's interfaces.

TopBack to top

Accessing Services Using Java

You can also access Microsoft Agent services from a Java applet. Many of the functions accessible through the Microsoft Agent interfaces return values through parameters passed by reference. In order to pass these parameters from Java, it is necessary to create single-element arrays in your code and pass them as parameters to the appropriate function. If you're using Microsoft Visual J++™ and have run the Java Type Library Wizard on the Microsoft Agent server, refer to the summary.txt file to review which functions require array arguments. The procedure is similar to that in C; you use the IAgentEx interface to create an instance of the server, then load the character:

private IAgentEx            m_AgentEx = null;
private IAgentCharacterEx   m_Merlin[] = {null};
private int                 m_MerlinID[] = {-1};
private int                 m_RequestID[] = {0};
private final String        m_CharacterPath = " merlinACS";

public void start()
{
      // Start the Microsoft Agent Server

      m_AgentEx = (IAgentEx) new AgentServer();

      try
      {
         // The filespec parameter of the Load method is a 
         // COM variant to accept alternate Agent data providers.
         // We want a standard provider so we can just specify
         // the filespec for our character.

         Variant characterPath = new Variant();
         characterPath.putString(m_CharacterPath);

         // Load the character

         m_AgentEx.Load(characterPath,
                    m_MerlinID,
                    m_RequestID);
      }



The procedure is slightly different when loading characters from a HTTP remote location such as a Web site. In this case the Load method is asynchronous and will raise a COM exception of E_PENDING (0x8000000a). You will need to catch this exception and handle it correctly as is done in the following functions:

// Constants used in asynchronous character loads

private final int E_PENDING = 0x8000000a;
private final int NOERROR = 0;


// This function loads a character from the specified path.
// It correctly handles the loading of characters from
// remote sites.

// This sample doesn't care about the request id returned
// from the Load call.  Real production code might use the
// request id and the RequestComplete callback to check for
// a successful character load before proceeding.

public int LoadCharacter(Variant path, int[] id)
{
   int requestid[] = {-1};
   int hRes = 0;

   try
   {
      // Load the character

      m_AgentEx.Load(path, id, requestid);
   }
   catch(com.ms.com.ComException e)
   {
      // Get the HRESULT

      hRes = e.getHResult();
      
      // If the error code is E_PENDING, we return NOERROR

      if (hRes == E_PENDING)
         hRes = NOERROR;
   }

   return hRes;
}

public void start()
{
   if (LoadCharacter(characterPath, m_MerlinID) != NOERROR)
   {
      stop();
      return;
   }

   // Other initialization code here

   .
   .
   .
}

Then get the IAgentCharacterEx interface that enables you to access its methods:

// Get the IAgentCharacterEx interface for the loaded
// character by passing its ID to the Agent server.

m_AgentEx.GetCharacterEx(m_MerlinID[0], m_Merlin);

// Show the character

m_Merlin[0].Show(FALSE, m_RequestID);

// And speak hello

m_Merlin[0].Speak("Hello World!", "", m_RequestID);

Similarly, to be notified of events, you must implement either the IAgentNotifySink or/P>

...
// Declare an Agent Notify Sink so that we can get
// notification callbacks from the Agent server.

private AgentNotifySinkEx m_SinkEx = null;
private int            m_SinkID[] = {-1};

public void start()
   {
   ...
   // Create and register a notify sink

   m_SinkEx = new AgentNotifySinkEx();

   m_AgentEx.Register(m_SinkEx, m_SinkID);
   …
   // Give our notify sink access to the character

   m_SinkEx.SetCharacter(m_Merlin[0]);
   ...
   }

In order to access Microsoft Agent from a Java applet, you must generate Java classes that you install with the applet. You can use the Visual J++ Java Type Library Wizard, for example, to generate these files. If you plan to host the applet on a Web page, you will need to build a signed Java CAB inclusive of the generated class files that download with the page. The class files are necessary to access the Microsoft Agent Server since it is a COM object, that executes outside of the Java sandbox. To learn more about Trust-Based Security for Java, see http://www.microsoft.com/java/security/ Non-MSDN Online link.

TopBack to top

Accessing Speech Services

Although Microsoft Agent's services include support for speech input, a compatible command-and-control speech recognition engine must be installed to access Agent's speech input services. Similarly, if you want to use Microsoft Agent's speech services to support synthesized speech output for a character, you must install a compatible text-to-speech (TTS) speech engine for your character. Because Microsoft Agent's speech services are based on the Microsoft Speech API (SAPI), you can use any engines that compatibly support the required speech interfaces. Further information on the availability and use of speech recognition and text-to-speech engines is at the Microsoft Agent Downloads for Developers page.

To enable speech input support in your application, define a Command object and set its Voice property. Microsoft Agent will automatically load speech services, so that when the user presses the Listening key or you call Listen, the speech recognition engine will be loaded. By default the character's language ID will determine which engine is loaded. Agent attempts to load the first engine that SAPI returns as matching this language. Use IAgentCharacterEx::SetSRModeID if you want to load a specific engine.

To enable text-to-speech output, use the Speak method. Microsoft Agent will automatically attempt to load an engine that matches the character's language ID. If the character's definition includes a specific TTS engine mode ID and that engine is available and matches the character's language ID, Agent loads that engine for the character. If not, Agent loads the first TTS engine that SAPI returns as matching the character's language setting. You can also use IAgentCharacterEx::SetTTSModeID to load a specific engine.

Typically, Microsoft Agent loads a speech recognition engine when the Listening mode is initiated and loads a text-to-speech engine when Speak is first called. However, if you want to preload the speech engine, you can do this by querying the properties related to the speech interfaces. For example, calling IAgentCharacterEx::GetSRModeID or IAgentCharacterEx::GetTTSModeID will attempt to load that type of engine.

TopBack to top

Reference

This reference contains the following sections:

Interfaces

Events

Interfaces

Microsoft Agent defines interfaces that allow applications to access its services, enabling an application to control the animation of a character, support user input events, and specify output.

All the Microsoft Agent interfaces are defined in header (.h) files.

IAgent

IAgent defines an interface that allows applications to load characters, receive events, and check the current state of the Microsoft Agent Server. These functions are also available from IAgentEx.

The GetSuspended method included in previous versions is obsolete and returns False for backward compatibility.

Methods in Vtable Order
IAgent Methods Description
Load Loads a character's data file.
Unload Unloads a character's data file.
Register Registers a notification sink for the client.
Unregister Unregisters a client's notification sink.
GetCharacter Returns the IAgentCharacter interface for a loaded character.

IAgent::GetCharacter

HRESULT GetCharacter(
   long dwCharID  // character ID
);

Retrieves the IAgentCharacter for a loaded character.

DwCharID

The character's ID.


IAgent::Load

HRESULT Load(
   VARIANT vLoadKey,  // data provider
   long * pdwCharID,  // address of a variable for character ID
   long * pdwReqID    // address of a variable for request ID
);

Loads a character into the Characters collection.

vLoadKey

A variant datatype that must be one of the following:

filespec The local file location of the specified character's definition file.
URL The HTTP address for the character's definition file.
provider An alternate character definition provider.

pdwCharID

Address of a variable that receives the character's ID.

pdwReqID

Address of a variable that receives the Load request ID.

You can load characters from the Microsoft Agent subdirectory by specifying a relative path (one that does not include a colon or leading slash character). This prefixes the path with Agent's characters directory (located in the localized %windows%\msagent directory). You can also use a relative address to specify your own directory in Agent's Chars directory.

You cannot load the same character (a character having the same GUID) more than once from a single connection. Similarly, you cannot load the default character and other characters at the same time from a single connection. The default character could be the same as the other character. However, you can create another connection (using CoCreateInstance) and load the same character.

Microsoft Agent's data provider supports loading character data stored as a single structured file (ACS) with character data and animation data together, or as separate character data (ACF) and animation (ACA) files. Generally, use the single structured ACS file to load a character that is stored on a local disk drive or network and accessed using conventional file protocol (such as UNC pathnames). Use the separate ACF and ACA files when you want to load the animation files individually from a remote site where they are accessed using HTTP protocol.

For ACS files, using the Load method provides access a character's animations; once loaded, you can use the Play method to animate the character. For ACF files, you also use the Prepare method to load animation data. The Load method does not support downloading ACS files from an HTTP site.

Loading a character does not automatically display the character. Use the Show method first to make the character visible.


IAgent::Register

HRESULT Register(
   IUnknown * punkNotifySink  // IUnknown address for client notification sink
   long * pdwSinkID           // address of the notification sink ID
);

Registers a notification sink for the client application.

IUnknown

Address of IUnknown for your notification sink interface.

pdwSinkID

Address of notification sink ID (used to unregister the notification sink).

You need to register your notification sink (also known as a notify sink or event sink) to receive events from the Microsoft Agent server.

See also IAgent::Unregister


IAgent::UnLoad

HRESULT UnLoad(
   long * dwCharID  //character ID
);

Unloads the character data for the specified character from the Characters collection.

dwCharID

The character's ID.

Use this method when you no longer need a character, to free up memory used to store information about the character. If you access the character again, use the Load method.

See also IAgent::Load


IAgent::Unregister

HRESULT Unregister(
   long dwSinkID  //notification sink ID
);

Unloads the character data for the specified character from the Characters collection.

dwSinkID

The notification sink ID.

Use this method when you no longer need Microsoft Agent services, such as when your application shuts down.

See also IAgent::Register


IAgentEx

IAgentEx is derived from the IAgent interface. It includes all the IAgent methods as well as provides access to additional functions.

Methods in Vtable Order
IAgentEx Methods Description
ShowDefaultCharacterProperties Displays the default character properties.
GetVersion Returns the version number for Microsoft Agent (server).

IAgentEx::ShowDefaultCharacterProperties

HRESULT ShowDefaultCharacterProperties(
   short x,          // x-coordinate of window
   short y,          // y-coordinate of window
   long bUseDefault  // default position flag
);

Displays default character properties window.

x

The x-coordinate of the window in pixels, relative to the screen origin (upper left).

y

The y-coordinate of the window in pixels, relative to the screen origin (upper left).

bUseDefault

Default position flag. If this parameter is True, Microsoft Agent displays the property sheet window for the default character at the last location it appeared.

Note For Windows 2000, it may be necessary to call the new AllowSetForegroundWindow API to ensure that this window becomes the foreground window. For more information about setting the foreground window under Windows 2000, see the Win32® documentation.

See also IAgentNotifySinkEx::DefaultCharacterChange


IAgentEx::GetVersion

HRESULT GetVersion(
   short * psMajor,  // address of major version
   short * psMinor   // address of minor version
);

Retrieves the version number of Microsoft Agent server.

psMajor

Address of a variable that receives the major version.

psMinor

Address of a variable that receives the minor version.


IAgentCharacter

IAgentCharacter defines an interface that allows applications to query character properties and play animations. These functions are also available from IAgentCharacterEx. You can use some method return request IDs to track their status in the character's queue and to synchronize your code with the character's current animation state.

Methods in Vtable Order
IAgentCharacter Methods Description
GetVisible Returns whether the character (frame) is currently visible.
SetPosition Sets the position of the character frame.
GetPosition Returns the position of the character frame.
SetSize Sets the size of the character frame.
GetSize Returns the size of the character frame.
GetName Returns the name of the character.
GetDescription Returns the description for the character.
GetTTSSpeed Returns the current TTS output speed setting for the character.
GetTTSPitch Returns the current TTS pitch setting for the character.
Activate Sets whether a client is active or a character is topmost.
SetIdleOn Sets the server's idle processing.
GetIdleOn Returns the setting of the server's idle processing.
Prepare Retrieves animation data for the character.
Play Plays a specified animation.
Stop Stops an animation for a character.
StopAll Stops all animations for a character.
Wait Holds the character's animation queue.
Interrupt Interrupts a character's animation.
Show Displays the character and plays the character's Showing state animation.
Hide Plays the character's Hiding state animation and hides the character's frame.
Speak Plays spoken output for the character.
MoveTo Moves the character frame to the specified location.
GestureAt Plays a gesturing animation based on the specified location.
GetMoveCause Retrieves the cause of the character's last move.
GetVisibilityCause Retrieves the cause of the last change to the character's visibility state.
HasOtherClients Retrieves whether the character has other current clients.
SetSoundEffectsOn Determines whether a character animation's sound effects play.
GetSoundEffectsOn Retrieves whether a character's sound effects setting is enabled.
SetName Sets the character's name.
SetDescription Sets the character's description.
GetExtraData Retrieves additional data stored with the character.

IAgentCharacter::Activate

HRESULT Activate(
   short sState, // topmost character or client setting
);

Sets whether a client is active or a character is topmost.

sState

You can specify the following values for this parameter:
0 Set as not the active client.
1 Set as the active client.
2 Make the topmost character.

When multiple characters are visible, only one of the characters receives speech input at a time. Similarly, when multiple client applications share the same character, only one of the clients receives mouse input (for example, Microsoft Agent control click or drag events) at a time. The character set to receive mouse and speech input is the topmost character and the client that receives input is the character's active client. (The topmost character's window also appears at the top of the character window's z-order.) Typically, the user determines which character is topmost by explicitly selecting it. However, topmost activation also changes when a character is shown or hidden (the character becomes or is no longer topmost, respectively.)

You can also use this method to explicitly manage when your client receives input directed to the character, such as when your application itself becomes active. For example, setting State to 2 makes the character topmost, and your client receives all mouse and speech input events generated from user interaction with the character. Therefore, it also makes your client the input-active client of the character. However, you can also set the active client for a character without making the character topmost, by setting State to 1. This enables your client to receive input directed to that character when the character becomes topmost. Similarly, you can set your client to not be the active client (to not receive input) when the character becomes topmost, by setting State to 0. You can determine if a character has other current clients using IAgentCharacter::HasOtherClients.

Avoid calling this method directly after a Show method. Show automatically sets the input-active client. When the character is hidden, the Activate call may fail, if it gets processed before the Show method completes.

Attempting to call this method with the State parameter set to 2 (when the specified character is hidden) will fail. Similarly, if you set State to 0, and your application is the only client, this call fails. A character must always have a topmost client.

Note Calling this method with State set to 1 does not typically generate an AgentNotifySink::ActivateInputState event unless there are no other characters loaded or your application is already input-active.

See also IAgentCharacter::HasOtherClients


IAgentCharacter::GestureAt

HRESULT GestureAt(
   short x,         // x-coordinate of specified location
   short y,         // y-coordinate of specified location
   long * pdwReqID  // address of a request ID
);

Plays the associated Gesturing state animation based on the specified location.

x

The x-coordinate of the specified location in pixels, relative to the screen origin (upper left).

y

The y-coordinate of the specified location in pixels, relative to the screen origin (upper left).

pdwReqID

Address of a variable that receives the GestureAt request ID.

The server automatically determines and plays the appropriate gesturing animation based on the character's current position and the specified location. When using the HTTP protocol to access character and animation data, use the Prepare method to ensure that the animations are available before calling this method.


IAgentCharacter::GetDescription

HRESULT GetDescription(
   BSTR * pbszDescription   // address of buffer for character description
); 

Retrieves the description of the character.

pbszDescription

The address of a BSTR that receives the value of the description for the character. A character's description is defined when it is compiled with the Microsoft Agent Character Editor. The description setting is optional and may not be supplied for all characters.


IAgentCharacter::GetExtraData

HRESULT GetExtraData(
   BSTR * pbszExtraData   // address of buffer for additional character data
); 

Retrieves additional data stored as part of the character.

pbszExtraData

The address of a BSTR that receives the value of the additional data for the character. A character's additional data is defined when it is compiled with the Microsoft Agent Character Editor. A character developer can supply this string by editing the .ACD file for a character. The setting is optional and may not be supplied for all characters, nor can the data be defined or changed at run time. In addition, the meaning of the data supplied is defined by the character developer.


IAgentCharacter::GetIdleOn

HRESULT GetIdleOn(
   long * pbOn  // address of idle processing flag
);

Indicates the automatic idle processing state for a character.

pbOn

Address of a variable that receives True if the Microsoft Agent server automatically plays Idling state animations for a character and False if not.

See also IAgentCharacter::SetIdleOn


IAgentCharacter::GetMoveCause

HRESULT GetMoveCause(
   long * pdwCause  // address of variable for cause of character move
);

Retrieves the cause of the character's last move.

pdwCause

Address of a variable that receives the cause of the character's last move and will be one of the following:

const unsigned short NeverMoved = 0; Character has not been moved.
const unsigned short UserMoved = 1; User dragged the character.
const unsigned short ProgramMoved = 2; Your application moved the character.
const unsigned short OtherProgramMoved = 3; Another application moved the character.
const unsigned short SystemMoved = 4 The server moved the character to keep it onscreen after a screen resolution change.

See also IAgentNotifySink::Move


IAgentCharacter::GetName

HRESULT GetName(
   BSTR * pbszName   // address of buffer for character name
);

Retrieves the name of the character.

pbszName

The address of a BSTR that receives the value of the name for the character.

A character's default name is defined when it is compiled with the Microsoft Agent Character Editor. A character's name may vary based on the character's language ID. Characters can be compiled with different names for different languages.

You can also set the character's name using IAgentCharacter:SetName; however, this changes the name for all current clients of the character.

See also IAgentCharacter::SetName


IAgentCharacter::GetPosition

HRESULT GetPosition(
   long * plLeft,  // address of variable for left edge of character 
   long * plTop    // address of variable for top edge of character 
);

Retrieves the character's animation frame position.

plLeft

Address of a variable that receives the screen coordinate of the character animation frame's left edge in pixels, relative to the screen origin (upper left).

plTop

Address of a variable that receives the screen coordinate of the character animation frame's top edge in pixels, relative to the screen origin (upper left).

Even though the character appears in an irregularly shaped region window, the location of the character is based on its rectangular animation frame.

See also IAgentCharacter::SetPosition, IAgentCharacter::GetSize


IAgentCharacter::GetSize

HRESULT GetSize(
   long * plWidth,  // address of variable for character width 
   long * plHeight  // address of variable for character height
);

Retrieves the size of the character's animation frame.

plWidth

Address of a variable that receives the width of the character animation frame in pixels, relative to the screen origin (upper left).

plHeight

Address of a variable that receives the height of the character animation frame in pixels, relative to the screen origin (upper left).

Even though the character appears in an irregularly shaped region window, the location of the character is based on its rectangular animation frame.

See also IAgentCharacter::SetSize


IAgentCharacter::GetSoundEffectsOn

HRESULT GetSoundEffectsOn(
   long * pbOn  // address of variable for sound effects setting 
);

Retrieves whether the character's sound effects setting is enabled.

pbOn

Address of a variable that receives True if the character's sound effects setting is enabled, False if disabled.

The character's sound effects setting determines whether sound effects compiled as a part of the character are played when you play an associated animation. The setting is subject to the user's global sound effects setting in IAgentAudioOutputProperties::GetUsingSoundEffects.

See also IAgentCharacter::SetSoundEffectsOn, IAgentAudioOutputProperties::GetUsingSoundEffects


IAgentCharacter::GetTTSPitch

HRESULT GetTTSPitch(
   long * pdwPitch  // address of variable for character TTS pitch
);

Retrieves the character's TTS output pitch setting.

pdwPitch

Address of a variable that receives the character's current TTS pitch setting in Hertz.

Although your application cannot write this value, you can include pitch tags in your output text that will temporarily increase the pitch for a particular utterance. This method applies only to characters configured for TTS output. If the speech synthesis (TTS) engine is not enabled (or installed) or the character does not support TTS output, this method returns zero (0).


IAgentCharacter::GetTTSSpeed

HRESULT GetTTSSpeed(
   long * pdwSpeed  // address of variable for character TTS output speed
);

Retrieves the character's TTS output speed setting.

pdwSpeed

Address of a variable that receives the output speed of the character in words per minute.

Although your application cannot write this value, you can include speed tags in your output text that will temporarily speed up the output for a particular utterance.

This property returns the current speaking output speed setting for the character. For characters using TTS output, the property returns the actual TTS output for the character. If TTS is not enabled or the character does not support TTS output, the setting reflects the user setting for output speed.


IAgentCharacter::GetVisibilityCause

HRESULT GetVisibilityCause(
   long * pdwCause  // address of variable for cause of character visible state
);

Retrieves the cause of the character's visible state.

pdwCause

Address of a variable that receives the cause of the character's last visibility state change and will be one of the following:

const unsigned short NeverShown = 0; Character has not been shown.
const unsigned short UserHid = 1; User hid the character with the character's taskbar icon pop-up menu or using speech input.
const unsigned short UserShowed = 2; User showed the character.
const unsigned short ProgramHid = 3; Your application hid the character.
const unsigned short ProgramShowed = 4; Your application showed the character.
const unsigned short OtherProgramHid = 5; Another application hid the character.
const unsigned short OtherProgramShowed = 6; Another application showed the character.
const unsigned short UserHidViaCharacterMenu = 7 User hid the character with the character's pop-up menu.
const unsigned short UserHidViaTaskbarIcon = UserHid User hid the character with the character's taskbar icon pop-up menu or using speech input.

See also IAgentNotifySink::VisibleState


IAgentCharacter::GetVisible

HRESULT GetVisible(
   long * pbVisible  // address of variable for character Visible setting
);

Determines whether the character's animation frame is currently visible.

pbVisible

Address of a variable that receives True if the character's frame is visible and False if hidden.

You can use this method to determine whether the character's frame is currently visible. To make a character visible, use the Show method. To hide a character, use the Hide method.


IAgentCharacter::HasOtherClients

HRESULT HasOtherClients(
   long * plNumOtherClients  // address of variable for number of clients 
);                           // for character 

Retrieves whether a character has other clients.

plNumOtherClients

Address of a variable that receives the number of other connected clients for the character (total number of clients minus your client).


IAgentCharacter::Hide

HRESULT Hide(
   long bFast,      // play Hiding state animation flag
   long * pdwReqID  // address of request ID
);

Hides the character.

bFast

Hiding state animation flag. If this parameter is True, the Hiding animation does not play before the character frame is hidden; if False, the animation plays.

pdwReqID

Address of a variable that receives the Hide request ID.

The server queues the animation associated with the Hide method in the character's queue. This allows you to use it to hide the character after a sequence of other animations. You can play the action immediately by using the Stop method before calling the Hide method.

When using the HTTP protocol to access character and animation data, use the Prepare method to ensure the availability of the Hiding state animation before calling this method.

Hiding a character can also result in triggering the AgentNotifySink::ActivateInputState event of another visible character.

Hidden characters cannot access the audio channel. The server will pass back a failure status in the RequestComplete event if you generate an animation request and the character is hidden.

See also IAgentCharacter::Show


IAgentCharacter::Interrupt

HRESULT Interrupt(
   long dwReqID,    // request ID to interrupt
   long * pdwReqID  // address of request ID
);

Interrupts the specified animation (request) of another character.

dwReqID

An ID of the request to interrupt.

pdwReqID

Address of a variable that receives the Interrupt request ID.

If you load multiple characters, you can use this method to sync up animation between characters. For example, if another character is in a looping animation, this method will stop the looping animation and start the next animation in the character's queue.

Interrupt halts the existing animation, but does not flush the character's animation queue. It starts the next animation in the character's queue. To halt and flush a character's queue, use the Stop method.

You cannot use this method to have a character interrupt itself because the Microsoft Agent server queues the Interrupt method in the character's animation queue. Therefore, you can only use Interrupt to halt the animation of another character you have loaded.


IAgentCharacter::MoveTo

HRESULT MoveTo(
   short x,         // x-coordinate of new location
   short y,         // y-coordinate of new location
   long lSpeed,     // speed to move the character
   long * pdwReqID  // address of request ID
);

Plays the associated Moving state animation and moves the character frame to the specified location.

x

The x-coordinate of the new position in pixels, relative to the screen origin (upper left). The location of a character is based on the upper left corner of its animation frame.

y

The y-coordinate of the new position in pixels, relative to the screen origin (upper left). The location of a character is based on the upper left corner of its animation frame.

lSpeed

A parameter specifying in milliseconds how quickly the character's frame moves. The recommended value is 1000. Specifying zero (0) moves the frame without playing an animation.

pdwReqID

Address of a variable that receives the MoveTo request ID.

When using the HTTP protocol to access character and animation data, use the Prepare method to ensure the availability of the Moving state animations before calling this method. Even if the animation is not loaded, the server still moves the frame.

See also IAgentCharacter::SetPosition


IAgentCharacter::Play

HRESULT Play(
   BSTR bszAnimation,  // name of an animation
   long * pdwReqID     // address of request ID
);

Plays the specified animation.

bszAnimation

The name of an animation.

pdwReqID

Address of a variable that receives the IAgentCharacter::Play request ID.

An animation's name is defined when the character is compiled with the Microsoft Agent Character Editor. Before playing the specified animation, the server attempts to play the Return animation for the previous animation (if one has been assigned).

When a character's animation data is stored on the user's local machine, you can use the IAgentCharacter::Play method and specify the name of the animation. When using the HTTP protocol to access animation data, use the Prepare method to ensure the availability of the animation before calling this method.

See also IAgentCharacter::Prepare


IAgentCharacter::Prepare

HRESULT Prepare(
   long dwType,     // type of animation data to load
   BSTR bszName,    // name of the animation 
   long bQueue,     // queue the request
   long * pdwReqID  // address of request ID
);

Retrieves animation data for a character.

dwType

A value that indicates the animation data type to load that must be one of the following:

const unsigned short PREPARE_ANIMATION = 0; A character's animation data.
const unsigned short PREPARE_STATE = 1; A character's state data.
const unsigned short PREPARE_WAVE = 2 A character's sound file (.WAV or .LWV) for spoken output.

bszName

The name of the animation or state.

The animation name is based on that defined for the character when it was saved using the Microsoft Agent Character Editor.

For states, the value can be one of the following:

"Gesturing" To retrieve all Gesturing state animations.
"GesturingDown" To retrieve GesturingDown animations.
"GesturingLeft" To retrieve GesturingLeft animations.
"GesturingRight" To retrieve GesturingRight animations.
"GesturingUp" To retrieve GesturingUp animations.
"Hiding" To retrieve the Hiding state animations.
"Hearing" To retrieve the Hearing state animations.
"Idling" To retrieve all Idling state animations.
"IdlingLevel1" To retrieve all IdlingLevel1 animations.
"IdlingLevel2" To retrieve all IdlingLevel2 animations.
"IdlingLevel3" To retrieve all IdlingLevel3 animations.
"Listening" To retrieve the Listening state animations.
"Moving" To retrieve all Moving state animations.
"MovingDown" To retrieve all Moving animations.
"MovingLeft" To retrieve all MovingLeft animations.
"MovingRight" To retrieve all MovingRight animations.
"MovingUp" To retrieve all MovingUp animations.
"Showing" To retrieve the Showing state animations.
"Speaking" To retrieve the Speaking state animations.

For .WAV files, set bszName to the URL or file specification for the .WAV file. If the specification is not complete, it is interpreted as being relative to the specification used in the Load method.

bQueue

A Boolean specifying whether the server queues the Prepare request. True queues the request and causes any animation request that follows it to wait until the animation data it specifies is loaded. False retrieves the animation data asynchronously.

pdwReqID

Address of a variable that receives the Prepare request ID.

If you load a character using the HTTP protocol (an ACF file), you must use the Prepare method to retrieve animation data before you can play the animation. You cannot use this method if you loaded the character using the UNC protocol (an ACS file). You also cannot retrieve HTTP data for a character using Prepare if you loaded that character using the UNC protocol (ACS character file).

Animation or sound data retrieved with the Prepare method is stored in the browser's cache. Subsequent calls will check the cache, and if the animation data is already there, the control loads the data directly from the cache. Once loaded, the animation or sound data can be played with the Play or Speak methods.

You can specify multiple animations and states by separating them with commas. However, you cannot mix types in the same Prepare statement.


IAgentCharacter::SetDescription

HRESULT SetDescription(
   BSTR bszDescription   // character description
); 

Sets the description of the character.

bszDescription

A BSTR that sets the description for the character. A character's default description is defined when it is compiled with the Microsoft Agent Character Editor. The description setting is optional and may not be supplied for all characters. You can change the character's description using IAgentCharacter::SetDescription; however, this value is not persistent (stored permanently). The character's description reverts to its default setting whenever the character is first loaded by a client.

See also IAgentCharacter::GetDescription


IAgentCharacter::SetIdleOn

HRESULT SetIdleOn(
   long bOn  // idle processing flag
);

Sets automatic idle processing for a character.

bOn

Idle processing flag. If this parameter is True, the Microsoft Agent automatically plays Idling state animations.

The server automatically sets a time out after the last animation played for a character. When this timer's interval is complete, the server begins the Idling states for a character, playing its associated Idling animations at regular intervals. If you want to manage the Idling state animations yourself, set the property to False. This property applies only to your client application's use of the character; the setting does not affect other clients of the character or other characters of your client application.

See also IAgentCharacter::GetIdleOn


IAgentCharacter::SetName

HRESULT SetName(
   BSTR bszName   // character name
);

Sets the name of the character.

bszName

A BSTR that sets the character's name. A character's default name is defined when it is compiled with the Microsoft Agent Character Editor. You can change it using IAgentCharacter::SetName; however, this changes the character name for all current clients of the character. This property is not persistent (stored permanently). The character's name reverts to its default name whenever the character is first loaded by a client.

The character's name may also depend on its language ID. Characters can be compiled with different names for different languages.

The server uses the character's name setting in parts of the Microsoft Agent's interface, such as the Voice Commands Window title when the character is input-active and in the Microsoft Agent taskbar pop-up menu.

See also IAgentCharacter::GetName


IAgentCharacter::SetPosition

HRESULT SetPosition(
   long lLeft,  // screen coordinate of the left edge of character 
   long lTop    // screen coordinate of the top edge of character 
);

Sets the position of the character's animation frame.

lLeft

Screen coordinate of the character animation frame's left edge in pixels, relative to the screen origin (upper left).

lTop

Screen coordinate of the character animation frame's top edge in pixels, relative to the screen origin (upper left).

This property's setting applies to all clients of the character. Even though the character appears in an irregularly shaped region window, the location of the character is based on its rectangular animation frame.

Note Unlike the MoveTo method, this function is not queued.

See also IAgentCharacter::GetPosition


IAgentCharacter::SetSize

HRESULT SetSize(
   long * lWidth,  // width of the character frame
   long * lHeight  // height of the character frame
);

Sets the size of the character's animation frame.

lWidth

The width of the character's animation frame in pixels.

lHeight

The height of the character's animation frame in pixels.

Changing the character's frame size scales the character to the size set with this method. This property's setting applies to all clients of the character.

Even though the character appears in an irregularly shaped region window, the location of the character is based on its rectangular animation frame.

See also IAgentCharacter::GetSize


IAgentCharacter::SetSoundEffectsOn

HRESULT SetSoundEffectsOn(
   long bOn  // character sound effects setting 
);

Determines whether the character's sound effects are played.

bOn

Sound effects setting. If this parameter is True, the sound effects for animations are played when the animation plays; if False, sound effects are not played.

This setting determines whether sound effects compiled as a part of the character are played when you play an associated animation. This property's setting applies to all clients of the character. The setting is also subject to the user's global sound effects setting in IAgentAudioOutputProperties::GetUsingSoundEffects.

See also IAgentCharacter::GetSoundEffectsOn, IAgentAudioOutputProperties::GetUsingSoundEffects


IAgentCharacter::Show

HRESULT Show(
   long bFast,      // play Showing state animation flag
   long * pdwReqID  // address of request ID
);

Displays a character.

bFast

Showing state animation flag. If this parameter is False, the Showing state animation plays after making the character visible; if True, the animation does not play.

pdwReqID

Address of a variable that receives the Show request ID.

Avoid setting the bFast parameter to True without playing an animation beforehand, otherwise, the character frame may be displayed, but have no image to display. In particular, note that that if you call MoveTo when the character is not visible, it does not play any animation. Therefore, if you call the Show method with bFast set to True, no image will be displayed. Similarly, if you call Hide then Show with bFast set to True, there will be no visible image.

When using the HTTP protocol to access character and animation data, use the Prepare method to ensure the availability of the Showing state animation before calling this method.

See also IAgentCharacter::Hide


IAgentCharacter::Speak

HRESULT Speak(
   BSTR bszText,    // text to speak
   BSTR bszURL,     // URL of a file to speak
   long * pdwReqID  // address of a request ID
);

Speaks the text or sound file.

bszText

The text the character is to speak.

bszURL

The URL (or file specification) of a sound file to use for spoken output. This can be a standard sound file (.WAV) or linguistically enhanced sound file (.LWV).

pdwReqID

Address of a variable that receives the Speak request ID.

To use this method with a character configured to speak using a text-to-speech (TTS) engine; simply provide the bszText parameter. You can include vertical bar characters (|) in the bszText parameter to designate alternative strings, so that each time the server processes the method, it randomly choose a different string. Support of TTS output is defined when the character is compiled using the Microsoft Agent Character Editor.

If you want to use sound file output for the character, specify the location for the file in the bszURL parameter. When using the HTTP protocol to download a sound file, use the Prepare method to ensure the availability of the file before using this method. You can use the bszText parameter to specify the words that appear in the character's word balloon. If you specify a linguistically enhanced sound file (.LWV) for the bszURL parameter and do not specify text, the bszText parameter uses the text stored in the file.

The Speak method uses the last animation played to determine which speaking animation to play. For example, if you precede the Speak command with a IAgentCharacter::Play "GestureRight", the server will play GestureRight and then the GestureRight speaking animation. If the last animation played has no speaking animation, then Microsoft Agent plays the animation assigned to the character's Speaking state.

If you call Speak and the audio channel is busy, the character's audio output will not be heard, but the text will display in the word balloon. The word balloon's Enabled property must also be True for the text to display.

Microsoft Agent's automatic word breaking in the word balloon, breaks words using white-space characters (for example, space and tab). However, it may break a word to fit the balloon as well. In languages like Japanese, Chinese, and Thai, where spaces are not used to break words, insert a Unicode zero width space character (0x200B) between characters to define logical word breaks.

Note Set the character's language ID (using |AgentCharacterEx::SetLanguageIDbefore using the Speak method to ensure appropriate text display within the word balloon.

See also IAgentCharacter::Play, IAgentBalloon::GetEnabled, IAgentCharacter::Prepare


IAgentCharacter::Stop

HRESULT Stop(
   long dwReqID  // request ID
);

Stops the specified animation (request) and removes it from the character's animation queue.

dwReqID

The ID of the request to stop.

Stop can also be used to halt any queued Prepare calls.

See also IAgentCharacter::Prepare, IAgentCharacter::StopAll


IAgentCharacter::StopAll

HRESULT StopAll();
   long lType,  // request type

Stops all animations (requests) and removes them from the character's animation queue.

lType

A bit field that indicates the types of requests to stop (and remove from the character's queue), comprised from the following:

const unsigned long STOP_TYPE_ALL = 0xFFFFFFFF; Stops all animation requests, including non-queued Prepare requests.
const unsigned long STOP_TYPE_PLAY = 0x00000001; Stops all Play requests.
const unsigned long STOP_TYPE_MOVE = 0x00000002; Stops all Move requests.
const unsigned long STOP_TYPE_SPEAK = 0x00000004; Stops all Speak requests.
const unsigned long STOP_TYPE_PREPARE = 0x00000008; Stops all queued Prepare requests.
const unsigned long STOP_TYPE_NONQUEUEDPREPARE = 0x00000010; Stops all non-queued Prepare requests.
const unsigned long STOP_TYPE_VISIBLE = 0x00000020; Stops all Hide or Show requests.

See also IAgentCharacter::Stop


IAgentCharacter::Wait

HRESULT Wait(
   long dwReqID,    // request ID
   long * pdwReqID  // address of request ID
);

Holds the character's animation queue at the specified animation (request) until another request for another character completes.

dwReqID

The ID of the request to wait for.

pdwReqID

Address of a variable that receives the Wait request ID.

Use this method only when you support multiple (simultaneous) characters and want to sequence their interaction. (For a single character, each animation request is played sequentially--after the previous request completes.) If you have two characters and want one character's animation request to wait until the other character's animation completes, set the Wait method to the other character's animation request ID.

IAgentCharacterEx

IAgentCharacterEx derives from the IAgentCharacter interface. It includes all the IAgentCharacter methods as well as provides access to additional functions.

Methods in Vtable Order
IAgentCharacterEx Methods Description
ShowPopupMenu Displays the pop-up menu for the character.
SetAutoPopupMenu Sets whether the server automatically displays the character's pop-up menu.
GetAutoPopupMenu Returns whether the server automatically displays the character's pop-up menu.
GetHelpFileName Returns the Help filename for the character.
SetHelpFileName Sets the Help filename for the character.
SetHelpModeOn Sets Help mode on.
GetHelpModeOn Returns whether Help mode is on.
SetHelpContextID Sets the HelpContextID for the character.
GetHelpContextID Returns the HelpContextID for the character.
GetActive Returns the active state for the character.
Listen Sets the listening state for the character.
SetLanguageID Sets the language ID for the character.
GetLanguageID Returns the language ID for the character.
GetTTSModeID Returns the TTS mode ID set for the character.
SetTTSModeID Sets the TTS mode ID for the character.
GetSRModeID Returns the current speech recognition engine's mode ID.
SetSRModeID Sets the speech recognition engine.
GetGUID Returns the character's identifier.
GetOriginalSize Returns the original size of the character frame.
Think Displays the specified text in the character's "thought" balloon.
GetVersion Returns the version of the character.
GetAnimationNames Returns the names of the animations for the character.
GetSRStatus Returns the conditions necessary to support speech input.

IAgentCharacterEx::GetActive

HRESULT GetActive(
   short * psState  // address of active state setting
);

Retrieves whether your client application is the active client of the character and whether the character is topmost.

psState

Address of a variable that receives one of the following values for the state setting:

const unsigned short ACTIVATE_NOTACTIVE = 0; Your client is not the active client of the character.
const unsigned short ACTIVATE_ACTIVE = 1; Your client is the active client of the character.
const unsigned short ACTIVATE_INPUTACTIVE = 2; Your client is input-active (active client of the topmost character).

This setting lets you know whether you are the active client of the character or whether your character is the active client of the character. When multiple client applications share the same character, the active client of the character receives mouse input (for example, Microsoft Agent control click or drag events). Similarly, when multiple characters are displayed, the active client of the topmost character (also known as the input-active client) receives IAgentNotifySink::Command events.

Use the Activate method to set whether your application is the active client of the character or to make your application the input active client (which also makes the character topmost).

See also IAgentCharacter::Activate, IAgentNotifySinkEx::ActiveClientChange


IAgentCharacterEx::GetAnimationNames

HRESULT GetAnimationNames(
   IUnknown ** punkEnum // address of IUnknown inteface
);

Retrieves the animation names for a character.

IUnknown

The address of the IUnknown interface for the character's animation collection.

This function enables you to enumerate the names of the animations for a character. Items in the collection have no properties, so individual items cannot be accessed directly.

Note For ACF characters, the collection returns all the animations that have been defined for the character, adding to the ones that have been retrieved with the Get method.


IAgentCharacterEx::GetAutoPopupMenu

HRESULT GetAutoPopupMenu(
   long * pbAutoPopupMenu  // address of auto pop-up menu display setting
);

Retrieves whether the server automatically displays the character's pop-up menu.

pbAutoPopupMenu

Address of a variable that receives True if the Microsoft Agent server automatically handles displaying the character's pop-up menu and False if not.

When this property is set to False, your application must display the pop-up menu using IAgentCharacter::ShowPopupMenu method.

This property applies only to your client application's use of the character; the setting does not affect other clients of the character or other characters of your client application.

See also IAgentCharacterEx::SetAutoPopupMenu, IAgentCharacterEx::ShowPopupMenu


IAgentCharacterEx::GetGUID

HRESULT GetGUID(
   BSTR * pbszGUID  // address of character's ID
);

Retrieves the unique ID for the character.

pbszGUID

Address of a BSTR that receives the ID for the character.

The property returns a string representation of the GUID (formatted with braces and dashes) that the server uses to uniquely identify the character. A character identifier is set when it is compiled with the Microsoft Agent Character Editor. The property is read-only.


IAgentCharacterEx::GetHelpContextID

HRESULT GetHelpContextID(
   long * pulHelpID  // address of character's help topic ID
);

Retrieves the HelpContextID for the character.

pulHelpID

Address of a variable that receives the context number of the help topic for the character.

If you've created a Windows® Help file for your application and set the character's HelpFile property, Microsoft Agent automatically calls Help when HelpModeOn is set to True and the user selects the character. If there is a context number in the HelpContextID, Agent calls Help and searches for the topic identified by the current context number. The current context number is the value of HelpContextID for the character.

IAgentCharacterEx::GetHelpContextID returns the HelpContextID you set for the character. It does not return the HelpContextID set by other clients.

Note Building a Help file requires the Microsoft Windows Help Compiler.

See also IAgentCharacterEx::SetHelpContextID, IAgentCharacterEx::SetHelpModeOn, IAgentCharacterEx::SetHelpFileName


IAgentCharacterEx::GetHelpFileName

HRESULT GetHelpFileName(
   BSTR * pbszName  // address of Help filename
);

Retrieves the HelpFileName for a character.

pbszName

Address of a variable that receives the Help filename for the character.

If you've created a Windows Help file for your application and set the character's HelpFile property, Microsoft Agent automatically calls Help when HelpModeOn is set to True and the user clicks the character or selects a command from its pop-up menu. If there is a context number in the selected command's HelpContextID property, Help displays a topic corresponding to the current Help context; otherwise it displays "No Help topic associated with this item."

This property applies only to your client application's use of the character; the setting does not affect other clients of the character or other characters of your client application.

Note Building a Help file requires the Microsoft Windows Help Compiler.

See also IAgentCommandsEx::SetHelpContextID, IAgentCharacterEx::SetHelpModeOn, IAgentCharacterEx::SetHelpFileName


IAgentCharacterEx::GetHelpModeOn

HRESULT GetHelpModeOn(
   long * pbHelpModeOn  // address of help mode setting
);

Retrieves whether context-sensitive Help mode is on for the character.

pbHelpModeOn

Address of a variable that receives True if Help mode is on for the character and False if not.

When this property is set to True, the mouse pointer changes to the context-sensitive Help image when moved over the character or over the pop-up menu for the character. When the user clicks or drags the character or clicks an item in the character's pop-up menu, the server triggers the IAgentNotifySinkEx::HelpComplete event and exits Help mode.

In Help mode, the server does not send the IAgentNotifySink::Click, IAgentNotifySink::DragStart, IAgentNotifySink::DragComplete, and IAgentNotifySink::Command events, unless GetAutoPopupMenu property returns True. In that case, the server will send the IAgentNotifySink::Click event (does not exit Help mode), but only for the right mouse button to enable you to display the pop-up menu.

This property applies only to your client application's use of the character; the setting does not affect other clients of the character or other characters of your client application.

See also IAgentCharacterEx::SetHelpModeOn


IAgentCharacterEx::GetLanguageID

HRESULT GetLanguageID(
   long * plangID  // address of language ID setting
);

Retrieves the language ID set for the character.

plangID

Address of a variable that receives the language ID setting for the character.

A Long integer specifying the language ID for the character. The language ID (LANGID) for a character is a 16-bit value defined by Windows, consisting of a primary language ID and a secondary language ID. The following examples are values for some languages. To determine the values other languages, see the Win32 SDK documentation Non-MSDN Online link.

Arabic (Saudi) 0x0401 Italian 0x0410
Basque 0x042d Japanese 0x0411
Chinese (Simplified) 0x0804 Korean 0x0412
Chinese (Traditional) 0x0404 Norwegian 0x0414
Croatian 0x041A Polish 0x0415
Czech 0x0405 Portuguese 0x0816
Danish 0x0406 Portuguese (Brazilian) 0x0416
Dutch 0x0413 Romanian 0x0418
English (British) 0x0809 Russian 0x0419
English (US) 0x0409 Slovakian 0x041B
Finnish 0x040B Slovenian 0x0424
French 0x040C Spanish 0x0C0A
German 0x0407 Swedish 0x041D
Greek 0x0408 Thai 0x041E
Hebrew 0x040D Turkish 0x041F
Hungarian 0x040E    

If you do not set this language ID for the character, the character's language ID will be the current system language ID.

This setting also determines the language for TTS output, word balloon text, the commands in the character's pop-up menu, and speech recognition engine. To determine if there is a compatible speech recognition engine available for the character's language, use IAgentCharacterEx::GetSRModeID or IAgentCharacterEx::GetTTSModeID.

This property applies only to your client application's use of the character; the setting does not affect other clients of the character or other characters of your client application.

Note If the language ID is set to a language that supports bidirectional text (such as Arabic or Hebrew), but the system running your application does not have bidirectional support installed, text will appear in the word balloon in logical rather than display order.

See also IAgentCharacterEx::SetLanguageID, IAgentCharacterEx::GetSRModeID, IAgentCharacterEx::GetTTSModeID


IAgentCharacterEx::GetOriginalSize

HRESULT GetOriginalSize(
   long * plWidth,  // address of variable for character width 
   long * plHeight  // address of variable for character height
);

Retrieves the original size of the character's animation frame.

plWidth

Address of a variable that receives the original width of the character animation frame in pixels.

plHeight

Address of a variable that receives the original height of the character animation frame in pixels.

This call returns the original size of the character frame as built in the Microsoft Agent Character Editor.

See also IAgentCharacter::GetSize


IAgentCharacterEx::GetSRModeID

HRESULT GetSRModeID(
   BSTR * pbszModeID  // address of speech recognition engine ID
);

Retrieves the mode ID of the speech recognition engine set for the character.

pbszModeID

Address of a BSTR that receives the mode ID setting of the speech recognition engine for the character.

This setting returns the engine set for a character's speech input. The mode ID for a speech recognition engine is a string representation of the GUID (formatted with braces and dashes) by the speech vendor uniquely identifying the engine. For more information, see the Microsoft Speech SDK documentation Non-MSDN Online link.

If you do not set a speech recognition engine mode ID for the character, the server returns an engine that matches the character's language setting (using Microsoft Speech API interfaces). If there is no matching speech recognition engine available for the character, the server returns a null (empty) string.

When speech input is enabled (in the Advanced Character Options window), querying or setting this property will load the associated engine (if it is not already loaded), and start speech services. That is, the Listening key is available, and the Listening Tip is displayable. (The Listening key and Listening Tip are enabled only if they are also enabled in Advanced Character Options.) However, if you query the property when speech is disabled, the server does not start speech services and it returns a null string (empty string).

This function returns only the setting for your client application's use of the character; the setting does not reflect other clients of the character or other characters of your client application.

This function does not fail if the IAgentSpeechInputProperties::GetEnabled returns False.

Microsoft Agent's speech engine requirements are based on the Microsoft Speech API. Engines supporting Microsoft Agent's SAPI requirements can be installed and used with Agent.

See also IAgentCharacterEx::SetSRModeID


IAgentCharacterEx::GetSRStatus

HRESULT GetSRStatus(
   long * plStatus  // address of the speech input status
);

Retrieves the status of the condition necessary to support speech input.

plStatus

Address of a variable that receives one of the following values for the state setting:

const unsigned long
LISTEN_STATUS_CANLISTEN
= 0;
Conditions support speech input.
const unsigned long
LISTEN_STATUS_NOAUDIO
= 1;
There is no audio input device available on this system. (Note that this does not detect whether a microphone is installed; it can only detect whether the user has a properly installed input-enabled sound card with a working driver.)
const unsigned long
LISTEN_STATUS_NOTTOPMOST
= 2;
Another client is the active client of this character, or the current character is not topmost.
const unsigned long LISTEN_STATUS_CANTOPENAUDIO = 3; The audio input or output channel is currently busy, some other application is using audio.
const unsigned long LISTEN_STATUS_COULDNTINITIALIZESPEECH = 4; An unspecified error occurred in the process of initializing the speech recognition subsystem. This includes the possibility that there is no speech engine available matching the character's language setting.
const unsigned long
LISTEN_STATUS_SPEECHDISABLED
= 5;
The user has disabled speech input in the Advanced Character Options window.
const unsigned long
LISTEN_STATUS_ERROR
= 6;
An error occurred in checking the audio status, but the cause of the error was not returned by the system.

This function enables you to query whether current conditions support speech recognition input, including the status of the audio device. If your application uses the IAgentCharacterEx::Listen method, you can use this function to better ensure that the call will succeed. Calling this method also loads the speech engine if it is not already loaded. However, it does not turn on Listening mode.

When speech input is enabled in the Agent property sheet (Advanced Character Options), querying the status will load the associated engine (if it is not already loaded), and start speech services. That is, the Listening key is available, and the Listening Tip is displayable. (The Listening key and Listening Tip are enabled only if they are also enabled in Advanced Character Options.) However, if you query the property when speech is disabled, the server does not start speech services.

This function returns only the setting for your client application's use of the character; the setting does not reflect other clients of the character or other characters of your client application.

IAgentCharacterEx::GetTTSModeID

HRESULT GetTTSModeID(
   BSTR * pbszModeID  // address of TTS engine ID
);

Retrieves the mode ID of the TTS engine set for the character.

pbszModeID

Address of a BSTR that receives the mode ID setting of the TTS engine for the character.

This setting returns the TTS (text-to-speech) engine mode ID for a character's spoken output. The mode ID for a TTS engine is a string representation of the GUID (formatted with braces and dashes) defined by the speech vendor uniquely identifying the engine. For more information, see the Microsoft Speech SDK documentation Non-MSDN Online link. Querying this property will load the associated engine if it is not already loaded.

If you do not set a TTS engine mode ID for the character, the server attempts to return an engine that matches (using Microsoft Speech API interfaces) the character's compiled TTS setting and the character's current language setting. If these are different, then the character's language setting overrides its authored mode setting. If you have not set the character's language setting, the character's language is the user default language ID, and the server attempts the match based on that language ID.

This function does not fail if the IAgentAudioObjectProperties::GetEnabled returns False.

This property applies only to your client application's use of the character; the setting does not affect other clients of the character or other characters of your client application.

Microsoft Agent's speech engine requirements are based on the Microsoft Speech API. Engines supporting Microsoft Agent's SAPI requirements can be installed and used with Agent.

See also IAgentCharacterEx::SetTTSModeID


IAgentCharacterEx::GetVersion

HRESULT GetVersion(
   short * psMajor,  // address of major version
   short * psMinor   // address of minor version
);

Retrieves the version number of the character standard animation set.

psMajor

Address of a variable that receives the major version.

psMinor

Address of a variable that receives the minor version.

The standard animation set version number is automatically set when you build it with the Microsoft Agent Character Editor.


IAgentCharacterEx::Listen

HRESULT Listen(
   long bListen  // listening mode flag
);

Turns Listening mode (speech recognition input) on or off.

bListen

Listening mode flag. If this parameter is True, the Listening mode is turned on; if False, Listening mode is turned off.

Setting this method to True enables the Listening mode (turns on speech recognition) for a fixed period of time. While you cannot set the value of the time-out, you can turn off Listening mode before the time-out expires. In addition, if the Listening mode is already on because you (or another client) successfully set the method to True before the time-out expires, the method succeeds and resets the time-out. However, if Listening mode is already on because the user is pressing the Listening key, the method succeeds, but the time-out is ignored and the Listening mode ends based on the user's interaction with the Listening key.

This method will succeed only when called by the input-active client. Therefore, the method will fail if your client is not the active client of the topmost character. The method will also fail if you attempt to set the method to False and the user is pressing the Listening key. It can also fail if there is no compatible speech engine available that matches the character's language ID setting or the user has disabled speech input using the Microsoft Agent property sheet. However, the method will not fail if the audio device is busy.

When you successfully set this method to True, the server triggers the IAgentNotifySinkEx::ListeningState event. The server also sends IAgentNotifySinkEx::ListeningState when the Listening mode time-out completes or when you set IAgentCharacterEx::Listen to False.

This method does not automatically call IAgentCharacter::StopAll and play a Listening state animation of the character as occurs when the user presses the Listening key. This enables you to use the IAgentNotifySinkEx::ListeningState event to determine whether you wish to stop the current animation and play your own appropriate animation. However, once a user utterance is detected, the server automatically calls IAgentCharacter::StopAll and plays a Hearing state animation.

See also IAgentNotifySinkEx::ListeningState, IAgentNotifySinkEx::ListeningState, IAgentSpeechInputProperties::GetEnabled


IAgentCharacterEx::SetAutoPopupMenu

HRESULT SetAutoPopupMenu(
   long bAutoPopupMenu,  // auto pop-up menu display setting
);

Sets whether the server automatically displays the character's pop-up menu.

bAutoPopupMenu

The automatic pop-up menu display flag. If this parameter is True, Microsoft Agent automatically displays the character's pop-up menu when the user right-clicks the character or character's taskbar icon.

This property applies only to your client application's use of the character; the setting does not affect other clients of the character or other characters of your client application.

By setting this property to False, you can create your own menu-handling behavior. To display the menu after setting this property to False, use the IAgentCharacter::ShowPopupMenu method.

See also IAgentCharacterEx::GetAutoPopupMenu, IAgentCharacterEx::ShowPopupMenu


IAgentCharacterEx::SetHelpContextID

HRESULT SetHelpContextID(
   long ulHelpID  // ID for help topic
);

Sets the HelpContextID for the character.

ulHelpID

The context number of the help topic for associated with a character; used to provide context-sensitive Help for the character.

If you've created a Windows Help file for your application and set this in the character's HelpFile property, Microsoft Agent automatically calls Help when HelpModeOn is set to True and the user selects the character. If there is a context number in the HelpContextID, Agent calls Help and searches for the topic identified by the current context number. The current context number is the value of HelpContextID for the character. If there is a context number in the HelpContextID property, Help displays a topic corresponding to the current Help context; otherwise it displays "No Help topic associated with this item."

This setting applies only when your client application is the active client of the topmost character. It does not affect other clients of the character or other characters that your client application is using.

Note Building a Help file requires the Microsoft Windows Help Compiler.

See also IAgentCharacterEx::GetHelpContextID, IAgentCharacterEx::SetHelpModeOn, IAgentCharacterEx::SetHelpFileName


IAgentCharacterEx::SetHelpFileName

HRESULT SetHelpFileName(
   BSTR bszName  // Help filename
);

Sets the HelpFileName for a character.

bszName

The Help filename for the character.

If you've created a Windows Help file for your application and set the character's HelpFile property, Microsoft Agent automatically calls Help when HelpModeOn is set to True and the user clicks the character or selects a command from its pop-up menu. If there is a context number in the HelpContextID property of the selected command, Help displays a topic corresponding to the current Help context; otherwise it displays "No Help topic associated with this item."

This property applies only to your client application's use of the character; the setting does not affect other clients of the character or other characters of your client application.

Note Building a Help file requires the Microsoft Windows Help Compiler.

See also IAgentCommandsEx::SetHelpContextID, IAgentCharacterEx::SetHelpModeOn, IAgentCharacterEx::GetHelpFileName


IAgentCharacterEx::SetHelpModeOn

HRESULT SetHelpModeOn(
   long bHelpModeOn  // help mode setting
);

Sets context-sensitive Help mode on for the character.

bHelpModeOn

Help mode flag. If this parameter is True, Microsoft Agent turns on Help mode for the character.

When you set this property to True, the mouse pointer changes to the context-sensitive Help image when moved over the character or over the pop-up menu for the character. When the user clicks or drags the character or clicks an item in the character's pop-up menu, the server triggers the IAgentNotifySinkEx::HelpComplete event and exits Help mode.

In Help mode, the server does not send the Click, DragStart, DragComplete, and Command events, unless the GetAutoPopupMenu property returns True. In that case, the server will send the Click event (does not exit Help mode), but only for the right mouse button so you can display the pop-up menu.

This property applies only to your client application's use of the character; the setting does not affect other clients of the character or other characters of your client application.

See also IAgentCharacterEx::GetHelpModeOn, IAgentNotifySinkEx::HelpComplete


IAgentCharacterEx::SetLanguageID

HRESULT SetLanguageID(
   long langID  // language ID setting of character
); 

Sets the language ID set for the character.

langID

The language ID setting for the character.

A Long integer specifying the language ID for the character. The language ID (LANGID) for a character is a 16-bit value defined by Windows, consisting of a primary language ID and a secondary language ID. You can use the following values for the specified languages. For more information, see the Win32 SDK documentation Non-MSDN Online link.

Arabic (Saudi) 0x0401 Italian 0x0410
Basque 0x042d Japanese 0x0411
Chinese (Simplified) 0x0804 Korean 0x0412
Chinese (Traditional) 0x0404 Norwegian 0x0414
Croatian 0x041A Polish 0x0415
Czech 0x0405 Portuguese 0x0816
Danish 0x0406 Portuguese (Brazilian) 0x0416
Dutch 0x0413 Romanian 0x0418
English (British) 0x0809 Russian 0x0419
English (US) 0x0409 Slovakian 0x041B
Finnish 0x040B Slovenian 0x0424
French 0x040C Spanish 0x0C0A
German 0x0407 Swedish 0x041D
Greek 0x0408 Thai 0x041E
Hebrew 0x040D Turkish 0x041F
Hungarian 0x040E

If you do not set the language ID for the character, its language ID will be the current system language ID if the corresponding Agent language DLL is installed; otherwise, the character's language will be English (US).

This property also determines the language for the word balloon text, the commands in the character's pop-up menu, and the speech recognition engine. It also determines the default language for TTS output. To determine if there is a compatible speech engine available for the character's language, use IAgentCharacterEx::GetSRModeID or IAgentCharacterEx::GetTTSModeID.

If you try to set the language ID for a character and the Agent language resources, the code page, or a display font for the language ID is not available, Agent returns an error and the character's language ID remains at its last setting. Setting this property does not return an error if there are no matching speech engines for the language.

This property applies only to your client application's use of the character; the setting does not affect other clients of the character or other characters of your client application.

Note If you set the character's language ID to a language that supports bidirectional text (such as Arabic or Hebrew), but the system running your application does not have bidirectional support installed, text will appear in the word balloon in logical rather than display order.

See also IAgentCharacterEx::GetLanguageID, IAgentCharacterEx::GetSRModeID, IAgentCharacterEx::GetTTSModeID


IAgentCharacterEx::SetSRModeID

HRESULT GetSRModeID(
   BSTR bszModeID  // speech recognition engine ID
);

Sets the mode ID of the speech recognition engine set for the character.

bszModeID

The mode ID setting of the speech recognition engine for the character.

This setting sets the engine for a character's speech input. The mode ID for a speech recognition engine is the GUID defined by the speech vendor that uniquely identifies the engine's mode (formatted with braces and dashes). For more information, see the Microsoft Speech SDK documentation Non-MSDN Online link.

If you specify a mode ID that does not match the character's language setting, if the user has disabled speech recognition (in the Microsoft Agent property sheet), or the engine is not installed, this call will fail. If you do not set a speech recognition engine mode ID for the character, the server sets one that matches the character's language setting (using Microsoft Speech API interfaces).

When speech input is enabled in the Agent property sheet (Advanced Character Options), setting this property will load the associated engine (if it is not already loaded), and start speech services. That is, the Listening key is available, and the Listening Tip is displayable. (The Listening key and Listening tip are enabled only if they are also enabled in Advanced Character Options.) However, if you query the property when speech is disabled, the server does not start speech services.

This property applies to only the client of the character; the setting does not reflect the setting for other clients of the character or other characters of the client.

Microsoft Agent's speech engine requirements are based on the Microsoft Speech API. Engines supporting Microsoft Agent's SAPI requirements can be installed and used with Agent.

See also IAgentCharacterEx::GetSRModeID


IAgentCharacterEx::SetTTSModeID

HRESULT GetTTSModeID(
   BSTR bszModeID  // TTS engine ID
);

Sets the mode ID of the TTS engine set for the character.

bszModeID

The mode ID setting of the TTS engine for the character.

Note SetTTSModeID can fail if speech.dll is not installed and the engine you specify does not match the character's compiled TTS mode setting.

This setting determines the preferred engine mode for a character's spoken TTS output. The mode ID for a TTS (text-to-speech) engine is the GUID defined by the speech vendor that uniquely identifies the mode of the engine (formatted with braces and dashes). For more information, see the Microsoft Speech SDK documentation Non-MSDN Online link.

If you set a TTS mode ID, it overrides the server attempt to match a speech engine based on the character's compiled TTS mode ID, the current system language ID, and the character's current language ID. However, if you attempt to set a mode ID when the user has disabled speech output in the Microsoft Agent property sheet or when the associated engine is not installed, this call will fail.

If you do not set a TTS engine mode ID for the character, the server sets an engine that matches the character's language setting (using Microsoft Speech API interfaces). Setting this property will load the associated engine if it is not already loaded.

This property applies to only your client application's use of the character; the setting does not affect other clients of the character or other characters of your client application.

Microsoft Agent's speech engine requirements are based on the Microsoft Speech API. Engines supporting Microsoft Agent's SAPI requirements can be installed and used with Agent.

See also IAgentCharacterEx::GetTTSModeID


IAgentCharacterEx::ShowPopupMenu

HRESULT ShowPopupMenu(
   short x,  // x-coordinate of pop-up menu
   short y   // y-coordinate of pop-up menu
);

Displays the pop-up menu for the character.

x

The x-coordinate of the character's pop-up menu in pixels, relative to the screen origin (upper left).

y

The y-coordinate of the character's pop-up menu in pixels, relative to the screen origin (upper left).

When you set IAgentCharacterEx::SetAutoPopupMenu to False, the server no longer automatically displays the menu when the character or its taskbar icon is right-clicked. You can use this method to display the menu.

The menu displays until the user selects a command or displays another menu. Only one pop-up menu can be displayed at a time; therefore, calls to this method will cancel (remove) the former menu.

This method should only be called when your client application is the active client of the character; otherwise it fails.

IAgentCharacterEx::SetAutoPopupMenu


IAgentCharacterEx::Think

HRESULT Think(
   BSTR bszText,    // text to think
   long * pdwReqID  // address of a request ID
);

Displays the character's thought word balloon with the specified text.

bszText

The text to appear in the character's thought balloon.

pdwReqID

Address of a variable that receives the Think request ID.

Like the Speak method, the Think method is a queued request that displays text in a word balloon, except that thoughts display in a special thought balloon. The thought balloon supports only the Bookmark speech control tag (\Mrk) and ignores any other speech control tags. Unlike Speak, the Think method does not change the character's animation state.

The IAgentBalloon settings also apply to the appearance style of the thought balloon. For example, the balloon's Enabled property must also be True for the text to display.

Microsoft Agent's automatic word breaking in the word balloon, breaks words using white-space characters (for example, space and tab). However, it may break a word to fit the balloon as well. In languages like Japanese, Chinese, and Thai, where spaces are not used to break words, insert a Unicode zero width space character (0x200B) between characters to define logical word breaks.

See also IAgentBalloon::GetEnabled, IAgentBalloonEx::SetStyle, IAgentCharacter::Speak


IAgentCommands

The Microsoft Agent server maintains a list of commands that are currently available to the user. This list includes commands that the server defines for general interaction, such as Hide and Microsoft Agent Properties, the list of available (but non-input-active) clients, and the commands defined by the current active client. The first two sets of commands are global commands; that is, they are available at any time, regardless of the input-active client. Client-defined commands are available only when that client is input-active.

Retrieve an IAgentCommands interface by querying the IAgentCharacter interface for IAgentCommands. Each Microsoft Agent client application can define a collection of commands called a Commands collection. To add a Command to the collection, use the Add or Insert method. Although you can specify a Command's properties using IAgentCommand methods, for optimum code performance, specify all of a Command's properties in the IAgentCommands::Add or IAgentCommands::Insert methods when initially setting the properties for a new Command. You can use the IAgentCommand methods to query or change the property settings.

For each Command in the Commands collection, you can determine whether the command appears on the character's pop-up menu, in the Voice Commands Window, in both, or in neither. For example, if you want a command to appear on the pop-up menu for the character, set the command's Caption and Visible properties. To display the command in the Voice Commands Window, set the command's Caption and Voice properties.

A user can access the individual commands in your Commands collection only when your client application is input-active and the character is visible. Therefore, you will typically want to set the Caption, VoiceCaption, and Voice properties for the Commands collection object as well as for the commands in the collection, because this places an entry for your Commands collection on a character's pop-up menu and in the Voice Commands Window. When the user switches to your client by choosing its Commands entry, the server automatically makes your client input-active, notifying your client application using the IAgentNotifySink::ActivateInputState and makes the Commands in its collection available. The server also notifies the client that is no longer input-active with the IAgentNotifySink::ActivateInputState event. This enables the server to present and accept only the Commands that apply to the current input-active client's context. It also serves to avoid Command-name collisions between clients.

A client can also explicitly request to make itself the input-active client using the IAgentCharacter::Activate method. This method also supports setting your application to not be the input-active client. You may want to use this method when sharing a character with another application, setting your application to be input-active when your application window gets focus and not input-active when it loses focus.

Similarly, you can use IAgentCharacter::Activate to set your application to be (or not be) the active client of the character. The active client is the client that receives input when its character is the topmost character. When this status changes, the server notifies your application with the IAgentNotifySinkEx::ActiveClientChange event.

When a character's pop-up menu is displayed, changes to the properties of a Commands collection or the commands in its collection do not appear until the user redisplays the menu. However, when open, the Voice Commands Window does display changes as they happen.

IAgentCommands defines an interface that allows applications to add, remove, set, and query properties for a Commands collection. These functions are also available from IAgentCommandsEx.

A Commands collection can appear as a command in both the pop-up menu and the Voice Commands Window for a character. To make the Commands collection appear, you must set its Caption property. The following table summarizes how the properties of a Commands collection affect its presentation.

Caption Property Voice-Caption Property Voice Property Visible Property Appears in
Character's Pop-up Menu
Appears in
Voice Commands Window
Yes Yes Yes True Yes, using Caption Yes, using VoiceCaption
Yes Yes No* True Yes, using Caption No
Yes Yes Yes False No Yes, using VoiceCaption
Yes Yes No* False No No
No* Yes Yes True No Yes, using VoiceCaption
No* Yes Yes False No Yes, using VoiceCaption
No* Yes No* True No No
No* Yes No* False No No
Yes No* Yes True Yes, using Caption Yes, using Caption
Yes No* No* True Yes No
Yes No* Yes False No Yes, using Caption
Yes No* No* False No No
No* No* Yes True No No**
No* No* Yes False No No**
No* No* No* True No No
No* No* No* False No No
*If the property setting is null. In some programming languages, an empty string may not be interpreted the same as a null string.

**The command is still voice-accessible.

Methods in Vtable Order
IAgentCommands Methods Description
GetCommand Retrieves a Command object from the Commands collection.
GetCount Returns the value of the number of Commands in a Commands collection.
SetCaption Sets the value of the Caption property for a Commands collection.
GetCaption Returns the value of the Caption property of a Commands collection.
SetVoice Sets the value of the Voice property for a Commands collection.
GetVoice Returns the value of the Voice property of a Commands collection.
SetVisible Sets the value of the Visible property for a Commands collection.
GetVisible Returns the value of the Visible property of a Commands collection.
Add Adds a Command object to a Commands collection.
Insert Inserts a Command object in a Commands collection.
Remove Removes a Command object in a Commands collection.
RemoveAll Removes all Command objects from a Commands collection.

IAgentCommands::Add

HRESULT Add(
   BSTR bszCaption,  // Caption setting for Command
   BSTR bszVoice,    // Voice setting for Command
   long bEnabled,    // Enabled setting for Command
   long bVisible,    // Visible setting for Command
   long * pdwID      // address for variable for ID
);

Adds a Command to a Commands collection.

bszCaption

A BSTR that specifies the value of the Caption text displayed for a Command in a Commands collection.

bszVoice

A BSTR that specifies the value of the Voice text setting for a Command in a Commands collection.

bEnabled

A Boolean expression that specifies the Enabled setting for a Command in a Commands collection. If the parameter is True, the Command is enabled and can be selected; if False, the Command is disabled.

bVisible

A Boolean expression that specifies the Visible setting for a Command in a Commands collection. If the parameter is True, the Command will be visible in the character's pop-up menu (if the Caption property is also set).

pdwID

Address of a variable that receives the ID for the added Command.

See also IAgentCommand::SetCaption, IAgentCommand::SetEnabled, IAgentCommand::SetVisible, IAgentCommand::SetVoice, IAgentCommands::Insert, IAgentCommands::Remove, IAgentCommands::RemoveAll


IAgentCommands::GetCaption

HRESULT GetCaption(
   BSTR * pbszCaption  // address of Caption text for Commands collection
);

Retrieves the Caption for a Commands collection.

pbszCaption

The address of a BSTR that receives the value of the Caption text setting displayed for a Commands collection.

See also IAgentCommands::SetCaption, IAgentCommands::GetVisible, IAgentCommands::GetVoice


IAgentCommands::GetCommand

HRESULT GetCommand(
   long dwCommandID,         // Command ID
   IUnknown ** ppunkCommand  // address of IUnknown interface
);                    

Retrieves a Command object from the Commands collection.

dwCommandID

The ID of a Command object in the Commands collection.

IUnknown

The address of the IUnknown interface for the Command object.

See also IAgentCommand


IAgentCommands::GetCount

HRESULT GetCount(
   long * pdwCount  // address of count of commands
);                    

Retrieves the number of Command objects in a Commands collection.

pdwCount

Address of a variable that receives the number of Commands in a Commands collection.

pdwCount includes only the number of Commands you define in your Commands collection. Server or other client entries are not included.


IAgentCommands::GetVisible

HRESULT GetVisible(
   long * pbVisible  // address of Visible setting for Commands collection
);

Retrieves the value of the Visible property for a Commands collection.

pbVisible

The address of a variable that receives the value of the Visible property for a Commands collection.

See also IAgentCommands::SetVisible, IAgentCommands::SetCaption


IAgentCommands::GetVoice

HRESULT GetVoice(
   BSTR * pbszVoice  // address of Voice setting for Commands collection
);

Retrieves the value of the Voice property for a Commands collection.

pbszVoice

The address of a BSTR that receives the value of the Voice text setting for a Commands collection.

See also IAgentCommands::SetVoice, IAgentCommands::GetCaption, IAgentCommands::GetVisible


IAgentCommands::Insert

HRESULT Insert(
   BSTR bszCaption,  // Caption setting for Command
   BSTR bszVoice,    // Voice setting for Command
   long bEnabled,    // Enabled setting for Command
   long bVisible,    // Visible setting for Command
   long dwRefID,     // reference Command for insertion
   long dBefore,     // insertion position flag
   long * pdwID      // address for variable for Command ID
);

Inserts a Command object in a Commands collection.

bszCaption

A BSTR that specifies the value of the Caption text displayed for the Command.

bszVoice

A BSTR that specifies the value of the Voice text setting for a Command.

bEnabled

A Boolean expression that specifies the Enabled setting for a Command. If the parameter is True, the Command is enabled and can be selected; if False, the Command is disabled.

bVisible

A Boolean expression that specifies the Visible setting for a Command. If the parameter is True, the Command will be visible in the character's pop-up menu (if the Caption property is also set).

dwRefID

The ID of a Command used as a reference for the relative insertion of the new Command.

dBefore

A Boolean expression that specifies where to place the Command. If this parameter is True, the new Command is inserted before the referenced Command; if False, the new Command is placed after the referenced Command.

pdwID

Address of a variable that receives the ID for the inserted Command.

See also IAgentCommands::Add, IAgentCommands::Remove, IAgentCommands::RemoveAll


IAgentCommands::Remove

HRESULT Remove(
   long dwID  // Command ID
);

Removes the specified Command from a Commands collection.

dwID

The ID of a Command to remove from the Commands collection.

Removing a Command from a Commands collection also removes it from the pop-up menu and the Voice Commands Window when your application is input-active.

See also IAgentCommands::Add, IAgentCommands::Insert, IAgentCommands::RemoveAll


IAgentCommands::RemoveAll

HRESULT Remove();

Removes all Commands from a Commands collection.

Removing all Commands from a Commands collection also removes them from the pop-up menu and the Voice Commands Window when your application is input-active. RemoveAll does not remove server or other client's entries.

See also IAgentCommands::Add, IAgentCommands::Insert, IAgentCommands::Remove


IAgentCommands::SetCaption

HRESULT SetCaption(
   BSTR bszCaption  // Caption setting for Commands collection
);

Sets the Caption text displayed for a Commands collection.

bszCaption

A BSTR that specifies the value for the Caption property for a Commands collection.

Setting the Caption property for a Commands collection defines how it will appear on the character's pop-up menu when its Visible property is set to True and your application is not the input-active client. To specify an access key (unlined mnemonic) for your Caption, include an ampersand (&) character before that character.

If you define commands for a Commands collection that has its Caption set, you typically also define a Caption for its Commands collection.

See also IAgentCommands::GetCaption, IAgentCommands::SetVisible, IAgentCommands::SetVoice


IAgentCommands::SetVisible

HRESULT SetVisible(
   long bVisible  // the Visible setting for Commands collection
);

Sets the value of the Visible property for a Commands collection.

bVisible

A Boolean value that determines the Visible property of a Commands collection. True sets the Commands collection's Caption to be visible when the character's pop-up menu is displayed; False does not display it.

A Commands collection must have its Caption property set and its Visible property set to True to appear on the character's pop-up menu. The Visible property must also be set to True for commands in the collection to appear when your client application is input-active.

See also IAgentCommands::GetVisible, IAgentCommands::SetCaption


IAgentCommands::SetVoice

HRESULT SetVoice(
   BSTR bszVoice  // the Voice setting for Command collection
);

Sets the Voice text property for a Command.

bszVoice

A BSTR that specifies the value for the Voice text property of a Commands collection.

A Commands collection must have its Voice text property set to be voice-accessible. It also must have its VoiceCaption or Caption property set to appear in the Voice Commands Window and its Visible property set to True to appear on the character's pop-up menu.

The BSTR expression you supply can include square bracket characters ([ ]) to indicate optional words and vertical bar characters (|) to indicate alternative strings. Alternates must be enclosed in parentheses. For example, "(hello [there] | hi)" tells the speech engine to accept "hello," "hello there," or "hi" for the command. Remember to include appropriate spaces between words you include in brackets or parentheses as well as other text. Remember to include appropriate spaces between the text that's in brackets or parentheses and the text that's not in brackets or parentheses.

You can use the star (*) operator to specify zero or more instances of the words included in the group or the plus (+) operator to specify one or more instances. For example, the following results in a grammar that supports "try this", "please try this", and "please please try this", with unlimited iterations of "please":

   "please* try this"

The following grammar format excludes "try this" because the + operator defines at least one instance of "please":

   "please+ try this"

The repetition operators follow normal rules of precedence and apply to the immediately preceding text item. For example, the following grammar results in "New York" and "New York York", but not "New York New York":

   "New York+"

Therefore, you typically want to use these operators with the grouping characters. For example, the following grammar includes both "New York" and "New York New York":

   "(New York)+"

Repetition operators are useful when you want to compose a grammar that includes a repeated sequence such as a phone number or specification of a list of items:

   "call (one|two|three|four|five|six|seven|eight|nine|zero|oh)*"
   "I'd like (cheese|pepperoni|pineapple|canadian bacon|mushrooms|and)+"

Although the operators can also be used with square brackets (an optional grouping character), doing so may reduce the efficiency of Agent's processing of the grammar.

You can also use an ellipsis (…) to support word spotting, that is, telling the speech recognition engine to ignore words spoken in this position in the phrase (sometimes called garbage words). When you use ellipses, the speech engine recognizes only specific words in the string regardless of when spoken with adjacent words or phrases. For example, if you set this property to "[…] check mail […]" the speech recognition engine will match phrases like "please check mail" or "check mail please" to this command. Ellipses can be used anywhere within a string. However, be careful using this technique as voice settings with ellipses may increase the potential of unwanted matches.

When defining the words and grammar for your command, include at least one word that is required; that is, avoid supplying only optional words. In addition, make sure that the word includes only pronounceable words and letters. For numbers, it is better to spell out the word rather than use an ambiguous representation. For example, "345" is not a good grammar form. Similarly, instead of "IEEE", use "I triple E". Also, omit any punctuation or symbols. For example, instead of "the #1 $10 pizza!", use "the number one ten dollar pizza". Including non-pronounceable characters or symbols for one command may cause the speech engine to fail to compile the grammar for all your commands. Finally, make your voice parameter as distinct as reasonably possible from other voice commands you define. The greater the similarity between the voice grammar for commands, the more likely the speech engine will make a recognition error. You can also use the confidence scores to better distinguish between two commands that may have similar or similar-sounding voice grammar.

You can include in your grammar words in the form of "text\pronunciation", where "text" is the text displayed and "pronunciation" is text that clarifies the pronunciation. For example, the grammar, "1st\first", would be recognized when the user says "first," but the Command event will return the text, "1st\first". You can also use IPA (International Phonetic Alphabet) to specify a pronunciation by beginning the pronunciation with a pound-sign character ("#"), then the text representing the IPA pronunciation.

For Japanese speech recognition engines, you can define grammar in the form "kana\kanji," reducing the alternative pronunciations and increasing the accuracy. (The ordering is reversed for backward compatibility.) This is particularly important for the pronunciation of proper names in Kanji. However, you can just pass in "kanji," without the Kana, in which case the engine should listen for all acceptable pronunciations for the Kanji. You can also pass in just Kana.

Except for errors using the grouping or repetition formatting characters, Microsoft Agent will not report errors in your grammar, unless the engine itself reports the error. If you pass text in your grammar that the engine fails to compile, but the engine does not handle and return as an error, Agent cannot report the error. Therefore, the client application must be careful defining the grammar for the Voice property.

Notes The grammar features available may depend on the speech recognition engine. You may want to check with the engine's vendor to determine what grammar options are supported. Use the SRModeID to use a specific engine.

The operation of this property depends on the state of Microsoft Agent server's speech recognition state. For example, if speech recognition is disabled or not installed, this function has no immediate effect. If speech recognition is enabled during a session, however, the command will become accessible when its client application is input-active.

See also IAgentCommands::GetVoice, IAgentCommands::SetCaption, IAgentCommands::SetVisible


IAgentCommandsEx

IAgentCommandsEx defines an interface that extends the IAgentCommands interface.

Methods in Vtable Order
IAgentCommandsEx Methods Description
SetDefaultID Sets the default command for the character's pop-up menu.
GetDefaultID Returns the default command for the character's pop-up menu.
SetHelpContextID Sets the context-sensitive help topic ID for a Commands object
GetHelpContextID Returns the context-sensitive help topic ID for a Command object .
SetFontName Sets the font to use in the character's pop-up menu.
GetFontName Returns the font used in the character's pop-up menu.
SetFontSize Sets the font size to use in the character's pop-up menu.
GetFontSize Returns the font size used in the character's pop-up menu.
SetVoiceCaption Sets the voice caption for the character's Commands object.
GetVoiceCaption Returns the voice caption for the character's Commands object.
AddEx Adds a Command object to a Commands collection.
InsertEx Inserts a Command object in a Commands collection.
SetGlobalVoiceCommandsEnabled Enables the voice grammar for Agent's global commands.
GetGlobalVoiceCommandsEnabled Returns whether the voice grammar for Agent's global commands is enabled.

IAgentCommandsEx::AddEx

HRESULT AddEx(
   BSTR bszCaption,       // Caption setting for Command
   BSTR bszVoice,         // Voice setting for Command
   BSTR bszVoiceCaption,  // VoiceCaption setting for Command
   long bEnabled,         // Enabled setting for Command
   long bVisible,         // Visible setting for Command
   long ulHelpID,         // HelpContextID setting for Command
   long * pdwID           // address for variable for ID
);

Adds a Command to a Commands collection.

bszCaption

A BSTR that specifies the value of the Caption text displayed for a Command in a Commands collection.

bszVoice

A BSTR that specifies the value of the Voice text setting for a Command in a Commands collection.

bszVoiceCaption

A BSTR that specifies the value of the VoiceCaption text displayed for a Command in a Commands collection.

bEnabled

A Boolean expression that specifies the Enabled setting for a Command in a Commands collection. If the parameter is True, the Command is enabled and can be selected; if False, the Command is disabled.

bVisible

A Boolean expression that specifies the Visible setting for a Command in a Commands collection. If the parameter is True, the Command will be visible in the character's pop-up menu (if the Caption property is also set).

ulHelpID

The context number of the help topic associated with the Command object; used to provide context-sensitive Help for the command.

pdwID

Address of a variable that receives the ID for the added Command.

IAgentCommandsEx::AddEx extends IAgentCommands::Add by including the HelpContextID property. You can also set the property using IAgentCommandsEx::SetHelpContextID

See also IAgentCommands::Add, IAgentCommandsEx::SetHelpContextID, IAgentCommand::SetCaption, IAgentCommand::SetEnabled, IAgentCommand::SetVisible, IAgentCommand::SetVoice, IAgentCommands::Insert, IAgentCommandsEx::InsertEx, IAgentCommands::Remove, IAgentCommands::RemoveAll


IAgentCommandsEx::GetDefaultID

HRESULT GetDefaultID(
   long * pdwID  // address of default command's ID
);

Retrieves the ID of the default command in a Commands collection.

pdwID

Address of a variable that receives the ID of the Command set as the default.

This property returns the current default Command object in your Commands collection. The default command is bold in the character's pop-up menu. However, setting the default command does not change command handling or double-click events.

This property applies only to your client application's use of the character; the setting does not affect other clients of the character or other characters of your client application.

See also IAgentCommandsEx::SetDefaultID


IAgentCommandsEx::GetFontName

HRESULT GetFontName(
   BSTR * pbszFontName  // address of variable for font displayed 
);                      // in character's pop-up menu

Retrieves the value for the font displayed in the character's pop-up menu.

pbszFontName

The address of a BSTR that receives the font name displayed in the character's pop-up menu.

The font name returned corresponds to the font used to display text in the character's pop-up menu when your client application is input-active. The default value for the font setting is based on the menu font setting for the character's language ID setting, or if not set, the user default language ID setting.

This property applies only to your client application's use of the character; the setting does not affect other clients of the character or other characters of your client application.

See also IAgentCommandsEx::SetFontName, IAgentCommandsEx::SetFontSize


IAgentCommandsEx::GetFontSize

HRESULT GetFontSize(
   long * plFontSize  // address of variable for font size 
);                    // for font displayed in character's pop-up menu

Retrieves the value for the size of the font displayed in the character's pop-up menu.

plFontSize

The address of a value that receives the size of the font.

The point size of the font returned corresponds to the size defined to display text in the character's pop-up menu when your client is input-active. The default value for the font setting is based on the menu font setting for the character's language ID setting, or if not set, the user default language setting.

This property applies only to your client application's use of the character; the setting does not affect other clients of the character or other characters of your client application.

See also IAgentCommandsEx::SetFontSize, IAgentCommandsEx::SetFontName


IAgentCommandsEx::GetGlobalVoiceCommandsEnabled

HRESULT GetGlobalVoiceCommandsEnabled(
     // address of the global voice command setting
);

Retrieves whether the voice grammar for Agent's global commands is enabled.

pbEnabled

The address that receives True if the voice grammar for Agent's global commands is enabled, False if disabled.

Microsoft Agent automatically adds voice parameters (grammar) for opening and closing the Voice Commands Window and for showing and hiding the character. When this method returns False, any voice parameters for these commands as well as the voice parameters for the Caption of other clients' Commands objects are not included in the grammar. This enables you to eliminate these from your client's current active grammar. However, this setting does not reflect the inclusion of these commands in the character's pop-up menu.

See also IAgentCommandsEx::SetGlobalVoiceCommandsEnabled


IAgentCommandsEx::GetHelpContextID

HRESULT GetHelpContextID(
   long * pulHelpID  // address of Commands object help topic ID
);

Retrieves the HelpContextID for a Commands object.

pulHelpID

Address of a variable that receives the context number of the help topic for the Commands object.

If you've created a Windows Help file for your application and set the character's HelpFile property, Microsoft Agent automatically calls Help when HelpModeOn is set to True and the user selects your Commands object. If there is a context number in the HelpContextID, Agent calls Help and searches for the topic identified by the current context number. The current context number is the value of HelpContextID for the Commands object.

This property applies only to your client application's use of the character; the setting does not affect other clients of the character or other characters of your client application.

Note Building a Help file requires the Microsoft Windows Help Compiler.

See also IAgentCommandsEx::SetHelpContextID, IAgentCharacterEx::SetHelpModeOn, IAgentCharacterEx::SetHelpFileName


IAgentCommandsEx::GetVoiceCaption

HRESULT GetVoiceCaption(
   BSTR * pbszVoiceCaption  // address of command's voice caption
);

Retrieves the VoiceCaption for a Commands object.

pbszVoiceCaption

The address of a BSTR that receives the value of the Caption text displayed for a Command.

The text returned is that set for your Commands object and appears in the Voice Commands window when your client application is input-active.

This property applies only to your client application's use of the character; the setting does not affect other clients of the character or other characters of your client application.

See also IAgentCommandsEx::SetVoiceCaption


IAgentCommandsEx::InsertEx

HRESULT InsertEx(
   BSTR bszCaption,       // Caption setting for Command
   BSTR bszVoice,         // Voice setting for Command
   BSTR bszVoiceCaption,  // VoiceCaption setting for Command
   long bEnabled,         // Enabled setting for Command
   long bVisible,         // Visible setting for Command
   long ulHelpID,         // HelpContextID setting for Command
   long dwRefID,          // reference Command for insertion
   long dBefore,          // insertion position flag
   long * pdwID           // address for variable for Command ID
);

Inserts a Command object in a Commands collection.

bszCaption

A BSTR that specifies the value of the Caption text displayed for the Command.

bszVoice

A BSTR that specifies the value of the Voice text setting for a Command.

bszVoiceCaption

A BSTR that specifies the value of the VoiceCaption text displayed for a Command in a Commands collection.

bEnabled

A Boolean expression that specifies the Enabled setting for a Command. If the parameter is True, the Command is enabled and can be selected; if False, the Command is disabled.

bVisible

A Boolean expression that specifies the Visible setting for a Command. If the parameter is True, the Command will be visible in the character's pop-up menu (if the Caption property is also set).

ulHelpID

The context number of the help topic associated with the Command object; used to provide context-sensitive Help for the command.

dwRefID

The ID of a Command used as a reference for the relative insertion of the new Command.

dBefore

A Boolean expression that specifies where to place the Command. If this parameter is True, the new Command is inserted before the referenced Command; if False, the new Command is placed after the referenced Command.

pdwID

Address of a variable that receives the ID for the inserted Command.

IAgentCommandsEx::InsertEx extends IAgentCommands::Insert by including the HelpContextID property. You can also set the property using IAgentCommandsEx::SetHelpContextID

See also IAgentCommandsEx::AddEx, IAgentCommandsEx::SetHelpContextID, IAgentCommands::Add, IAgentCommands::Remove, IAgentCommands::RemoveAll


IAgentCommandsEx::SetDefaultID

HRESULT SetDefaultID(
   long dwID,  // default command's ID
);

Sets the ID of the default command in a Commands collection.

dwID

The ID for the Command to be set as the default.

This property sets the default Command object set in your Commands collection. The default command is bold in the character's pop-up menu. However, setting the default command does not actually change command handling or double-click events.

This property applies only to your client application's use of the character; the setting does not affect other clients of the character or other characters of your client application.

See also IAgentCommandsEx::GetDefaultID


IAgentCommandsEx::SetFontName

HRESULT SetFontName(
   BSTR bszFontName  // font to be displayed in character's pop-up menu
);

Sets the font displayed in the character's pop-up menu.

bszFontName

A BSTR that sets the font displayed in the character's pop-up menu.

This property determines the font used to display text in the character's pop-up menu. The default value for the font setting is based on the menu font setting for the character's language ID setting -- or if that's not set -- the user default language ID setting.

This property applies only to your client application's use of the character; the setting does not affect other clients of the character or other characters of your client application.

See also IAgentCommandsEx::GetFontName, IAgentCommandsEx::GetFontSize, IAgentCommandsEx::SetFontSize


IAgentCommandsEx::SetFontSize

HRESULT SetFontSize(
   long lFontSize  // font size displayed in character's pop-up menu
);

Sets the size of the font displayed in the character's pop-up menu.

lFontSize

The size of the font.

This property determines the point size of the font used to display text in the character's pop-up menu when your client application is input-active. The default value for the font setting is based on the menu font setting for the character's language ID setting -- or if that's not set -- the user default language setting. If not input-active, your client application's Commands Caption text appears in the point size specified for the input-active client.

This property applies only to your client application's use of the character; the setting does not affect other clients of the character or other characters of your client application.

See also IAgentCommandsEx::GetFontSize, IAgentCommandsEx::GetFontName, IAgentCommandsEx::SetFontName


IAgentCommandsEx::SetGlobalVoiceCommandsEnabled

HRESULT SetGlobalVoiceCommandsEnabled(
   // Enabled setting for Agent's global voice commands
);

Sets the Enabled property for the voice grammar of Microsoft Agent's global commands.

bEnable

A Boolean value that sets whether the voice grammar of Agent's global commands is enabled. True enables the voice grammar; False disables it.

Microsoft Agent automatically adds voice parameters (grammar) for opening and closing the Voice Commands Window and for showing and hiding the character. When set to False, Agent disables any voice parameters for these commands as well as the voice parameters for the Caption of other client's Commands objects. This enables you to eliminate these from your client's current active grammar. However, because this potentially blocks voice access to other clients, reset this property to True after processing the user's voice input.

Disabling the property does not affect the character's pop-up menu. The global commands added by the server will still appear. You cannot remove them from the pop-up menu.

See also IAgentCommandsEx::GetGlobalVoiceCommandsEnabled


IAgentCommandsEx::SetHelpContextID

HRESULT SetHelpContextID(
   long ulHelpID  // ID for help topic
);

Sets the HelpContextID for a Command object.

ulHelpID

The context number of the help topic associated with the Command object; used to provide context-sensitive Help for the command.

If you've created a Windows Help file for your application and set this in the character's HelpFile property. Agent automatically calls Help when HelpModeOn is set to True and the user selects the command. If there is a context number in the HelpContextID, Agent calls Help and searches for the topic identified by the current context number. The current context number is the value of HelpContextID for the command. If there is a context number in the selected command's HelpContextID property, Help displays a topic corresponding to the current Help context; otherwise it displays "No Help topic associated with this item."

This property applies only to your client application's use of the character; the setting does not affect other clients of the character or other characters of your client application.

Note Building a Help file requires the Microsoft Windows Help Compiler.

See also IAgentCommandsEx::GetHelpContextID, IAgentCharacterEx::SetHelpModeOn, IAgentCharacterEx::SetHelpFileName


IAgentCommandsEx::SetVoiceCaption

HRESULT SetVoiceCaption(
   BSTR bszVoiceCaption  // voice caption text
);

Sets the VoiceCaption text displayed for the Commands object.

bszVoiceCaption

A BSTR that specifies the text for the VoiceCaption property for a Command.

If you define a Command object in a Commands collection and set its Voice property, you will typically also set its VoiceCaption property. This text will appear in the Voice Commands Window when your client application is input-active and the character is visible. If this property is not set, the setting for the Caption property determines the text displayed. When neither the VoiceCaption or Caption property is set, the command does not appear in the Voice Commands Window.

See also IAgentCommandsEx::GetVoiceCaption


IAgentCommand

A Command object is an item in a Commands collection. The server provides the user access to your commands your client application becomes input active. To retrieve a Command, call IAgentCommands::GetCommand.

IAgentCommand defines an interface that allows applications to set and query properties for Command objects that can appear in a character's pop-up menu and in the Voice Commands Window. These functions are also available from IAgentCommandEx. A Command object is an item in a Commands collection. The server provides the user access to your commands when your client application becomes input active.

A Command may appear in either or both the character's pop-up menu and the Voice Commands Window. To appear in the pop-up menu, it must have a Caption and have the Visible property set to True. The Visible property for its Commands collection object must also be set to True for the command to appear in the pop-up menu when your client application is input-active. To appear in the Voice Commands Window, a Command must have its VoiceCaption and Voice properties set. (For backward compatibility, if there is no VoiceCaption, the Caption setting is used.)

A character's pop-up menu entries do not change while the menu is displayed. If you add or remove Commands or change their properties while the character's popup menu is displayed, the menu displays those changes when redisplayed. However, the Voice Commands Window does display changes as you make them.

The following table summarizes how the properties of a command affect its presentation.

Caption Property Voice-Caption Property Voice Property Visible Property Appears in
Character's Pop-up Menu
Appears in
Voice Commands Window
Yes Yes Yes True Yes, using Caption Yes, using VoiceCaption
Yes Yes No* True Yes, using Caption No
Yes Yes Yes False No Yes, using VoiceCaption
Yes Yes No* False No No
No* Yes Yes True No Yes, using VoiceCaption
No* Yes Yes False No Yes, using VoiceCaption
No* Yes No* True No No
No* Yes No* False No No
Yes No* Yes True Yes, using Caption Yes, using Caption
Yes No* No* True Yes No
Yes No* Yes False No Yes, using Caption
Yes No* No* False No No
No* No* Yes True No No**
No* No* Yes False No No**
No* No* No* True No No
No* No* No* False No No

*If the property setting is null. In some programming languages, an empty string may not be interpreted as the same as a null string.

**The command is still voice-accessible.

Generally, if you define a Command with a Voice setting, you also define Caption and Voice settings for its associated Commands collection. If the Commands collection for a set of commands has no Voice or no Caption setting and is currently input-active, but the Commands have Caption and Voice settings, the Commands appear in the Voice Commands Window tree view under "(undefined command)" when your client application becomes input-active.

When the server receives input that matches one of the Command objects you defined for your Commands collection, it sends a IAgentNotifySink::Command event, and passes back the ID of the command as an attribute of the IAgentUserInput object. You can then use conditional statements to match and process the command.

Methods in Vtable Order
IAgentCommand Methods Description
SetCaption Sets the value for the Caption for a Command object.
GetCaption Returns the value of the Caption property of a Command object.
SetVoice Sets the value for the Voice text for a Command object.
GetVoice Returns the value of the Caption property of a Command object.
SetEnabled Sets the value of the Enabled property for a Command object.
GetEnabled Returns the value of the Enabled property of a Command object.
SetVisible Sets the value of the Visible property for a Command object.
GetVisible Returns the value of the Visible property of a Command object.
SetConfidenceThreshold Sets the value of the Confidence property for a Command object.
GetConfidenceThreshold Returns the value of the Confidence property of a Command object.
SetConfidenceText Sets the value of the ConfidenceText property for a Command object.
GetConfidenceText Returns the value of the ConfidenceText property of a Command object.
GetID Returns the ID of a Command object.

IAgentCommand::GetCaption

HRESULT GetCaption(
   BSTR * pbszCaption  // address of Caption for Command
);

Retrieves the Caption for a Command.

pbszCaption

The address of a BSTR that receives the value of the Caption text displayed for a Command.

See also IAgentCommand::SetCaption, IAgentCommand::SetEnabled, IAgentCommand::SetVisible, IAgentCommand::SetVoice, IAgentCommands::Add, IAgentCommands::Insert


IAgentCommand::GetConfidenceText

HRESULT GetConfidenceText(
   BSTR * pbszTipText  // address of ConfidenceText setting for Command 
);

Retrieves the Listening Tip text previously set for a Command.

pbszTipText

The address of a BSTR that receives the value of the Listening Tip text for a Command.

See also IAgentCommand::SetConfidenceThreshold, IAgentCommand::GetConfidenceThreshold, IAgentCommand::SetConfidenceText, IAgentUserInput::GetItemConfidence


IAgentCommand::GetConfidenceThreshold

HRESULT GetConfidenceThreshold(
long * plConfidenceThreshold  // address of ConfidenceThreshold 
);                            // setting for Command

Retrieves the value of the ConfidenceThreshold property for a Command.

plConfidenceThreshold

The address of a variable that receives the value of the ConfidenceThreshold property for a Command.

See also IAgentCommand::SetConfidenceThreshold, IAgentCommand::SetConfidenceText, IAgentUserInput::GetItemConfidence


IAgentCommand::GetEnabled

HRESULT GetEnabled(
   long * pbEnabled  // address of Enabled setting for Command
);

Retrieves the value of the Enabled property for a Command.

pbEnabled

The address of a variable that receives True if the Command is enabled, or False if it is disabled. A disabled Command cannot be selected.

See also IAgentCommand::SetCaption, IAgentCommand::SetVisible, IAgentCommand::SetVoice, IAgentCommands::Add, IAgentCommands::Insert /P>


IAgentCommand::GetID

HRESULT GetID(
   long * pdwID  // address of ID for Command
);

Retrieves the ID for a Command.

pdwID

The address of a variable that receives the ID of a Command.

See also IAgentCommands::Add, IAgentCommands::Insert, IAgentCommands::Remove


IAgentCommand::GetVisible

HRESULT GetVisible(
   long * pbVisible  // address of Visible setting for Command
);

Retrieves the value of the Visible property for a Command.

pbVisible

The address of a variable that receives the Visible property for a Command.

See also IAgentCommand::SetVisible, IAgentCommand::SetCaption, IAgentCommands::Add, IAgentCommands::Insert


IAgentCommand::GetVoice

HRESULT GetVoice(
   BSTR * pbszVoice  // address of Voice setting for Command
);

Retrieves the value of the Voice text property for a Command.

pbszVoice

The address of a BSTR that receives the Voice text property for a Command.

A Command with its Voice property set and its Enabled property set to True will be voice-accessible. If its Caption property is also set it appears in the Voice Commands Window. If its Visible property is set to True, it appears in the character's pop-up menu.

See also IAgentCommand::SetVoice, IAgentCommands::Add, IAgentCommands::Insert


IAgentCommand::SetCaption

HRESULT SetCaption(
   BSTR bszCaption  // Caption setting for Command
);

Sets the Caption text displayed for a Command.

bszCaption

A BSTR that specifies the text for the Caption property for a Command.

Setting the Caption property for a Command defines how it will appear on the character's pop-up menu when its Visible property is set to True and your application is not the input-active client. To specify an access key (unlined mnemonic) for your Caption, include an ampersand (&) character before that character. To make it selectable, its Enabled property must be set to True.

See also IAgentCommand::GetCaption, IAgentCommand::SetEnabled, IAgentCommand::SetVisible, IAgentCommand::SetVoice, IAgentCommands::Add, IAgentCommands::Insert


IAgentCommand::SetConfidenceThreshold

HRESULT SetConfidenceThreshold(
   long lConfidence  // Confidence setting for Command
);

Sets the value of the Confidence property for a Command.

lConfidence

The value for the Confidence property of a Command.

If the confidence value returned of the best match returned in the Command event does not exceed the value set for the ConfidenceThreshold property, the text supplied in SetConfidenceText is displayed in the Listening Tip.

See also IAgentCommand::GetConfidenceThreshold, IAgentCommand::SetConfidenceText, IAgentUserInput::GetItemConfidence


IAgentCommand::SetConfidenceText

HRESULT SetConfidenceText(
   BSTR bszTipText  // ConfidenceText setting for Command 
);

Sets the value of the Listening Tip text for a Command.

bszTipText

A BSTR that specifies the text for the ConfidenceText property of a Command.

If the confidence value returned of the best match returned in the Command event does not exceed the value set for the ConfidenceThreshold property, the text supplied in bszTipText is displayed in the Listening Tip.

See also IAgentCommand::SetConfidenceThreshold, IAgentCommand::GetConfidenceThreshold, IAgentCommand::GetConfidenceText, IAgentUserInput::GetItemConfidence


IAgentCommand::SetEnabled

HRESULT SetEnabled(
   long bEnabled  // Enabled setting for Command
);

Sets the Enabled property for a Command.

bEnabled

A Boolean value that sets the value of the Enabled setting of a Command. True enables the Command; False disables it. A disabled Command cannot be selected.

A Command must have its Enabled property set to True to be selectable. It also must have its Caption property set and its Visible property set to True to appear in the character's pop-up menu. To make the Command appear in the Voice Commands Window, you must set its Voice property.

See also IAgentCommand::GetCaption, IAgentCommand::SetVoice, IAgentCommands::Add, IAgentCommands::Insert


IAgentCommand::SetVisible

HRESULT SetVisible(
   long bVisible  // Visible setting for Command
);

Sets the value of the Visible property for a Command.

bVisible

A Boolean value that determines the Visible property of a Command. True shows the Command; False hides it.

A Command must have its Visible property set to True and its Caption property set to appear in the character's pop-up menu.

See also IAgentCommand::GetVisible, IAgentCommand::SetCaption, IAgentCommands::Add, IAgentCommands::Insert


IAgentCommand::SetVoice

HRESULT SetVoice(
   BSTR bszVoice  // voice text setting for Command
);

Sets the Voice property for a Command.

bszVoice

A BSTR that specifies the text for the Voice property of a Command.

A Command must have its Voice property and Enabled property set to be voice-accessible. It also must have its VoiceCaption property set to appear in the Voice Commands Window. (For backward compatibility, if there is no VoiceCaption, the Caption setting is used.)

The BSTR expression you supply can include square bracket characters ([ ]) to indicate optional words and vertical bar characters (|) to indicate alternative strings. Alternates must be enclosed in parentheses. For example, "(hello [there] | hi)" tells the speech engine to accept "hello," "hello there," or "hi" for the command. Remember to include appropriate spaces between the text that's in brackets or parentheses and the text that's not in brackets or parentheses.

You can use the star (*) operator to specify zero or more instances of the words included in the group or the plus (+) operator to specify one or more instances. For example, the following results in a grammar that supports "try this", "please try this", and "please please try this", with unlimited iterations of "please":

   "please* try this"

The following grammar format excludes "try this" because the + operator defines at least one instance of "please":

   "please+ try this"

The repetition operators follow normal rules of precedence and apply to the immediately preceding text item. For example, the following grammar results in "New York" and "New York York", but not "New York New York":

   "New York+"

Therefore, you will typically want to use these operators with the grouping characters. For example, the following grammar includes both "New York" and "New York New York":

   "(New York)+"

Repetition operators are useful when you want to compose a grammar that includes a repeated sequence such as a phone number or specification of a list of items:

   "call (one|two|three|four|five|six|seven|eight|nine|zero|oh)*"
   "I'd like (cheese|pepperoni|pineapple|canadian bacon|mushrooms|and)+"

Although the operators can also be used with the square brackets (an optional grouping character), doing so may reduce the efficiency of Agent's processing of the grammar.

You can also use an ellipsis (…) to support word spotting, that is, telling the speech recognition engine to ignore words spoken in this position in the phrase (sometimes called garbage words). Therefore, the speech engine recognizes only specific words in the string regardless of when spoken with adjacent words or phrases. For example, if you set this property to "[…] check mail […]" the speech recognition engine will match phrases like "please check mail" or "check mail please" to this command. Ellipses can be used anywhere within a string. However, be careful using this technique, because voice settings with ellipses may increase the potential of unwanted matches.

When defining the words and grammar for your command, always make sure that you include at least one word that is required; that is, avoid supplying only optional words. In addition, make sure that the word includes only pronounceable words and letters. For numbers, it is better to spell out the word rather than using the numeric representation. Also, omit any punctuation or symbols. For example, instead of "the #1 $10 pizza!", use "the number one ten dollar pizza". Including non-pronounceable characters or symbols for one command may cause the speech engine to fail to compile the grammar for all your commands. Finally, make your voice parameter as distinct as reasonably possible from other voice commands you define. The greater the similarity between the voice grammar for commands, the more likely the speech engine will make a recognition error. You can also use the confidence scores to better distinguish between two commands that may have similar or similar-sounding voice grammar.

Setting the Voice property for a Command automatically enables Agent's speech services, making the Listening key and Listening Tip available. However, it does not load the speech recognition engine.

Note The grammar features available may depend on the speech recognition engine. You may want to check with the engine's vendor to determine what grammar options are supported. Use IAgentCharacterEx::SRModeID to specify an engine.

See also IAgentCommand::GetVoice, IAgentCommand::SetCaption, IAgentCommand::SetEnabled, IAgentCommands::Add, IAgentCommands::Insert


IAgentCommandEx

IAgentCommandEx is derived from the IAgentCommand interface. It includes all the IAgentCommand methods and provides access to additional functions.

Methods in Vtable Order
IAgentCommandEx Methods Description
SetHelpContextID Sets the context-sensitive help topic ID for a Command object.
GetHelpContextID Returns the context-sensitive help topic ID for a Command object.
SetVoiceCaption Sets the voice caption for a Command object.
GetVoiceCaption Returns the voice caption for a Command object.

IAgentCommandEx::GetHelpContextID

HRESULT GetHelpContextID(
   long * pulID  //  address of command's help topic ID
);

Retrieves the HelpContextID for a Command object.

pulID

Address of a variable that receives the context number of the help topic associated with the Command object.

If you've created a Windows Help file for your application and set your character's HelpFile property to this file, Microsoft Agent automatically calls Help when HelpModeOn is set to True and the user selects the command. If there is a context number in the HelpContextID, Agent calls Help and searches for the topic identified by the current context number. The current context number is the value of HelpContextID for the command.

Note Building a Help file requires the Microsoft Windows Help Compiler.

See also IAgentCommandEx::SetHelpContextID, IAgentCharacterEx::SetHelpModeOn, IAgentCharacterEx::SetHelpFileName


IAgentCommandEx::GetVoiceCaption

HRESULT GetVoiceCaption(
   BSTR * pbszVoiceCaption  // address of command's voice caption text
);

Retrieves the VoiceCaption for a Command.

pbszVoiceCaption

The address of a BSTR that receives the value of the Caption text displayed for a Command.

The VoiceCaption is the text that appears for a Command object in the Voice Commands Window when your client application is input-active.

See also IAgentCommandEx::SetVoiceCaption, IAgentCommand::SetEnabled, IAgentCommand::SetVisible, IAgentCommand::SetVoice, IAgentCommandsEx::AddEx, IAgentCommandsEx::InsertEx, IAgentCommands::Add, IAgentCommands::Insert


IAgentCommandEx::SetHelpContextID

HRESULT SetHelpContextID(
   long ulID  //  ID for help topic
);

Sets the HelpContextID for a Command object.

ulID

The context number of the help topic associated with the Command object; used to provide context-sensitive Help for the command.

If you've created a Windows Help file for your application and set this in the character's HelpFile property. Microsoft Agent automatically calls Help when HelpModeOn is set to True and the user selects the command. If there is a context number in the HelpContextID, Agent calls Help and searches for the topic identified by the current context number. The current context number is the value of HelpContextID for the command.

Note Building a Help file requires the Microsoft Windows Help Compiler.

See also IAgentCommandEx::GetHelpContextID, IAgentCharacterEx::SetHelpModeOn, IAgentCharacterEx::SetHelpFileName


IAgentCommandEx::SetVoiceCaption

HRESULT SetVoiceCaption(
   BSTR bszVoiceCaption  // voice caption text
);

Sets the VoiceCaption text displayed for a Command.

bszVoiceCaption

A BSTR that specifies the text for the VoiceCaption property for a Command.

If you define a Command object in a Commands collection and set its Voice property, you will typically also set its VoiceCaption property. This text will appear in the Voice Commands Window when your client application is input active. If this property is not set, the setting for the Caption property determines the text displayed. When neither the VoiceCaption or Caption property is set, the command does not appear in the Voice Commands Window.

See also IAgentCommand::GetCaption, IAgentCommand::SetEnabled, IAgentCommand::SetVisible, IAgentCommand::SetVoice, IAgentCommandsEx::AddEx, IAgentCommandsEx::InsertEx, IAgentCommands::Add, IAgentCommands::Insert


IAgentUserInput

When the server notifies the input-active client with IAgentNotifySink::Command it returns information through the UserInput object. IAgentUserInput defines an interface that allows applications to query these values.

Methods in Vtable Order
IAgentUserInput Methods Description
GetCount Returns the number of command alternatives returned in a Command event.
GetItemId Returns the ID for a specific Command alternative.
GetItemConfidence Returns the value of the Confidence property for a specific Command alternative.
GetItemText Returns the value of Voice text for a specific Command alternative.
GetAllItemData Returns the data for all Command alternatives.

IAgentUserInput::GetAllItemData

HRESULT GetAllItemData(
   VARIANT * pdwItemIndices,  // address of variable for alternative IDs
   VARIANT * plConfidences,   // address of variable for confidence scores
   VARIANT * pbszText         // address of variable for voice text
);

Retrieves the data for all Command alternatives passed to an IAgentNotifySink::Command callback.

pdwItemIndices

Address of a variable that receives the IDs of Commands passed to the IAgentNotifySink::Command callback.

plConfidences

Address of a variable that receives the confidence scores for Command alternatives passed to the IAgentNotifySink::Command callback.

pbszText

Address of a variable that receives the voice text for Command alternatives passed to the IAgentNotifySink::Command callback.

If speech input triggers IAgentNotifySink::Command, the server returns the best match, the second-best match, and the third-best match, if these are provided by the speech engine. It provides the relative confidence scores, in the range of -100 to 100, and actual text "heard" by the speech engine. If the best match was a server-supplied command, the server sends a NULL ID, but still sends a confidence score and the Voice text.

If speech input was not the source for the event; for example, if the user selected the command from the character's pop-up menu, the Microsoft Agent server returns the ID of the Command selected, with a confidence score of 100 and voice text as NULL. The other alternatives return as NULL with confidence scores of zero (0) and voice text as NULL.

Note Not all speech recognition engines may return all the values for all the parameters of this event. Check with your engine vendor to determine whether the engine supports the Microsoft Speech API interface for returning alternatives and confidence scores.

See also IAgentUserInput::GetItemConfidence, IAgentUserInput::GetItemText, IAgentUserInput::GetItemID


IAgentUserInput::GetCount

HRESULT GetCount(
   long * pdwCount  // address of a variable for number of alternatives 
);

Retrieves the number of Command alternatives passed to an IAgentNotifySink::Command callback.

pdwCount

Address of a variable that receives the count of Commands alternatives identified by the server.

If voice input was not the source for the command, for example, if the user selected the command from the character's pop-up menu, GetCount returns 1. If GetCount returns zero (0), the speech recognition engine detected spoken input but determined that there was no matching command.

IAgentUserInput::GetItemConfidence

HRESULT GetItemConfidence(
   long dwItemIndex,    // index of Command alternative
   long * plConfidence  // address of confidence value for Command 
);

Retrieves the confidence value for a Command passed to an IAgentNotifySink::Command callback.

dwItemIndex

The index of a Command alternative passed to the IAgentNotifySink::Command callback.

plConfidence

Address of a variable that receives the confidence score for a Command alternative passed to the IAgentNotifySink::Command callback.

If voice input was not the source for the command, for example, if the user selected the command from the character's pop-up menu, the Microsoft Agent server returns the confidence value of the best match as 100 and the confidence values for all other alternatives as zero (0).

See also IAgentUserInput::GetItemID, IAgentUserInput::GetAllItemData, IAgentUserInput::GetItemText


IAgentUserInput::GetItemID

HRESULT GetItemID(
   long dwItemIndex,    // index of Command alternative
   long * pdwCommandID  // address of a variable for number of alternatives 
);

Retrieves the identifier of a Command alternative passed to an IAgentNotifySink::Command callback.

dwItemIndex

The index of the Command alternative passed to the IAgentNotifySink::Command callback.

pdwCommandID

Address of a variable that receives the ID of a Command.

If voice input triggers the IAgentNotifySink::Command callback, the server returns the IDs for any matching Commands defined by your application.

See also IAgentUserInput::GetItemConfidence, IAgentUserInput::GetItemText, IAgentUserInput::GetAllItemData


IAgentUserInput::GetItemText

HRESULT GetItemText(
   Long dwItemIndex,  // index of Command alternative
   BSTR * pbszText    // address of voice text for Command 
);

Retrieves the voice text for a Command alternative passed to the IAgentNotifySink::Command callback.

dwItemIndex

The index of a Command alternative passed to the IAgentNotifySink::Command callback.

pbszText

Address of a BSTR that receives the value of the voice text for the Command.

If voice input was not the source for the command, for example, if the user selected the command from the character's pop-up menu, the server returns NULL for the Command's voice text.

See also IAgentUserInput::GetItemConfidence, IAgentUserInput::GetItemID, IAgentUserInput::GetAllItemData


IAgentBalloon

IAgentBalloon defines an interface that allows applications to query properties for the Microsoft Agent word balloon. These functions are also available from IAgentBalloonEx.

Initial defaults for a character's word balloon are set in the Microsoft Agent Character Editor, but once the application is running, the user may override the Enabled and Font properties. If a user changes the balloon's properties, the change affects all characters. The IAgentBalloon object's properties also apply to text output through the Think method.

Methods in Vtable Order
IAgentBalloon Methods Description
GetEnabled Returns whether the word balloon is enabled.
GetNumLines Returns the number of lines displayed in the word balloon.
GetNumCharsPerLine Returns the average number of characters per line displayed in the word balloon.
GetFontName Returns the name of the font displayed in the word balloon.
GetFontSize Returns the size of the font displayed in the word balloon.
GetFontBold Returns whether the font displayed in the word balloon is bold.
GetFontItalic Returns whether the font displayed in the word balloon is italic.
GetFontStrkethru Returns whether the font displayed in the word balloon is displayed as strikethrough.
GetFontUnderline Returns whether the font displayed in the word balloon is underlined.
GetForeColor Returns the foreground color displayed in the word balloon.
GetBackColor Returns the background color displayed in the word balloon.
GetBorderColor Returns the border color displayed in the word balloon.
SetVisible Sets the word balloon to be visible.
GetVisible Returns the visibility setting for the word balloon.
SetFontName Sets the font used in the word balloon.
SetFontSize Sets the font size used in the word balloon.
SetFontCharSet Sets the character set used in the word balloon.
GetFontCharSet Returns the character set used in the word balloon.

IAgentBalloon::GetBackColor

HRESULT GetBackColor(
   long * plBGColor  // address of variable for background color displayed
);                   // in word balloon

Retrieves the value for the background color displayed in a word balloon.

plBGColor

The address of a variable that receives the color setting for the balloon background.

The background color used in a character word balloon is defined in the Microsoft Agent Character Editor. It cannot be changed by an application. However, the user can change the background color of the word balloons for all characters through the Microsoft Agent property sheet.

See also IAgentBalloon::GetForeColor


IAgentBalloon::GetBorderColor

HRESULT GetBorderColor (
  long * plBorderColor// address of variable for border color displayed
);                    // for word balloon

Retrieves the value for the border color displayed for a word balloon.

plBorderColor

The address of a variable that receives the color setting for the balloon border.

The border color for a character word balloon is defined in the Microsoft Agent Character Editor. It cannot be changed by an application. However, the user can change the border color of the word balloons for all characters through the Microsoft Agent property sheet.

See also IAgentBalloon::GetBackColor, IAgentBalloon::GetForeColor


IAgentBalloon::GetEnabled

HRESULT GetEnabled(
  long * pbEnabled  // address of variable for Enabled setting 
);                  // for word balloon

Retrieves the value of the Enabled property for a word balloon.

pbEnabled

The address of a variable that receives True when the word balloon is enabled and False when it is disabled.

The Microsoft Agent server automatically displays the word balloon for spoken output, unless it is disabled. The word balloon can be disabled for a character in the Microsoft Agent Character Editor, or (by the user) for all characters in the Microsoft Agent property sheet. If the user disables the word balloon, the client cannot restore it.


IAgentBalloon::GetFontBold

HRESULT GetFontBold(
   long * pbFontBold  // address of variable for bold setting for
);                    // font displayed in word balloon 

Indicates whether the font used in a word balloon is bold.

pbFontBold

The address of a value that receives True if the font is bold and False if not bold.

The font style used in a character word balloon is defined in the Microsoft Agent Character Editor. It cannot be changed by an application. However, the user can override the font settings for all characters through the Microsoft Agent property sheet.


IAgentBalloon::GetFontCharSet

HRESULT GetFontCharSet(
   short * psFontCharSet  // character set displayed in word balloon
); 

Indicates the character set of the font displayed in a word balloon.

psFontCharSet

The address of a value that receives the font's character set. The following are some common settings for value:

0 Standard Windows characters (ANSI).
1 Default character set.
2 The symbol character set.
128 Double-byte character set (DBCS) unique to the Japanese version of Windows.
129 Double-byte character set (DBCS) unique to the Korean version of Windows.
134 Double-byte character set (DBCS) unique to the Simplified Chinese version of Windows.
136 Double-byte character set (DBCS) unique to the Traditional Chinese version of Windows.
255 Extended characters usually displayed by MS-DOS® applications.

For other character set values, consult the Microsoft Win32 documentation.

The default character set used in a character's word balloon is defined in the Microsoft Agent Character Editor. You can change it using IAgentBalloon::SetFontCharSet. However, the user can override the character set setting for all characters using the Microsoft Agent property sheet.

See also IAgentBalloon::SetFontCharSet


IAgentBalloon::GetFontItalic

HRESULT GetFontItalic(
   long * pbFontItalic  // address of variable for italic setting for 
);                      // font displayed in word balloon 

Indicates whether the font used in a word balloon is italic.

pbFontItalic

The address of a value that receives True if the font is italic and False if not italic.

The font style used in a character's word balloon is defined in the Microsoft Agent Character Editor. It cannot be changed by an application. However, the user can override the font settings for all characters through the Microsoft Agent property sheet.


IAgentBalloon::GetFontName

HRESULT GetFontName(
   BSTR * pbszFontName  // address of variable for font displayed 
);                      // in word balloon
                   

Retrieves the value for the font displayed in a word balloon.

pbszFontName

The address of a BSTR that receives the font name displayed in a word balloon.

The default font used in a character word balloon is defined in the Microsoft Agent Character Editor. You can change it with IAgentBalloon::SetFontName. The user can override the font setting for all characters using the Microsoft Agent property sheet.


IAgentBalloon::GetFontSize

HRESULT GetFontSize(
   long * plFontSize  // address of variable for font size 
);                    // for font displayed in word balloon 

Retrieves the value for the size of the font displayed in a word balloon.

plFontSize

The address of a value that receives the size of the font.

The default font size used in a character word balloon is defined in the Microsoft Agent Character Editor. You can change it with IAgentBalloon::SetFontSize. However, the user can override the font size settings for all characters using the Microsoft Agent property sheet.


IAgentBalloon::GetFontStrikethru

HRESULT GetFontStrikethru(
   long * pbFontStrikethru  // address of variable for strikethrough setting 
);                          // for font displayed in word balloon 

Indicates whether the font used in a word balloon has the strikethrough style set.

pbFontStrikethru

The address of a value that receives True if the font strikethrough style is set and False if not.

The font style used in a character word balloon is defined in the Microsoft Agent Character Editor. It cannot be changed by an application. However, the user can override the font settings for all characters using the Microsoft Agent property sheet.


IAgentBalloon::GetFontUnderline

HRESULT GetFontUnderline(
   long * pbFontUnderline  // address of variable for underline setting
);                         // for font displayed in word balloon 

Indicates whether the font used in a word balloon has the underline style set.

pbFontUnderline

The address of a value that receives True if the font underline style is set and False if not.

The font style used in a character word balloon is defined in the Microsoft Agent Character Editor. It cannot be changed by an application. However, the user can override the font settings for all characters using the Microsoft Agent property sheet.


IAgentBalloon::GetForeColor

HRESULT GetForeColor(
   long * plFGColor // address of variable for foreground color displayed
);                  // in word balloon

Retrieves the value for the foreground color displayed in a word balloon.

plFGColor

The address of a variable that receives the color setting for the balloon foreground.

The foreground color used in a character word balloon is defined in the Microsoft Agent Character Editor. It cannot be changed by an application. However, the user can override the foreground color of the word balloons for all characters through the Microsoft Agent property sheet.

See also IAgentBalloon::GetBackColor


IAgentBalloon::GetNumCharsPerLine

HRESULT GetNumCharsPerLine(
   long * plCharsPerLine  // address of variable for characters per line
);                        // displayed in word balloon

Retrieves the value for the average number of characters per line displayed in a word balloon.

The address of a variable that receives the number of characters per line.

The Microsoft Agent server automatically scrolls the lines displayed for spoken output in the word balloon. The average number of characters per line for a character's word balloon is defined in the Microsoft Agent Character Editor. It cannot be changed by an application.

See also IAgentBalloon::GetNumLines


IAgentBalloon::GetNumLines

HRESULT GetNumLines(
   long * pcLines  // address of variable for number of lines 
);                  // displayed in word balloon

Retrieves the value of the number of lines displayed in a word balloon.

pcLines

The address of a variable that receives the number of lines displayed.

The Microsoft Agent server automatically scrolls the lines displayed for spoken output in the word balloon. The number of lines for a character word balloon is defined in the Microsoft Agent Character Editor. It cannot be changed by an application.

See also IAgentBalloon::GetNumCharsPerLine


IAgentBalloon::GetVisible

HRESULT GetVisible(
   long * pbVisible  // address of variable for word balloon
);                   // Visible setting

Determines whether the word balloon is visible or hidden.

pbVisible

Address of a variable that receives True if the word balloon is visible and False if hidden.

See also IAgentBalloon::SetVisible


IAgentBalloon::SetFontCharSet

HRESULT SetFontCharSet(
   short sFontCharSet  // character set displayed in word balloon
); 

Sets the character set of the font displayed in the word balloon.

sFontCharSet

The character set of the font. The following are some common settings for value:

0 Standard Windows characters (ANSI).
1 Default character set.
2 The symbol character set.
128 Double-byte character set (DBCS) unique to the Japanese version of Windows.
129 Double-byte character set (DBCS) unique to the Korean version of Windows.
134 Double-byte character set (DBCS) unique to the Simplified Chinese version of Windows.
136 Double-byte character set (DBCS) unique to the Traditional Chinese version of Windows.
255 Extended characters usually displayed by MS-DOS applications.

For other character set values, consult the Microsoft Win32 documentation.

The default character set used in a character's word balloon is defined in the Microsoft Agent Character Editor. You can change it with IAgentBalloon::SetFontCharSet. However, the user can override the character set setting for all characters using the Microsoft Agent property sheet. This property applies only to your client application's use of the character; the setting does not affect other clients of the character or other characters of your client application.

See also IAgentBalloon::GetFontCharSet


IAgentBalloon::SetFontName

HRESULT SetFontName(
   BSTR bszFontName  // font displayed in word balloon
);
                   

Sets the font displayed in the word balloon.

bszFontName

A BSTR that sets the font displayed in the word balloon.

The default font used in a character's word balloon is defined in the Microsoft Agent Character Editor. You can change it with IAgentBalloon::SetFontName. However, the user can override the font setting for all characters using the Microsoft Agent property sheet.

See also IAgentBalloon::GetVisible


IAgentBalloon::SetFontSize

HRESULT SetFontSize(
   long lFontSize  // font size displayed in word balloon
); 

Sets the size of the font displayed in the word balloon.

lFontSize

The size of the font.

The default font size used in a character's word balloon is defined in the Microsoft Agent Character Editor. You can change it with IAgentBalloon::SetFontSize. However, the user can override the font size setting for all characters using the Microsoft Agent property sheet.

See also IAgentBalloon::GetFontSize


IAgentBalloon::SetVisible

HRESULT SetVisible(
   long bVisible  // word balloon Visible setting 
);

Sets the Visible property for the word balloon.

bVisible

Visible property setting. A value of True displays the word balloon; a value of False hides it.

See also IAgentBalloon::GetVisible


IAgentBalloonEx

IAgentBalloonEx is derived from the IAgentBalloon interface. It includes all the IAgentBalloon methods and provides access to additional functions.

Methods in Vtable Order
IAgentBalloonEx Methods Description
GetStyle Returns the word balloon's output style.
SetStyle Sets the word balloon's output style.
SetNumLines Sets the number lines output in the word balloon.
SetNumCharsPerLine Sets the number of characters per line output in the word balloon.

IAgentBalloonEx::GetStyle

HRESULT GetStyle(
   long * plStyle,  // address of style settings
);

Retrieves the character's word balloon style settings.

plStyle

Style settings for the word balloon, which can be a combination of any of the following values:

const unsigned short
BALLOON_STYLE_BALLOONON = 0x00000001;
The balloon is supported for output.
const unsigned short
BALLOON_STYLE _SIZETOTEXT = 0x0000002;
The balloon height is sized to accommodate the text output.
const unsigned short
BALLOON_STYLE _AUTOHIDE = 0x00000004;
The balloon is automatically hidden.
const unsigned short
BALLOON_STYLE _AUTOPACE = 0x00000008;
The text output is paced based on the output rate.

When the BalloonOn style bit is set, the word balloon appears when the Speak or Think method is used, unless the user overrides its display through the Microsoft Agent property sheet. When not set, no balloon appears.

When the SizeToText style bit is set, the word balloon automatically sizes the height of the balloon to the current size of the text specified in the Speak or Think method. When not set, the balloon's height is based on the balloon's number of lines property setting. This style bit is set to 1 and an attempt to use IAgentBalloonEx::SetNumLines will result in an error.

When the AutoHide style bit is set, the word balloon automatically hides after a short time-out. When not set, the balloon displays until a new Speak or Think call, the character is hidden, or the user clicks or drags the character.

When the AutoPace style bit is set, the word balloon paces the output based on the current output rate, for example, one word at a time. When output exceeds the size of the balloon, the former text is automatically scrolled. When not set, all text included in a Speak or Think statement displays at once.

This property applies only to your client application's use of the character; the setting does not affect other clients of the character or other characters of your client application.

The defaults for these style bits are based on the settings when the character is compiled through the Microsoft Agent Character Editor.

See also IAgentBalloonEx::SetStyle


IAgentBalloonEx::SetNumCharsPerLine

HRESULT SetNumCharsPerLine(
   long lCharsPerLine,  // number of characters per line setting
);

Sets the number of characters per line that can be displayed in the character's word balloon.

lCharsPerLine

Number of lines to display in the word balloon.

The minimum setting is 8 and the maximum is 255. If the text specified in the Speak or Think method exceeds the size of the current balloon, Agent automatically scrolls the text in the balloon.

The default setting is based on settings when the character is compiled with the Microsoft Agent Character Editor.

See also IAgentBalloon::GetNumCharsPerLine


HRESULT SetNumLines(
   long lLines,  // number of lines setting
);

Sets the number of lines of text output that can be displayed in the character's word balloon.

lLines

Number of lines to display in the word balloon.

The minimum setting is 1 and maximum is 128. If the text specified in the Speak or Think method exceeds the size of the current balloon, Agent automatically scrolls the text in the balloon.

This method will fail if the SizeToText balloon style bit is set.

The default setting is based on settings when the character is compiled with the Microsoft Agent Character Editor.

See also IAgentBalloon::GetNumLines, IAgentBalloonEx::GetStyle, IAgentBalloonEx::SetStyle


IAgentBalloonEx::SetStyle

HRESULT SetStyle(
   long lStyle,  // style settings
);

Retrieves the character's word balloon style settings.

lStyle

Style settings for the word balloon, which can be a combination of any of the following values:

const unsigned short
BALLOON_STYLE_BALLOONON = 0x00000001;
The balloon is supported for output.
const unsigned short
BALLOON_STYLE _SIZETOTEXT = 0x0000002;
The balloon height is sized to accommodate the text output.
const unsigned short
BALLOON_STYLE _AUTOHIDE = 0x00000004;
The balloon is automatically hidden.
const unsigned short
BALLOON_STYLE _AUTOPACE = 0x00000008;
The text output is paced based on the output rate.

When the BalloonOn style bit is set, the word balloon appears when the Speak or Think method is used, unless the user overrides its display in the Microsoft Agent property sheet. When not set, no balloon appears.

When the SizeToText style bit is set, the word balloon automatically sizes the height of the balloon to the current size of the text specified in the Speak or Think method. When not set, the balloon's height is based on the balloon's number of lines property setting. This style bit is set to 1 and an attempt to use IAgentBalloonEx::SetNumLines will result in an error.

When the AutoHide style bit is set, the word balloon automatically hides after a short timeout. When not set, the balloon displays until a new Speak or Think call, the character is hidden, or the user clicks or drags the character.

When the AutoPace style bit is set, the word balloon paces the output based on the current output rate, for example, one word at a time. When output exceeds the size of the balloon, the former text is automatically scrolled. When not set, all text included in a Speak or Think statement displays at once.

The Balloon's style property can be set even if the user has disabled display of the Balloon using the Microsoft Agent property sheet.

This property applies only to your client application's use of the character; the setting does not affect other clients of the character or other characters of your client application.

The defaults for these style bits are based on their settings when the character is compiled with the Microsoft Agent Character Editor.

See also IAgentBalloonEx::GetStyle


IAgentCommandWindow

IAgentCommandWindow defines an interface that allows applications to set and query the properties of the Voice Commands Window. The Voice Commands Window is a shared resource primarily designed to enable users to view voice-enabled commands. If speech recognition is disabled, the Voice Commands Window still displays, with the text "Speech input disabled" (in the language of the character). If no speech engine is installed that matches the character's language setting, the window displays, "Speech input not available." If the input-active client has not defined voice parameters for its commands and has disabled global voice commands, the window displays, "No voice commands." You can also query the properties of the Voice Commands Window regardless of whether speech input is disabled or a compatible speech engine is installed.

Methods in Vtable Order

IAgentCommandWindow Methods Description
SetVisible Sets the value of the Visible property of the Voice Commands Window.
GetVisible Returns the value of the Visible property of the Voice Commands Window.
GetPosition Returns the position of the Voice Commands Window.
GetSize Returns the size of the Voice Commands Window.

HRESULT GetPosition(
   long * plLeft,  // address of variable for left edge of Voice Commands Window
   long * plTop    // address of variable for top edge of Voice Commands Window
);

Retrieves the Voice Commands Window's position.

plLeft

Address of a variable that receives the screen coordinate of the left edge of the Voice Commands Window in pixels, relative to the screen origin (upper left).

plTop

Address of a variable that receives the screen coordinate of the top edge of the Voice Commands Window in pixels, relative to the screen origin (upper left).

See also IAgentCommandWindow::GetSize


IAgentCommandWindow::GetSize

HRESULT GetSize(
   long * plWidth,  // address of variable for Voice Commands Window width
   long * plHeight  // address of variable for Voice Commands Window height
);

Retrieves the current size of the Voice Commands Window.

plWidth

Address of a variable that receives the width of the Voice Commands Window in pixels, relative to the screen origin (upper left).

plHeight

Address of a variable that receives the height of the Voice Commands Window in pixels, relative to the screen origin (upper left).

See also IAgentCommandWindow::GetPosition


IAgentCommandWindow::GetVisible

HRESULT GetVisible(
   long * pbVisible  // address of variable for Visible setting for 
);                   // Voice Commands Window

Determines whether the Voice Commands Window is visible or hidden.

pbVisible

Address of a variable that receives True if the Voice Commands Window is visible, or False if hidden.

See also IAgentCommandWindow::SetVisible


IAgentCommandWindow::SetVisible

HRESULT SetVisible(
   long bVisible  // Voice Commands Window Visible setting 
);

Set the Visible property for the Voice Commands Window.

bVisible

Visible property setting. A value of True displays the Voice Commands Window; False hides it.

The user can override this property.

See also IAgentCommandWindow::GetVisible


IAgentSpeechInputProperties

IAgentSpeechInputProperties provides access to the speech input properties maintained by the server. Most of the properties are read-only for client applications, but the user can change them in the Microsoft Agent property sheet. The Microsoft Agent server returns values only if a compatible speech engine has been installed and is enabled. Querying these properties attempts to start the speech engine.

Methods in Vtable Order
IAgentSpeechInputProperties Methods Description
GetEnabled Returns whether the speech recognition engine is enabled.
GetHotKey Returns the current key assignment of the Listening key.
GetListeningTip Returns whether the Listening Tip is enabled.

GetInstalled, GetLCID, GetEngine, and SetEngine methods (supported in earlier versions of Microsoft Agent) are still supported for backward compatibility. However, the methods are not stubbed and do not return useful values. Use GetSRModeID and SetSRModeID to query and set the speech recognition engine to be used with the character. Keep in mind that the engine must match the character's current language setting.


IAgentSpeechInputProperties::GetEnabled

HRESULT GetEnabled(
   long * pbEnabled  // address of variable for speech recognition engine 
);                   // Enabled setting

Retrieves a value indicating whether the installed speech recognition engine is enabled.

pbEnabled

Address of a variable that receives True if the speech engine is currently enabled and False if disabled.


IAgentSpeechInputProperties::GetHotKey

HRESULT GetHotKey(
BSTR * pbszHotCharKey  // address of variable for listening key 
);                        

Retrieves the current keyboard assignment for the speech input Listening key.

pbszHotCharKey

Address of a BSTR that receives the current hotkey setting used to open the audio channel for speech input.

If GetEnabled returns False, querying this setting raises an error.

See also IAgentSpeechInputProperties::GetEnabled


IAgentSpeechInputProperties::GetListeningTip

HRESULT GetListeningTip(
long * pbListeningTip  // address of variable for listening tip flag
);                       

Retrieves a value indicating whether the Listening Tip is enabled for display.

pbListeningTip

Address of a variable that receives True if the Listening Tip is enabled for display, or False if the Listening Tip is disabled.

If GetEnabled returns False, querying any other speech input properties returns an error.


IAgentAudioOutputProperties

IAgentAudioOutputProperties provides access to audio output properties maintained by the Microsoft Agent server. These functions are also available from IAgentAudioOutputPropertiesEx. The properties are read-only, but the user can change them in the Microsoft Agent property sheet.

Methods in Vtable Order
IAgentAudioOutputProperties Methods Description
GetEnabled Returns whether audio output is enabled.
GetUsingSoundEffects Returns whether sound-effect output is enabled.

IAgentAudioOutputProperties::GetEnabled

HRESULT GetEnabled(
long * pbEnabled  // address of variable for audio output Enabled setting 
);                      

Retrieves a value indicating whether character speech output is enabled.

pbEnabled

Address of a variable that receives True if the speech output is currently enabled and False if disabled.

Because this setting affects spoken output (TTS and sound file) for all characters, only the user can change this property in the Microsoft Agent property sheet.


IAgentAudioOutputProperties

HRESULT GetUsingSoundEffects(
long * pbUsingSoundEffects  // address of variable sound effects output 
);                          // setting 

Retrieves a value indicating whether sound effects output is enabled.

pbUsingSoundEffects

Address of a variable that receives True if the sound effects output is currently enabled and False if disabled.

Sound effects for a character's animation are assigned in the Microsoft Agent Character Editor. Because this setting affects sound effects output for all characters, only the user can change this property in the Microsoft Agent property sheet.


IAgentAudioOutputPropertiesEx

IAgentAudioOutputPropertiesEx is derived from the IAgentAudioOutputProperties interface. It includes all the IAgentAudioOutputProperties methods and provides access to additional functions.

Methods in Vtable Order

IAgentAudioOutputPropertiesEx Methods Description
GetStatus Returns the status of the audio output channel.

IAgentAudioOutputPropertiesEx::GetStatus

HRESULT GetStatus(
   long * plStatus,  // address of audio channel status
);

Retrieves the status of the audio channel.

plStatus

Status of the audio output channel, which may be one of the following values:

const unsigned short
AUDIO_STATUS_AVAILABLE = 0;
The audio output channel is available (not busy).
const unsigned short
AUDIO_STATUS_NOAUDIO = 1;
There is no support for audio output; for example, because there is no sound card.
const unsigned short
AUDIO_STATUS_CANTOPENAUDIO = 2;
The audio output channel can't be opened (is busy); for example, because another application is playing audio.
const unsigned short
AUDIO_STATUS_USERSPEAKING = 3;
The audio output channel is busy because the server is processing user speech input
const unsigned short
AUDIO_STATUS_CHARACTERSPEAKING = 4;
The audio output channel is busy because a character is currently speaking.
const unsigned short
AUDIO_STATUS_SROVERRIDEABLE = 5;
The audio output channel is not busy, but it is waiting for user speech input.
const unsigned short
AUDIO_STATUS_ERROR = 6;
There was some other (unknown) problem in attempting to access the audio output channel.

This setting enables your client application to query the state of the audio output channel. You can use this to determine whether to have your character speak or to try to turn on Listening mode (using IAgentCharacterEx::Listen).


IAgentPropertySheet

IAgentPropertySheet defines an interface that allows applications to set and query p/P>

Methods in Vtable Order
IAgentPropertySheet Methods Description
GetVisible Returns whether the Microsoft Agent property sheet is visible.
SetVisible Sets the Visible property of the Microsoft Agent property sheet.
GetPosition Returns the position of the Microsoft Agent property sheet.
GetSize Returns the size of the Microsoft Agent property sheet.
GetPage Returns the current page for the Microsoft Agent property sheet.
SetPage Sets the current page for the Microsoft Agent property sheet.

IAgentPropertySheet::GetPage

HRESULT GetPage(
BSTR * pbszPage  // address of variable for current property page
);

Retrieves the current page of the Microsoft Agent property sheet.

pbszPage

Address of a variable that receives the current page of the property sheet (last viewed page if the window is not open). The parameter can be one of the following:

"Speech" The Speech Input page.
"Output" The Output page.
"Copyright" The Copyright page.

See also IAgentPropertySheet::SetPage


IAgentPropertySheet::GetPosition

HRESULT GetPosition(
   long * plLeft,  // address of variable for left edge of property sheet
   long * plTop    // address of variable for top edge of property sheet
);

Retrieves the Microsoft Agent's property sheet window position.

plLeft

Address of a variable that receives the screen coordinate of the left edge of the property sheet in pixels, relative to the screen origin (upper left).

plTop

Address of a variable that receives the screen coordinate of the top edge of the property sheet in pixels, relative to the screen origin (upper left).

See also IAgentPropertySheet::GetSize


IAgentPropertySheet::GetSize

HRESULT GetSize(
   long * plWidth,  // address of variable for property sheet width
   long * plHeight  // address of variable for property sheet height
);

Retrieves the size of the Microsoft Agent property sheet window.

plWidth

Address of a variable that receives the width of the property sheet in pixels, relative to the screen origin (upper left).

plHeight

Address of a variable that receives the height of the property sheet in pixels, relative to the screen origin (upper left).

See also IAgentPropertySheet::GetPosition


IAgentPropertySheet::GetVisible

HRESULT GetVisible(
   long * pbVisible  // address of variable for property sheet
);                   // Visible setting

Determines whether the Microsoft Agent property sheet is visible or hidden.

pbVisible

Address of a variable that receives True if the property sheet is visible and False if hidden.

See also IAgentPropertySheet::SetVisible


IAgentPropertySheet::SetPage

HRESULT SetPage(
   BSTR bszPage  // current property page
);

Sets the current page of the Microsoft Agent property sheet.

bszPage

A BSTR that sets the current page of the property. The parameter can be one of the following.

"Speech" The Speech Input page.
"Output" The Output page.
"Copyright" The Copyright page.

See also IAgentPropertySheet::GetPage


IAgentPropertySheet::SetVisible

HRESULT SetVisible(
   long bVisible  // property sheet Visible setting 
);

Sets the Visible property for the Microsoft Agent property sheet.

bVisible

Visible property setting. A value of True displays the property sheet; a value of False hides it.

See also IAgentPropertySheet::GetVisible


Events

IAgentNotifySink notifies clients when certain state changes occur. These functions are also available from IAgentNotifySinkEx.

Methods in Vtable Order
IAgentNotifySink Description
Command Occurs when the server processes a client-defined command.
ActivateInputState Occurs when a character becomes or ceases to be input-active.
VisibleState Occurs when the character's Visible state changes.
Click Occurs when a character is clicked.
DblClick Occurs when a character is double-clicked.
DragStart Occurs when a user starts dragging a character.
DragComplete Occurs when a user stops dragging a character.
RequestStart Occurs when the server begins processing a Request object.
RequestComplete Occurs when the server completes processing a Request object.
Bookmark Occurs when the server processes a bookmark.
Idle Occurs when the server starts or ends idle processing.
Move Occurs when a character has been moved.
Size Occurs when a character has been resized.
BalloonVisibleState Occurs when the visibility state of a character's word balloon changes.

The IAgentNotifySink::Restart and IAgentNotifySink::Shutdown events, supported in earlier versions of Microsoft Agent, are now obsolete. While supported for backward compatibility, the server no longer sends these events.


IAgentNotifySink::ActivateInputState

HRESULT ActivateInputState(
   long dwCharID,   // character ID
   long bActivated  // input activation flag
);                          

Notifies a client application that a character's input active state changed.

dwCharID

Identifier of the character whose input activation state changed.

bActivated

Input active flag. This Boolean value is True if the character referred to by dwCharID became input active; and False if the character lost its input active state.


IAgentNotifySink:: BalloonVisibleState

HRESULT BalloonVisibleState(
   long dwCharID,  // character ID
   long bVisible   // visibility flag
);                          

Notifies a client application when the visibility state of the character's word balloon changes.

dwCharID

Identifier of the character whose word balloon's visibility state has changed.

bVisible

Visibility flag. This Boolean value is True when character's word balloon becomes visible; and False when it becomes hidden.

This event is sent to all clients of the character.


IAgentNotifySink::Bookmark

HRESULT Bookmark(
   long dwBookMarkID  // bookmark ID
);                          

Notifies a client application when its bookmark completes.

dwBookMarkID

Identifier of the bookmark that resulted in triggering the event.

When you include bookmark tags in a Speak method, you can track when they occur with this event.

See also IAgentCharacter::Speak, Speech Output Tags


IAgentNotifySink::Click

HRESULT Click(
   long dwCharID,  // character ID
   short fwKeys,   // mouse button and modifier key state
   long x,         // x coordinate of mouse pointer
   long y          // y coordinate of mouse pointer
);                          

Notifies a client application when the user clicks a character or character's taskbar icon.

dwCharID

Identifier of the clicked character.

fwKeys

A parameter that indicates the mouse button and modifier key state. The parameter can return any combination of the following:

0x0001 Left Button
0x0010 Middle Button
0x0002 Right Button
0x0004 Shift Key Down
0x0008 Control Key Down
0x0020 Alt Key Down
0x1000 Event occurred on the character's taskbar icon

x

The x-coordinate of the mouse pointer in pixels, relative to the screen origin (upper left).

y

The y-coordinate of the mouse pointer in pixels, relative to the screen origin (upper left).

This event is sent to the input-active client of the character. If none of the character's clients are input-active, the server notifies the character's active client. If the character is visible, the server also makes that client input-active and sends the IAgentNotifySink::ActivateInputState. If the character hidden, the character is also automatically shown.


IAgentNotifySink::Command

HRESULT Command(
   long dwCommandID,         // Command ID of the best match
   IUnknown * punkUserInput  // address of IAgentUserInput object 
);                          

Notifies a client application that a Command was selected by the user.

dwCommandID

Identifier of the best match command alternative.

punkUserInput

Address of the IUnknown interface for the IAgentUserInput object.

Use QueryInterface to retrieve the IAgentUserInput interface.

The server notifies the input-active client when the user chooses a command by voice or by selecting a command from the character's pop-up menu. The event occurs even when the user selects one of the server's commands. In this case the server returns a null command ID, the confidence score, and the voice text returned by the speech engine for that entry.

See also IAgentUserInput


IAgentNotifySink::DblClick

HRESULT DblClick(
   long dwCharID,  // character ID
   short fwKeys,   // mouse button and modifier key state
   long x,         // x coordinate of mouse pointer
   long y          // y coordinate of mouse pointer
);                          

Notifies a client application when the user double-clicks a character.

dwCharID

Identifier of the double-clicked character.

fwKeys

A parameter that indicates the mouse button and modifier key state. The parameter can return any combination of the following:

0x0001 Left Button
0x0010 Middle Button
0x0002 Right Button
0x0004 Shift Key Down
0x0008 Control Key Down
0x0020 Alt Key Down
0x1000 Event occurred on the character's taskbar icon

x

The x-coordinate of the mouse pointer in pixels, relative to the screen origin (upper left).

y

The y-coordinate of the mouse pointer in pixels, relative to the screen origin (upper left).

This event is sent to the input-active client of the character. If none of the character's clients are input-active, the server notifies the character's active client. If the character is visible, the server also makes that client input-active and sends the IAgentNotifySink::ActivateInputState. If the character is hidden, the character is also automatically shown.


IAgentNotifySink::DragComplete

HRESULT DragComplete(
   long dwCharID,  // character ID
   short fwKeys,   // mouse button and modifier key state
   long x,         // x-coordinate of mouse pointer
   long y          // y-coordinate of mouse pointer
);                          

Notifies a client application when the user stops dragging a character.

dwCharID

Identifier of the dragged character.

fwKeys

A parameter that indicates the mouse button and modifier key state. The parameter can return any combination of the following:

0x0001 Left Button
0x0010 Middle Button
0x0002 Right Button
0x0004 Shift Key Down
0x0008 Control Key Down
0x0020 Alt Key Down

x

The x-coordinate of the mouse pointer in pixels, relative to the screen origin (upper left).

y

The y-coordinate of the mouse pointer in pixels, relative to the screen origin (upper left).


IAgentNotifySink::DragStart

HRESULT DragStart(
   long dwCharID,  // character ID
   short fwKeys,   // mouse button and modifier key state
   long x,         // x-coordinate of mouse pointer
   long y          // y-coordinate of mouse pointer
);                          

Notifies a client application when the user starts dragging a character.

dwCharID

Identifier of the dragged character.

fwKeys

A parameter that indicates the mouse button and modifier key state. The parameter can return any combination of the following:

0x0001 Left Button
0x0010 Middle Button
0x0002 Right Button
0x0004 Shift Key Down
0x0008 Control Key Down
0x0020 Alt Key Down

x

The x-coordinate of the mouse pointer in pixels, relative to the screen origin (upper left).

y

The y-coordinate of the mouse pointer in pixels, relative to the screen origin (upper left).


IAgentNotifySink::Idle

HRESULT Idle(
   long dwCharID,  // character ID
   long bStart     // start flag
);                          

Notifies a client application when a character's Idling state has changed.

dwCharID

Identifier of the request that started.

bStart

Start flag. This Boolean value is True when the character begins idling and False when it stops idling.

This event enables you to track when the Microsoft Agent server starts or stops idle processing for a character.

See also IAgentCharacter::GetIdleOn, IAgentCharacter::SetIdleOn


IAgentNotifySink::Move

HRESULT Move(
   long dwCharID,  // character ID
   long x,         // x-coordinate of new location
   long y,         // y-coordinate of new location
   long dwCause    // cause of move state
);                          

Notifies a client application when the character has been moved.

dwCharID

Identifier of the character that has been moved.

x

The x-coordinate of the new position in pixels, relative to the screen origin (upper left). The location of a character is based on the upper left corner of its animation frame.

y

The y-coordinate of the new position in pixels, relative to the screen origin (upper left). The location of a character is based on the upper left corner of its animation frame.

dwCause

The cause of the character move. The parameter may be one of the following:

const unsigned short NeverMoved = 0; Character has not been moved.
const unsigned short UserMoved = 1; User dragged the character.
const unsigned short ProgramMoved = 2; Your application moved the character.
const unsigned short OtherProgramMoved = 3; Another application moved the character.
const unsigned short SystemMoved = 4 The server moved the character to keep it onscreen after a screen resolution change.

This event is sent to all clients of the character.

See also IAgentCharacter::GetMoveCause, IAgentCharacter::MoveTo


IAgentNotifySink::RequestComplete

HRESULT RequestComplete(
   long dwRequestID,  // request ID
   long hrStatus      // status code
);                          

Notifies a client application when a request completes.

dwRequestID

Identifier of the request that started.

hrStatus

Status code. This parameter returns the status code for the request.

This event enables you to track when a queued method completes using its request ID.

See also IAgentNotifySink::RequestStart, IAgent::Load, IAgentCharacter::GestureAt, IAgentCharacter::Hide, IAgentCharacter::Interrupt, IAgentCharacter::MoveTo, IAgentCharacter::Prepare, IAgentCharacter::Play, IAgentCharacter::Show, IAgentCharacter::Speak, IAgentCharacter::Wait


IAgentNotifySink::RequestStart

HRESULT RequestStart(
   long dwRequestID  // request ID
);                          

Notifies a client application when a request begins.

dwRequestID

Identifier of the request that started.

This event enables you to track when a queued request begins using its request ID.

See also IAgentNotifySink::RequestComplete, IAgent::Load, IAgentCharacter::GestureAt, IAgentCharacter::Hide, IAgentCharacter::Interrupt, IAgentCharacter::MoveTo, IAgentCharacter::Prepare, IAgentCharacter::Play, IAgentCharacter::Show, IAgentCharacter::Speak, IAgentCharacter::Wait


IAgentNotifySink::Size

HRESULT Size(
   long dwCharID,  // character ID
   long lWidth,    // new width
   long lHeight,   // new height
);                          

Notifies a client application when the character has been resized.

dwCharID

Identifier of the character that has been resized.

lWidth

The width of the character's animation frame in pixels.

lHeight

The height of the character's animation frame in pixels.

This event is sent to all clients of the character.

See also IAgentCharacter::GetSize, IAgentCharacter::SetSize


IAgentNotifySink::VisibleState

HRESULT VisibleState(
   long dwCharID,  // character ID
   long bVisible,  // visibility flag
   long dwCause,   // cause of visible state
);                          

Notifies a client application when the visibility state of the character changes.

dwCharID

Identifier of the character whose visibility state is changed.

bVisible

Visibility flag. This Boolean value is True when character becomes visible and False when the character becomes hidden.

dwCause

Cause of last change to the character's visibility state. The parameter may be one of the following:

const unsigned short NeverShown = 0; Character has not been shown.
const unsigned short UserHid = 1; User hid the character with the character's taskbar icon pop-up menu or with speech input..
const unsigned short UserShowed = 2; User showed the character.
const unsigned short ProgramHid = 3; Your application hid the character.
const unsigned short ProgramShowed = 4; Your application showed the character.
const unsigned short OtherProgramHid = 5; Another application hid the character.
const unsigned short OtherProgramShowed = 6; Another application showed the character.
const unsigned short UserHidViaCharacterMenu = 7 User hid the character with the character's pop-up menu.
const unsigned short UserHidViaTaskbarIcon = UserHid User hid the character with the character's taskbar icon pop-up menu or using speech input.

See also IAgentCharacter::GetVisible, IAgentCharacter::GetVisibilityCause


IAgentNotifySinkEx

IAgentNotifySinkEx is derived from the IAgentNotifySink interface. It includes all the IAgentNotifySink methods and provides access to additional functions.

Methods in Vtable Order

IAgentNotifySinkEx Methods Description
HelpComplete Occurs when the user selects a menu or the character in Help mode.
ListeningState Occurs when the character's listening state changes.
Suspend Occurs when the server suspends operation.
DefaultCharacterChange Occurs when the user changes the default character.
AgentPropertyChange Occurs when the user changes an Agent property setting.
ActiveClientChange Occurs when the active client of a character changes.

IAgentNotifySinkEx::ActiveClientChange

HRESULT ActiveClientChange(
...long dwCharID,  // character ID
   long lStatus    // active state flag
);

Notifies a client application if its active client is no longer the active client of a character.

dwCharID

Identifier of the character for which active client status changed.

lStatus

Active state change of the client, which can be a combination of any of the following values:

const unsigned short ACTIVATE_NOTACTIVE = 0; Your client is not the active client of the character.
const unsigned short ACTIVATE_ACTIVE = 1; Your client is the active client of the character.
const unsigned short ACTIVATE_INPUTACTIVE = 2; Your client is input-active (active client of the topmost character).

When multiple client applications share the same character, the active client of the character receives mouse input (for example, Microsoft Agent control click or drag events). Similarly, when multiple characters are displayed, the active client of the topmost character (also known as the input-active client) receives IAgentNotifySink::Command events.

When the active client of a character changes, this event passes back the ID of that character and True if your application has become the active client of the character or False if it is no longer the active client of the character.

A client application may receive this event when the user selects another client application's entry in character's pop-up menu or by voice command, the client application changes its active status, or another client application quits its connection to Microsoft Agent. Agent sends this event only to the client applications that are directly affected -- those that either become the active client or stop being the active client.

You can use the Activate method to set whether your application is the active client of the character or to make your application the input-active client (which also makes the character topmost).

See also IAgentCharacter::Activate, IAgentCharacterEx::GetActive, IAgentNotifySink::ActivateInputState


IAgentNotifySinkEx::AgentPropertyChange

HRESULT AgentPropertyChange(
);

Notifies a client application when the user changes a Microsoft Agent property setting.

When the user changes a Microsoft Agent property setting in the Microsoft Agent property sheet, the server sends this event to all clients unless the server is currently suspended.

See also IAgentNotifySinkEx::DefaultCharacterChange


IAgentNotifySinkEx::DefaultCharacterChange

HRESULT DefaultCharacterChange(
   BSTR bszGUID  // character identifier
);

Notifies a client application when the default character changes.

bszGUID

The unique identifier for the character.

When the user changes the character assigned as the user's default character, the server sends this event to clients that have loaded the default character. The event returns the character's unique identifier (GUID) formatted with braces and dashes, which is defined when the character is built with the Microsoft Agent Character Editor.

When the new character appears, it assumes the same size as any already loaded instance of the character or the previous default character (in that order).

See also IAgent::Load


IAgentNotifySinkEx::HelpComplete

HRESULT HelpComplete(
   long dwCharID,     // character ID
   long dwCommandID,  // command ID
   long dwCause       // cause 
);

Notifies a client application when the user selects a command or character to complete Help mode.

dwCharID

Identifier of the character for which Help mode completed.

dwCommandID

Identifier of the command the user selected.

dwCause

The cause for the event, which may be the following values:

const unsigned short
CSHELPCAUSE_COMMAND = 1;
The user selected a command supplied by your application.
const unsigned short CSHELPCAUSE_OTHERPROGRAM = 2; The user selected the Commands object of another client.
const unsigned short CSHELPCAUSE_OPENCOMMANDSWINDOW = 3; The user selected the Open Voice Commands command.
const unsigned short CSHELPCAUSE_CLOSECOMMANDSWINDOW = 4; The user selected the Close Voice Commands command.
const unsigned short CSHELPCAUSE_SHOWCHARACTER = 5; The user selected the Show CharacterName command.
const unsigned short CSHELPCAUSE_HIDECHARACTER = 6; The user selected the Hide CharacterName command.
const unsigned short
CSHELPCAUSE_CHARACTER = 7;
The user selected (clicked) the character.

Typically Help mode completes when the user clicks or drags the character or selects a command from the character's pop-up menu. Clicking on another character or elsewhere on the screen does not cancel Help mode. The client that set Help mode for the character can cancel Help mode by setting IAgentCharacter::HelpModeOn to False. (This does not trigger the IAgentNotifySinkEx::HelpComplete event.)

When the user selects a command from the character's pop-up menu in Help mode, the server removes the menu, calls Help with the command's specified HelpContextID, and sends this event. The context-sensitive (also known as What's This?) Help window is displayed at the pointer location. If the user selects the command by voice input, the Help window is displayed over the character. If the character is off-screen, the window is displayed on-screen nearest to the character's current position.

If the server returns dwCommandID as an empty string (""), it indicates that the user selected a server-supplied command.

This event is sent only to the client application that places the character into Help mode.

See also IAgentCharacterEx::SetHelpModeOn, IAgentCharacterEx::SetHelpFileName, IAgentCharacterEx::SetHelpContextID, IAgentCommandsEx::SetHelpContextID,


IAgentNotifySinkEx::ListeningState

HRESULT ListeningState(
   long dwCharacterID,  // character ID
   long bListening,     // listening mode state
   long dwCause         // cause  
);

Notifies a client application when the Listening mode changes.

dwCharacterID

The character for which the listening state changed.

bListening

The Listening mode state. True indicates that Listening mode has started; False, that Listening mode has ended.

dwCause

The cause for the event, which may be one of the following values.

const unsigned long LSCOMPLETE_CAUSE_PROGRAMDISABLED = 1; Listening mode was turned off by program code.
const unsigned long LSCOMPLETE_CAUSE_PROGRAMTIMEDOUT = 2; Listening mode (turned on by program code) timed out.
const unsigned long LSCOMPLETE_CAUSE_USERTIMEDOUT = 3; Listening mode (turned on by the Listening key) timed out.
const unsigned long LSCOMPLETE_CAUSE_USERRELEASEDKEY = 4; Listening mode was turned off because the user released the Listening key.
const unsigned long LSCOMPLETE_CAUSE_USERUTTERANCEENDED = 5; Listening mode was turned off because the user finished speaking.
const unsigned long LSCOMPLETE_CAUSE_CLIENTDEACTIVATED = 6; Listening mode was turned off because the input active client was deactivated.
const unsigned long
LSCOMPLETE_CAUSE_DEFAULTCHARCHANGE = 7
Listening mode was turned off because the default character was changed.
const unsigned long
LSCOMPLETE_CAUSE_USERDISABLED = 8
Listening mode was turned off because the user disabled speech input.

This event is sent to all clients when the Listening mode begins after the user presses the Listening key or when its time-out ends, or when the input-active client calls the IAgentCharacterEx::Listen method with True or False.

The event returns values to the clients that currently have this character loaded. All other clients receive a null character (empty string).

See also IAgentCharacterEx::Listen



Back to topBack to top

Did you find this material useful? Gripes? Compliments? Suggestions for other articles? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.