Solved

Need Microsoft Agent samples/code

Posted on 1998-11-02
8
226 Views
Last Modified: 2008-03-10
Hi All,
I am creating an online HELP program for a Win NT 4 system, and I have been toying with the MS Agent control.  I could sure use some sample code (besides HELLO WORLD on the MS site) and perhaps a good web site, for code examples.  Namely, I'm having problems coding the click event on the character.  I want to "do something" after the pop up menu comes on screen, and I don't know how to code that.  Any help/samples/url's would be great!
Thanks!



0
Comment
Question by:KIRK50
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 14

Accepted Solution

by:
waty earned 20 total points
ID: 1443000
I have implemented succesfully it in one application.

Here is a module I wrote to use the Agent :

' #VBIDEUtils#************************************************************
' * Programmer Name  : Waty Thierry
' * Web Site         : www.geocities.com/ResearchTriangle/6311/
' * E-Mail           : waty.thierry@usa.net
' * Date             : 16/10/98
' * Time             : 17:52
' * Module Name      : Agent_Module
' * Module Filename  : Agent.bas
' **********************************************************************
' * Comments         : Functions to handle an Agent
' *
' *
' **********************************************************************

Option Explicit

' *** Agent
Global Character           As IAgentCtlCharacterEx

Private sIddle(8)          As String

Public Sub Agent_Init(MyAgent As Agent, sChar As String, bShow As Boolean)
   ' *** Initialise the agent
   
   On Error GoTo ERROR_Agent_Init
   
   Randomize
   
   Set Character = Nothing
   MyAgent.Characters.Load "CharacterID", sChar
   Set Character = MyAgent.Characters("CharacterID")
   
   ' *** Set the character's language
   Character.LanguageID = &H409

   ' *** Show the character
   If bShow Then Character.Show
   
   sIddle(1) = "Idle1_1"
   sIddle(2) = "Idle1_2"
   sIddle(3) = "Idle1_3"
   sIddle(4) = "Idle1_4"
   sIddle(5) = "Idle2_1"
   sIddle(6) = "Idle2_2"
   sIddle(7) = "Idle3_1"
   sIddle(8) = "Idle3_2"
   
   Exit Sub
   
ERROR_Agent_Init:
   Exit Sub

End Sub

Public Sub Agent_NewsArrive(sNews As String)
   ' *** News arrives
   
   On Error GoTo ERROR_Agent_NewsArrive
   
   Character.Play "Announce"
   Character.Speak sNews
   
   Exit Sub
   
ERROR_Agent_NewsArrive:
   Exit Sub
   
End Sub

Public Sub Agent_Search()
   ' *** Start a search
   
   On Error GoTo ERROR_Search
   
   Character.Stop
   Character.Play "Search"
   
   Exit Sub
   
ERROR_Search:
   Exit Sub
   
End Sub

Public Sub Agent_Searching(sText As String)
   ' *** Start a search
   
   On Error GoTo ERROR_Searching
   
   Character.Play "Searching"
   Character.Speak sText
   
   Exit Sub
   
ERROR_Searching:
   Exit Sub
   
End Sub

Public Sub Agent_SearchFound(sText As String)
   ' *** Start a search
   
   On Error GoTo ERROR_Agent_SearchFound
   
   Character.Play "Pleased"
   Character.Speak sText & "  found"
   
   Exit Sub
   
ERROR_Agent_SearchFound:
   Exit Sub
   
End Sub

Public Sub Agent_SearchNotFound(sText As String)
   ' *** Start a search
   
   On Error GoTo ERROR_Agent_SearchNotFound
   
   Character.Play "Sad"
   Character.Speak sText & " not found"
   
   Exit Sub
   
ERROR_Agent_SearchNotFound:
   Exit Sub
   
End Sub

Public Sub Agent_Read()
   ' *** Start a Read
   
   On Error GoTo ERROR_Read
   
   Character.Play "Read"
   
   Exit Sub
   
ERROR_Read:
   Exit Sub
   
End Sub

Public Sub Agent_Reading(sText As String)
   ' *** Start a Read
   
   On Error GoTo ERROR_Reading
   
   Character.Play "Reading"
   Character.Speak sText
   
   Exit Sub
   
ERROR_Reading:
   Exit Sub
   
End Sub

Public Sub Agent_Iddle()
   ' *** Start an iddle
   
   On Error GoTo ERROR_Iddle
   
   Character.Play sIddle(Int((8 * Rnd) + 1))
   
   Exit Sub
   
ERROR_Iddle:
   Exit Sub
   
End Sub

Public Sub Agent_Query()
   ' *** Start a query
   
   On Error GoTo ERROR_Query
   
   Character.Play "DoMagic1"
   Character.Play "DoMagic2"
 
   Exit Sub
   
ERROR_Query:
   Exit Sub
   
End Sub

Public Sub Agent_Stop()
   ' *** Stop
   
   On Error GoTo ERROR_Stop
   
   Character.Stop
 
   Exit Sub
   
ERROR_Stop:
   Exit Sub

End Sub

Public Sub Agent_Filter(sText As String)
   ' *** Start a filter
   
   On Error GoTo ERROR_Filter
   
   Character.Play "Process"
   
   Exit Sub
   
ERROR_Filter:
   Exit Sub
   
End Sub

Public Sub Agent_Speech(sText As String)
   ' *** Say something
   
   On Error GoTo ERROR_Filter
   
   Character.Play "Suggest"
   Character.Speak sText
   
   Exit Sub
   
ERROR_Filter:
   Exit Sub
   
End Sub

0
 

Author Comment

by:KIRK50
ID: 1443001
Waty,

Thanks, as always, for the help ... very good stuff.  Now, just one LITTLE question I want to ask.  What code does it take to manipulate the pop up menu, and then activate one of the pop up menu events?  I can get items into the pop up menu, but I don't understand how to make the click event on one of the items work!

Please help!!!  Thanks!

 
0
 

Author Comment

by:KIRK50
ID: 1443002
Waty,

P.S.  How do I "call" the public functions in the regular program?  And do I have to specify somewhere else in my program the character ID and name, or perhaps prompt the user to choose between a couple of choices?  Please lend me a hand with those two questions, and the one about activating the popup menu!

Thanks!

-- Kirk
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:waty
ID: 1443003
To start the agent :
' *** Character agent
Call Agent_Init(MyAgent, GetWindowsDirectory() & "msagent\chars\Merlin.acs", gbAssistant)
   If (gbSoundAssistant = False) Then Character.SoundEffectsOn = False

To call :
Call Agent_SearchNotFound("Search not found")



NB : Wich popup menu in the previous comment?
0
 

Author Comment

by:KIRK50
ID: 1443004
Waty,

The menu I mentioned is a little popup menu you can program to show a few possible choices, like HIDE, SHOW, Show The Voice Commands Window, etc.  It looks like this in code:

(assuming you have already DIM'd genie, set datapath, etc...)

Dim cmd1 As IAgentCtlCommandEx

' WhatUP appears in popupmenu when activated ... like this...
Set cmd1 = Genie.Commands.Add("WhatUP", "WhatUP")  

' then to activate the popup menu on screen, do this
Genie.ShowPopupMenu 150, 150      


So the question is, after the popup menu appears, you should be able to click on WhatUP and go somewhere, however, right now
I don't know how to program it!  Where does it go, and how does
it work??  Thanks again!

-- Kirk


0
 

Author Comment

by:KIRK50
ID: 1443005
Hi Waty,

Just wanted to know if you had any code, or could teach me, how to manipulate/respond to a user clicking on the popup menu?
Or, just as good, how do you get the genie to respond to events?  Do you put questions (Yes,No, Ok, Cancel) in his balloon or something?  If so, how?  Okay, sorry to bother you!
Thanks!

0
 
LVL 14

Expert Comment

by:waty
ID: 1443006
No, I have not done this, I have only used this to "display" with the sound some messages, and also read some titles of news.
0
 

Author Comment

by:KIRK50
ID: 1443007
Ok, thanks!  Appreciate the help!

-- Kirk
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month5 days, 19 hours left to enroll

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question