Solved

Need Microsoft Agent samples/code

Posted on 1998-11-02
8
222 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
  • 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now