Page 1 of 2 12>
Topic Options
#62435 - 2002-01-28 05:30 AM Using MS Agent in KIX
mmantei Offline
Fresh Scripter

Registered: 2002-01-28
Posts: 25
I'm working on some KIX scripting and would like to incorporate the Microsoft agent. Somewhere (I can't remember exactly) I found some sample code for using an MS Agent in KIX. A shortened verion of a sample is this:

$AgentName="Genie"
$AgentPath = "%WinDir%\MSAgent\Chars\Genie.ACS"
$Agent = CreateObject ("Agent.Control.2")

If @Error = 0
$Agent.Connected = "1"
$agent.raiserequesterrors="True"
$=$Agent.Characters.Load($AgentName,$AgentPath)
$Char = $Agent.Characters.Character($AgentName)
$=$Char.Show()
$=$Char.MoveTo(400, 300)
$Req=$Char.Speak("Hello. Thank you for logging on to the network")
EndIf

The issue is that the script ends before the character has done anything. I've found that in VBScript you can deal with this by using code like this:

Set Figure1 = Activate("Genie")

Figure1.Show
figure1.MoveTo(300,300)

set Request1=figure1.speak("Welcome to the new network")

Do Until request1.Status = Complete
Wscript.Sleep 100
Loop

Function Activate(Figure)
Path = "%WINDIR%\MSAGENT\CHARS\" & Figure & ".ACS"
Set AgentControl = WScript.CreateObject("Agent.Control.1", "event_")
If IsObject(AgentControl) Then AgentControl.Connected = True
Set wshshell = CreateObject("WScript.Shell")
Path = wshshell.ExpandEnvironmentStrings(Path)
AgentControl.Characters.Load Figure, Path
Set Activate = AgentControl.Characters(Figure)
End Function

The key seems to be these lines:
set Request1=figure1.speak("Welcome to the new network")

Do Until request1.Status = Complete
Wscript.Sleep 100
Loop

How do I emulate this in KIX? I'm pretty comfortable with KIX, and know almost nothing about VBScript but I've never tried working with this type of thing before.

What I've read is that the first statement sets a "REQUEST". The "DO" loop checks the status of the request and will continue to loop until the request finishes. How do I set the request in KIX and how do I check the status?

Thanks in advance.

_________________________
Mike

Top
#62436 - 2002-01-28 06:18 AM Re: Using MS Agent in KIX
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
AAAAHHHHHHHHHHHGGGGGGGGGG!!!!!

No one has ever beaten an Agent, Neo. If you see one, Run.

_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#62437 - 2002-01-28 07:04 AM Re: Using MS Agent in KIX
rustic Offline
Fresh Scripter

Registered: 2002-01-11
Posts: 6
Loc: Lansdale, PA
It is funny, I was just working on my first Agent KiXtart script today. I was using the same code example from the kix samples scripts. I took a guess and added the following lines to give my agent time to speak (in addition to the $char.wait($req):

code:

$myreq=$char.wait($req)
Sleep 20
$=$char.hide()
$agent.connected = "0"

Better yet (for me) I stuck the script into a function so that I could place any text in to the comments.

code:
 
Function GetAgent($ReqMsg)
;;;(cut)...agent code
$req=$char.speak($ReqMsg)
EndFunction

Hope this helps!
Cheers

Top
#62438 - 2002-01-28 07:37 AM Re: Using MS Agent in KIX
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
You want agents? You got agents!

try here

cj

Top
#62439 - 2002-01-28 08:17 AM Re: Using MS Agent in KIX
rustic Offline
Fresh Scripter

Registered: 2002-01-11
Posts: 6
Loc: Lansdale, PA
Good stuff. I think that the COM references in KiXtart version 4.x are a bit different though (simplified).

You will have to convert all of the olexxx commands such as olecallfunc. For example, use:

code:
  
$=$char.play("read")
$=$char.play("readreturn")

insted of:

code:

$= olecallfunc ( $character, "play", "s", "read" )
$= olecallfunc ( $character, "play", "s", "readreturn" )

The MS documentation lists the various animations that can be used for each character.

All MSagent Documentation (doc format)

Cheers

Top
#62440 - 2002-01-28 02:34 PM Re: Using MS Agent in KIX
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
I concur Radimus

another msagent excursion was taken here (last reply)

Hmmm .. If one'd ask me I'd I'd say nice to play with, but no business needs;
I even deny to convert to 4.x COM allthough it'd be simple ...

just my € 0.02

J.

_________________________



Top
#62441 - 2002-01-28 03:29 PM Re: Using MS Agent in KIX
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
I couldn't let it go....

I can't get the wait thing or the request thing to work, but if you are interested... this is the kix4 version of merlin..

$agent_name = "Merlin"
$agent_path = "%windir%\msagent\chars\$agent_name.acs"
$Agent = CreateObject ("Agent.Control.2")
$Agent.Connected = "1"
$=$Agent.Characters.Load($AgentName,$AgentPath)
$Char = $Agent.Characters.Character($AgentName)

$=$Char.Show()
$=$char.play("announce" )
$=$char.play("greet" )
sleep 5
$=$Char.Speak("Greetings %username% !" )
$=$char.play("restpose" )
$speak=$Char.Speak("My name is $agent_name and this is your logon script ... " )
sleep 5
$=$char.play("read" )
$=$Char.read("Checking group membership ..." )
$=$char.play("readreturn" )
sleep 5
$=$Char.moveto("$xlimit", "0" )
$=$char.play("domagic1" )
$=$Char.Speak("I summon your network drives" )
$=$Char.Speak("Appear!!" )
$=$char.play("domagic2" )
sleep 5
$=$Char.moveto("$xlimit", "$ylimit" )
$=$Char.Speak("Examining your computer" )
$=$char.play("search" )
sleep 5
$=$Char.moveto("0", "$ylimit" )
$=$char.play("wave" )
$=$Char.Speak("All done... have a nice day !" )
$=$Char.hide()
sleep 5
$=$Char.moveto("$xlimit", "0" )
$=$Char.Show()
$=$Char.Speak("But I'll be watching you..." )
sleep 5
$=$Char.hide()
$=$Agent.Characters.unLoad($AgentName,$AgentPath)
sleep 5
exit

_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#62442 - 2002-01-28 04:46 PM Re: Using MS Agent in KIX
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
i can't resist either. if you've downloaded two agents (in this case, merlin and genie), one can synchronize them using the wait method ... oh yeah, it's said that if you ever see an microsoft agent - you run ! - you run like hell !


break on


$merlin_path = "%windir%\msagent\chars\merlin.acs"
$genie_path = "%windir%\msagent\chars\genie.acs"


$agent = createobject ("agent.control.2")
$agent.connected = "1"


$= $agent.characters.load("merlin","$merlin_path")
$= $agent.characters.load("genie","$genie_path")


$merlin = $agent.characters.character("merlin")
$genie = $agent.characters.character("genie")


$= $genie.moveto(200,200)
$= $merlin.moveto(400,200)


$= $merlin.show()
$= $genie.show()


$wait = $merlin.play("announce" )


$= $genie.wait($wait)
$= $genie.gestureat(400,200)
$wait= $genie.speak("Hey Merlin, stop making a freak'n racket, will yeah ?")


$= $merlin.wait($wait)
$wait= $merlin.speak("Genie, why don't you go get bottled !")


$= $genie.wait($wait)
$= $genie.moveto(450,200)
$wait= $genie.play("domagic2")


$= $merlin.wait($wait)
$= $merlin.speak("Oh crap")
$wait= $merlin.hide()


$= $genie.wait($wait)
$= $genie.speak("I hate those dang-darn Microsoft Agents anyways!!!")
$= $genie.hide()


gets$

exit

-Shawn

Top
#62443 - 2002-01-28 05:33 PM Re: Using MS Agent in KIX
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
EH, fun stuff...

BTW, the download for Genie is http://agent.microsoft.com/agent2/chars/genie.exe while Merlin is http://agent.microsoft.com/agent2/chars/merlin.exe (Win2k has Merlin already).

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#62444 - 2002-01-28 05:39 PM Re: Using MS Agent in KIX
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
ok les. we want to see you whip-up a little microsoft agent play !
Top
#62445 - 2002-01-28 07:09 PM Re: Using MS Agent in KIX
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Gee, I think you're mistaking me for a programmer!
I'm just a utilitarian. No bells, no whistles, no Murphy-proofing...
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#62446 - 2002-01-28 07:48 PM Re: Using MS Agent in KIX
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
I want to see a use for it...

Perhaps reading event logs looking for errors, or busting people that have Napster unstalled, or reading an email, or explaing somthing to a user, (as well all know that users cannot read)

_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#62447 - 2002-01-29 05:55 AM Re: Using MS Agent in KIX
mmantei Offline
Fresh Scripter

Registered: 2002-01-28
Posts: 25
Thanks everyone for the help. I actually do have a business use for the use of the agent. I work for an agency that deals with handicapped individuals. We have a numer of user that are blind, and the audio feedback would be good for them. We also use the Genie as part of the help system on our Intranet. I wanted to maintain consistency with that by utilizing it in the logon script.

I'm unable to use the "Wait" because I'm only dealing with a single agent. I also can't use the "Sleep" method because I have to deal with everything from Pentium 75 computers to 2.0 GHz P4s. I can't determine exactly how long the different functions will take and really need to be able to check the status. I'm also using Kix2001 and therefor would be writing it using COM, not OLE.

I've got everything else working and have, for some time. The problem is making KIX wait for all of the animations to finish, without using a sleep statement. In otherword, I'm trying to convert these 2 lines into KIX SCript:

set Request1=figure1.speak("Welcome to the new network")

Do Until request1.Status = Complete

Thanks again.

_________________________
Mike

Top
#62448 - 2002-01-29 06:28 AM Re: Using MS Agent in KIX
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Mike,
Looking at this from a non-programmer's perspective, why not get a second agent into the act? Just give it a very minor role to queue up the main character.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#62449 - 2002-01-29 08:13 AM Re: Using MS Agent in KIX
mmantei Offline
Fresh Scripter

Registered: 2002-01-28
Posts: 25
There are really 3 reasons to want only a single agent.

1. I only need one. We only use the Genie and we use that one because our Intranet is called GENIE. We don't use any other agents on our Intranet and I really have no use for another one.

2. I have to load and use the agents to a bunch of old PCs using dialup and other slow mediums. Having to load another agent would waste bandwidth and PC clock cycles that they really don't have to spare.

3. The agents are designed to do exactly what I want them to do. I just can't figure out the correct commands in KIX to do it. I shouldn't have to modify things just because I don't know the right way to do it. That's how Windows got so so screwed up in the first place.

Mike

_________________________
Mike

Top
#62450 - 2002-01-30 10:20 AM Re: Using MS Agent in KIX
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
Have a look in my KiXtart manual for an appendix on converting OLE calls to COM and back.

I like to use 2 agents as more than a page of text from one and I am asleep. I used to use DrSbaitso in the (good) old days and it took about 4 sentences to put em to sleep.

I wrote my own text to speech engine in KiX a long time ago, let me see if I can find it. Nope, it is too old for this board

If you want it, email me. I will zip up the .WAVs and send you the script. I made it by recording some phonemes (sounds) and the script sequences the sounds into words. It is quite creepy and sounds just like me if I talk slowly and enunciate.

cj

Top
#62451 - 2002-01-30 11:00 AM Re: Using MS Agent in KIX
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
ceej,

you meant this one Dr Sbaitso meets KiX ?

Yeah, those where the days ... *sigh

Mike,
have to revise my last statement about bussiness needs
Enabling the disabled is surely a good use !

... but aren't there better ways ?

regards

Jochen

_________________________



Top
#62452 - 2002-01-31 12:01 AM Re: Using MS Agent in KIX
mmantei Offline
Fresh Scripter

Registered: 2002-01-28
Posts: 25
There probably are better ways. Right now we have a text to speach program in use for several of these individuals. I'm just trying to find a simple way of getting small pieces of information across to those individuals that are not completely blind and don't have the software installed. It's also nice to be consistent with our intranet. This was actually my bosses idea and I'm starting to run outof time on the project. Once this last sticking point is taken care of, I'll be on the final stretch to finally finishing the project.

cj I would love to look at your manual, bu the link prvided does not work. I would also be interested in looking at your text to speach engine if you wouldn't mind sending it to me.

I would like to stay in kixscript to do this. Anone got any additional ideas?

_________________________
Mike

Top
#62453 - 2002-01-31 09:59 AM Re: Using MS Agent in KIX
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
J, that's it. I called it KiXtalk in the later versions (not posted from memory) and I was searching for "kixtalk" on the board.

M, My mum has RP and uses narrator (Dr Sbaitso built into win2k) for text to speech stuff.

Here is the link to my site, I had forgotten the .DOC on the web page link You can also use the little icons across the top of this post too.

Let me check that post Jpols mentioned for the .WAVs.

Wow, just reading that old post. I will dig up that wavs.exe file and put it back onto the internet. Should I reserrect that project?

cj

Top
#62454 - 2002-02-01 12:03 AM Re: Using MS Agent in KIX
mmantei Offline
Fresh Scripter

Registered: 2002-01-28
Posts: 25
Thanks for the link to the Manual. It may help with a few things. It doesn't answer my basic question however. In Kix 3.63, you have OLECALLFUNC and OLECALLPROC. In Kix 4, both of thesse commands are gone and have been replaced with handle.name(arguments...). That's well and good, but OLECALLFUNC and OLECALLPROC are two different things. If I were to do an OLECALLFUNC a value would be returned. That doesn't appear to be the case with the handle.name in Kix 4.

In VBScript, this line is the key to determining the status of the agent: "Do Until request1.Status = Complete" In Kix3.63, I could use the OLECALLFUNC and then check the value of "Request.Status" until it shows the action has completed. If I were to use OLECALLPROC, I would never receive a value in "Request.Status". That is the same as with "handle.property" It will never contain the return value from the showing the action has completed, so it's not truely an equivelent for OLECALLFUNC.

Any ideas?

_________________________
Mike

Top
Page 1 of 2 12>


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 202 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.052 seconds in which 0.015 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org