Click here to Skip to main content
12,950,832 members (59,111 online)
Click here to Skip to main content
Add your own
alternative version


40 bookmarked
Posted 14 Sep 2003

MSAgent Class

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


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.

CommandParameterValues [defaults]


MoveToxPos yPos Speed{number}{number}{[0]|> 0}
MoveToPosition Speed{center|lefttop|leftbottom|righttop|rightbottom}{[0]|>0}
MoveDeltaX DeltaY Speed{number}{number}{[0]|>0}
SizexSize ySize{number}{number}
NameName for Character 
Volumechannel switch{master|wave}{[on]|off|reset|volume in percent}
ExecuteExecutable [Parameter] 
Shell["Verb"] File 

bool  Script (char *IniFile,char *Key);

Execute a script. Scripts are Sections from Windows .ini files :

An additional command available from scripts is :

CommandParameterValues [defaults]


a key in this script file 

Sample Script File :

MoveTo Center 0
Show Slow
Play Greet

Goto First
Speak Hallo !
Hide Slow

Goto First
Speak Goodby !
Hide Slow

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;

Other classes used from cAgent


Covers the commands from cAgent.


Controls the queue that will serialize the commands. Raise mouse and bookmark events.


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
Developer downloads


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


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


About the Author

Stefan Voitel
Germany Germany
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralMS Agent, why Scroll lock Pin
Muammar©10-May-07 21:37
memberMuammar©10-May-07 21:37 
GeneralBorland C++ BuilderX compatibility? (how to) Pin
Millyard16-Mar-05 11:46
memberMillyard16-Mar-05 11:46 
Questioncan u show me how to use that Pin
nigrl23-Oct-03 15:42
membernigrl23-Oct-03 15:42 
GeneralCrash, error on NT 4 ( not only? ) Pin
sitondrejn25-Sep-03 1:41
membersitondrejn25-Sep-03 1:41 
GeneralRe: Crash, error on NT 4 ( not only? ) Pin
Stefan Voitel25-Sep-03 11:51
memberStefan Voitel25-Sep-03 11:51 
GeneralVC++ 6 project/conpile files Pin
Bagpuss16-Sep-03 6:13
memberBagpuss16-Sep-03 6:13 
GeneralRe: VC++ 6 project/conpile files Pin
Stefan Voitel18-Sep-03 9:14
memberStefan Voitel18-Sep-03 9:14 
GeneralRe: VC++ 6 project/conpile files Pin
alexwinx7-Oct-03 20:25
memberalexwinx7-Oct-03 20:25 
GeneralRe: VC++ 6 project/conpile files Pin
Arbesto Pelta28-Jan-04 6:27
memberArbesto Pelta28-Jan-04 6:27 
GeneralSome commands are missing... Pin
Anonymous15-Sep-03 11:38
sussAnonymous15-Sep-03 11:38 
GeneralRe: Some commands are missing... Pin
Stefan Voitel18-Sep-03 9:02
memberStefan Voitel18-Sep-03 9:02 
GeneralWaaahhh!!!! Pin
jhwurmbach15-Sep-03 3:49
memberjhwurmbach15-Sep-03 3:49 
GeneralRe: Waaahhh!!!! Pin
Greg Ellis15-Sep-03 5:12
memberGreg Ellis15-Sep-03 5:12 
GeneralRe: Waaahhh!!!! Pin
Stefan Voitel18-Sep-03 9:04
memberStefan Voitel18-Sep-03 9:04 
GeneralRe: Waaahhh!!!! Pin
Stefan Voitel18-Sep-03 9:20
memberStefan Voitel18-Sep-03 9:20 

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

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

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170525.1 | Last Updated 24 Sep 2003
Article Copyright 2003 by Stefan Voitel
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid