Click here to Skip to main content
Click here to Skip to main content

MSAgent Class

, 23 Sep 2003
Rate this:
Please Sign up or sign in to vote.
A Class to use MS-Agents instead of MessageBoxes

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

MS-Agent Hompage http://www.microsoft.com/msagent/
Developer downloads

http://www.microsoft.com/msagent/downloads/

History

  • 15 Sep 2003 Initial release
  • 24 Sep 2003 Updated sourcecode

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Stefan Voitel

Germany Germany
No Biography provided

Comments and Discussions

 
GeneralMS Agent, why Scroll lock PinmemberMuammar©10-May-07 21:37 
GeneralBorland C++ BuilderX compatibility? (how to) PinmemberMillyard16-Mar-05 11:46 
Questioncan u show me how to use that Pinmembernigrl23-Oct-03 15:42 
GeneralCrash, error on NT 4 ( not only? ) Pinmembersitondrejn25-Sep-03 1:41 
GeneralRe: Crash, error on NT 4 ( not only? ) PinmemberStefan Voitel25-Sep-03 11:51 
GeneralVC++ 6 project/conpile files PinmemberBagpuss16-Sep-03 6:13 
GeneralRe: VC++ 6 project/conpile files PinmemberStefan Voitel18-Sep-03 9:14 
GeneralRe: VC++ 6 project/conpile files Pinmemberalexwinx7-Oct-03 20:25 
GeneralRe: VC++ 6 project/conpile files PinmemberArbesto Pelta28-Jan-04 6:27 
GeneralSome commands are missing... PinsussAnonymous15-Sep-03 11:38 
GeneralRe: Some commands are missing... PinmemberStefan Voitel18-Sep-03 9:02 
GeneralWaaahhh!!!! Pinmemberjhwurmbach15-Sep-03 3:49 
GeneralRe: Waaahhh!!!! PinmemberGreg Ellis15-Sep-03 5:12 
GeneralRe: Waaahhh!!!! PinmemberStefan Voitel18-Sep-03 9:04 
GeneralRe: Waaahhh!!!! PinmemberStefan Voitel18-Sep-03 9:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140827.1 | Last Updated 24 Sep 2003
Article Copyright 2003 by Stefan Voitel
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid