#62435 - 2002-01-28 05:30 AM
Using MS Agent in KIX
|
mmantei
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
|
|
|
|
#62437 - 2002-01-28 07:04 AM
Re: Using MS Agent in KIX
|
rustic
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
|
|
|
|
#62439 - 2002-01-28 08:17 AM
Re: Using MS Agent in KIX
|
rustic
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
|
|
|
|
#62442 - 2002-01-28 04:46 PM
Re: Using MS Agent in KIX
|
Shawn
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
|
|
|
|
#62447 - 2002-01-29 05:55 AM
Re: Using MS Agent in KIX
|
mmantei
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
|
|
|
|
#62449 - 2002-01-29 08:13 AM
Re: Using MS Agent in KIX
|
mmantei
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
|
|
|
|
#62452 - 2002-01-31 12:01 AM
Re: Using MS Agent in KIX
|
mmantei
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
|
|
|
|
#62454 - 2002-02-01 12:03 AM
Re: Using MS Agent in KIX
|
mmantei
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
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 202 anonymous users online.
|
|
|