Introduction
Apologies in advance about my English and the brief descriptions, as my native language is German. I demonstrate a class to use MS-Agents instead of MessageBoxes to communicate with users. The following features are included:
- simple command interface.
- serialize all commands.
- support scripting.
- can interact with user through mouse events.
Using the code
class cAgent
cAgent (char *Character = NULL);
Create a Agent object. Character can be a *.acs file. NULL uses the default character from system.
bool Command (char *Command);
Push a Command to the Queue. Commands are case sensitive, Parameters and Values are not.
| Command |
Parameter |
Values [defaults] |
|
Speak
|
Text |
|
Think |
Text |
|
Play |
AnimationName |
|
MoveTo |
xPos yPos Speed |
{number}{number}{[0]|> 0} |
MoveTo |
Position Speed |
{center|lefttop|leftbottom|righttop|rightbottom}{[0]|>0} |
Move |
DeltaX DeltaY Speed |
{number}{number}{[0]|>0} |
Show |
Speed |
{[slow]|fast} |
Hide |
Speed |
{[slow]|fast} |
Size |
xSize ySize |
{number}{number} |
Resize |
|
|
Name |
Name for Character |
|
Language |
Language |
{german|american|english} |
Menu |
ShowAutoPopup |
{[off]|on} |
Sounds |
AnimationSounds |
{[on]|off} |
Volume |
channel switch |
{master|wave}{[on]|off|reset|volume in percent} |
Phrase |
FileName |
{[Phrases.txt]} |
Execute |
Executable [Parameter] |
|
Shell |
["Verb"] File |
|
Stop |
|
|
Quit |
|
|
bool Script (char *IniFile,char *Key);
Execute a script. Scripts are Sections from Windows .ini files :
An additional command available from scripts is :
| Command |
Parameter |
Values [defaults] |
|
Goto
|
a key in this script file |
|
Sample Script File :
[FIRST]
MoveTo Center 0
Show Slow
Play Greet
[HALLO]
Goto First
Speak Hallo !
Hide Slow
[GOODBY]
Goto First
Speak Goodby !
Hide Slow
Quit
void GetIdle (void);
Wait for Queue is empty.
void GetQuit (void);
Wait for Quit command and terminate. You can't use the cAgent Object after GetQuit().
virtual void Click (teMouseEventKeys keys,tMousePosition p);
virtual void DblClick (teMouseEventKeys keys,tMousePosition p);
Overwrite this functions to get response from Agent. A window created from here will be destroyed with the cAgent object.
Click() will be called before DblClick(), to avoid this use the next four functions.
virtual void LeftClick (teVirtualKeys key,bool SysTray);
virtual void RightClick (teVirtualKeys key,bool SysTray);
virtual void LeftDblClick (teVirtualKeys key,bool SysTray);
virtual void RightDblClick (teVirtualKeys key,bool SysTray);
Overwrite this functions to get response from Agent. This functions would be executed from a thread that terminate on return XXClick(). A window created from here will be destroyed after return !
The simplest way to use :
#include "cAgent.h"
extern "C" int PASCAL WinMain (HINSTANCE i,HINSTANCE prev,
LPSTR cmd,int show) {
cAgent *Agent = new cAgent();
Agent->Command ("MoveTo Center 0");
Agent->Command ("Show Slow");
Agent->Command ("Play Greet");
Agent->Command ("Speak Hallo world !");
Agent->Command ("Play RestPose");
Agent->Command ("Hide slow");
Agent->GetIdle ();
delete Agent;
return ERROR_SUCCESS;
}
Other classes used from cAgent
cAgentCommands
Covers the commands from cAgent.
cAgentSink
Controls the queue that will serialize the commands. Raise mouse and bookmark events.
Queue
A simple circular buffer to hold the commands.
cMMControl , cPhrase
cMMControl controls the system audio mixer. cPhrase picks a random phrase from a simple formatted text file.
Points of Interest
History
- 15 Sep 2003 Initial release
- 24 Sep 2003 Updated sourcecode