Hello,

I'm trying to control ms-agent from vbs. That works fine when the
script is embedded in a web page but, when I try to do that in a
stnadalone script nothing happens !

Nom = "peedy"
Set Agent = CreateObject("Agent.Control.2")
Agent.Connected = true
Agent.Characters.Load Nom, Nom+".acs"
Set Merlin = Agent.Characters(Nom)
Merlin.Show
Merlin.Play "DoMagic2"
Do While Merlin.Visible:wscript.sleep 10:loop
Agent.connected = false
Set Merlin = Nothing
Set Agent = Nothing

sub Agent_Click(ByVal CharacterID, ByVal Button, ByVal Shift, ByVal X,
ByVal Y)
Merlin.Hide
end sub

The click event is never triggered, I tried with _Command, _DblClick
ans so on.

Does anyone have an idea ?

Thanks in advance.
--
Gilles COSTA, Géomètre-expert
Selarl Gross-Allain
17, grande rue, BP 23 91311 Montlhéry cedex, France

Re: Controling MS-Agent events from a standalone vb script by Don

Don
Mon Feb 09 14:58:56 CST 2004

Here is a working script that just run without problem, You should be able
to modify it to suit your needs.

Option Explicit

' ------------------
' Constants...
' ------------------

Const Complete = 0, Pending = 2

' ------------------
' Setup...
' ------------------

Dim objAgent, objChar, objRequest, txtSpeak
Dim strCharacter, Shell, strFirstName, sTime

' ------------------
' Initialize...
' ------------------

strFirstName = "Don"
'strCharacter = "Merlin"
strCharacter = "Genie"
'strCharacter = "Robby"
'strCharacter = "Peedy"

' ------------------
' Start...
' ------------------
sTime = Time()

Set Shell = CreateObject("WScript.Shell")

If HaveAgent() Then

' ------------------
' Microsoft Agent control was found...
' ------------------

objAgent.Characters.Load strCharacter, strCharacter & ".acs"
Set objChar = objAgent.Characters(strCharacter)
With objChar
.Top = 50
.Left = 50
.LanguageID = &h409
.Show
End With

' objChar.Play "Greet"
' objChar.Speak "Hello, " & strFirstName & "\Vol=100"
' objChar.Play "GetAttention"
' objChar.Play "GetAttentionReturn"
' objChar.Speak "Hello! " & strFirstName
' objChar.Play "Idle2_2"
' objChar.Play "Acknowledge"
objChar.Play "Announce"
objChar.Speak sTime
' objChar.Speak "The time is now " & time()
objChar.Play "Idle3_1"
' objChar.Speak "Yup, it's now time to go home."
' objChar.MoveTo 800, 600
' objChar.Play "Idle3_1"
' objChar.Play "Wave"
' objChar.Speak "Goodbye! " & strFirstName

' ------------------
' Synchronize our Animation characters with VBScripts Quit...
' ------------------

Set objRequest = objChar.Hide
Do Until objRequest.Status = Complete
Wscript.Sleep 100
Loop

Set objChar = Nothing
objAgent.Characters.Unload strCharacter

WScript.Quit
Else

' ------------------
' Microsoft Agent control was NOT found...
' ------------------

Shell.Popup "MS Agent NOT Found !" & vbCrLf, _
10, _
"Error Message", _
vbInformation + vbOKOnly + vbSystemModal
Wscript.Quit
End If

Function HaveAgent()

' ------------------
' Function to check MS Agent availability...
' ------------------

HaveAgent = False
On Error Resume Next
Set objAgent = CreateObject("Agent.Control.1")
objAgent.Connected = True
HaveAgent = IsObject(objAgent)
End Function




'*****************************************

"Gilles Costa" <gross.allain@wanadoo.fr> wrote in message
news:znbs36z1.fsf@wanadoo.fr...
> Hello,
>
> I'm trying to control ms-agent from vbs. That works fine when the
> script is embedded in a web page but, when I try to do that in a
> stnadalone script nothing happens !
>
> Nom = "peedy"
> Set Agent = CreateObject("Agent.Control.2")
> Agent.Connected = true
> Agent.Characters.Load Nom, Nom+".acs"
> Set Merlin = Agent.Characters(Nom)
> Merlin.Show
> Merlin.Play "DoMagic2"
> Do While Merlin.Visible:wscript.sleep 10:loop
> Agent.connected = false
> Set Merlin = Nothing
> Set Agent = Nothing
>
> sub Agent_Click(ByVal CharacterID, ByVal Button, ByVal Shift, ByVal X,
> ByVal Y)
> Merlin.Hide
> end sub
>
> The click event is never triggered, I tried with _Command, _DblClick
> ans so on.
>
> Does anyone have an idea ?
>
> Thanks in advance.
> --
> Gilles COSTA, Géomètre-expert
> Selarl Gross-Allain
> 17, grande rue, BP 23 91311 Montlhéry cedex, France



Re: Controling MS-Agent events from a standalone vb script by Gilles

Gilles
Tue Feb 10 02:21:53 CST 2004

"Don Grover" <spamfree@assoft.com.au> writes:

> Here is a working script that just run without problem, You should be able
> to modify it to suit your needs.
>

8<...

Thanks, I managed to have the agent play some animations or speak
text. What I didn't managed to do is to make the agent react to events
such as click, command, move etc.

Any idea ?
--
Gilles COSTA, Géomètre-expert
Selarl Gross-Allain
17, grande rue, BP 23 91311 Montlhéry cedex
T : 01.64.49.00.52 - F : 01.64.49.06.64
http://perso.wanadoo.fr/gross.allain

Re: Found Controling MS-Agent events from a standalone vb script by Gilles

Gilles
Tue Feb 10 05:00:17 CST 2004

Gilles Costa <gross.allain@wanadoo.fr> writes:

> "Don Grover" <spamfree@assoft.com.au> writes:
>
>> Here is a working script that just run without problem, You should be able
>> to modify it to suit your needs.
>>
>
> 8<...
>
> Thanks, I managed to have the agent play some animations or speak
> text. What I didn't managed to do is to make the agent react to events
> such as click, command, move etc.
>

Calling the object AgentControl and creating it with the following
syntax works :
Set AgentControl = WScript.CreateObject("Agent.Control.2","AgentControl_")

Any event is now correctly handled.
--
Gilles COSTA, Géomètre-expert
Selarl Gross-Allain
17, grande rue, BP 23 91311 Montlhéry cedex
T : 01.64.49.00.52 - F : 01.64.49.06.64
http://perso.wanadoo.fr/gross.allain