chroy:

The following is a relatively responsive user interface built using Internet Explorer 4+ common dialogs.

To run this, you should have Windows NT or Windows 2000 and have the following software installed on your workstation...

1) Internet Explorer 4+
2) MSAgent 2.5 Core Components
3) MSAgent "Merlin" character
4) MSAgent Text-to-speech engine

MSAgent downloads are here ...


http://msdn.microsoft.com/workshop/imedia/agent/agentdl.asp


This script presents the user with a "television" style remote control that will solicit input and control the speech and actions of our favorite MS Agent - "Merlin" (Sorry - I couldn't think of anything better to control" !


code:


break on


$false = 0
$true = -1
$agentname = "Merlin"
$agentpath = "%windir%\msagent\chars\$agentname.acs"
$agentcontrol = "agent.control.2"


$agent = olecreateobject ( "$agentcontrol" )
if $agent = 0
exit
endif


$ie = olecreateobject ( "internetexplorer.application" )
if $ie = 0
exit
endif


$rs = setconsole ( "minimize" )


$rs = oleputproperty ( $agent, "connected", "s", "1" )
$chars = val ( "&" + olegetproperty ( $agent, "characters" ))
$rs = olecallfunc ( $chars, "load", "ss", "$agentname", "$agentpath" )
$actor = val ( "&" + olecallfunc ( $chars, "character", "s", "$agentname" ))


$rs = oleputproperty ( $ie, "addressbar", "s", "$false" )
$rs = oleputproperty ( $ie, "menubar", "s", "$false" )
$rs = oleputproperty ( $ie, "toolbar", "s", "$false" )
$rs = oleputproperty ( $ie, "statusbar", "s", "$false" )
$rs = oleputproperty ( $ie, "resizeable", "s", "$false" )
$rs = oleputproperty ( $ie, "top", "s", "30" )
$rs = oleputproperty ( $ie, "left", "s", "150" )
$rs = oleputproperty ( $ie, "height", "s", "375" )
$rs = oleputproperty ( $ie, "width", "s", "175" )
$rs = olecallfunc ( $ie, "navigate", "s", "about:blank" )


while olegetproperty ( $ie, "busy" ) <> "0" loop


$doc = val ( "&" + olegetproperty ( $ie, "document" ))


$rs = olecallfunc ( $doc, "open" )


$html = '<html>' +
'<head><title>Agent Remote</title><style>'+
'<!---body{ background-color: silver; color: black;'+
'font-family: tahoma, arial; font-size: 10pt; margin: 3px "'+
'input.tbox { border: lpx black solid;}'+
'td { font: 10pt tahoma; }'+
'---></style></head>'+
'<body scroll=no onresize="window.resizeto(240,120);">'+
; Form
'<form name=remote>'+
'<input id=status name=stat type=hidden value=0>' +
'Message:<br>'+
'<input id=message name=message class=tbox '+
' value="Hello"><br><br>' +
'<input id=x type=button value=" Speak " '+
' onclick="remote.status.value=1">' +
'<input id=x type=button value=" Think " '+
' onclick="remote.status.value=2"><br><br>' +
'Distance:<br>'+
'<input id=distance name=distance class=tbox '+
' value="100"><br>' +
'Speed:<br>'+
'<input id=speed name=speed class=tbox '+
' value="50"><br><br>' +
'<input id=x type=button value=" Up " '+
' onclick="remote.status.value=3">' +
'<input id=x type=button value=" Down "'+
' onclick="remote.status.value=4"><br>' +
'<input id=x type=button value=" Left " '+
' onclick="remote.status.value=5">' +
'<input id=x type=button value=" Right " '+
' onclick="remote.status.value=6"><br><br>' +
'<input id=x type=button value=" Hide " '+
' onclick="remote.status.value=7">' +
'<input id=x type=button value=" Show " '+
' onclick="remote.status.value=8"><br><br>' +
'<input id=exit type=button value=" Exit " '+
' onclick="remote.status.value=99">' +
'</form>'+
'</body>'+
'</html>'


$rs = olecallfunc ( $doc, "write", "s", "$html" )


; Show Agent Remote Control ...


$rs = oleputproperty ( $ie, "visible", "s", "$true" )


; Show Agent ...


$rs = olecallfunc ( $actor, "show" )


while olegetproperty ( $ie, "busy" ) <> "0" loop


$oStatus = val ( "&" + olecallfunc ( $doc, "GetElementById", "s", "status" ) )
$oMessage = val ( "&" + olecallfunc ( $doc, "GetElementById", "s", "message" ) )
$oDistance = val ( "&" + olecallfunc ( $doc, "GetElementById", "s", "distance" ) )
$oSpeed = val ( "&" + olecallfunc ( $doc, "GetElementById", "s", "speed" ) )


; Enter command loop ...


while @error = 0


sleep 1


$mMessage = olegetproperty ( $oMessage, "value" )
$mLeft = val(olegetproperty ( $actor, "left" ))
$mTop = val(olegetproperty ( $actor, "top" ))
$mStatus = olegetproperty ( $oStatus, "value" )
$mSpeed = val(olegetproperty ( $oSpeed, "value" ))
$mDistance = val(olegetproperty ( $oDistance, "value" ))


select


case $mStatus = "1" ; SPEAK


$rs = olecallfunc ( $actor, "speak", "s", "$mMessage" )


case $mStatus = "2" ; THINK


$rs = olecallfunc ( $actor, "think", "s", "$mMessage" )


case $mStatus = "3" ; UP


$mTop = $mTop - $mDistance
$rs = olecallfunc ( $actor, "moveto", "sss", "$mLeft", "$mTop", "$mSpeed" )


case $mStatus = "4" ; DOWN


$mTop = $mTop + $mDistance
$rs = olecallfunc ( $actor, "moveto", "sss", "$mLeft", "$mTop", "$mSpeed" )


case $mStatus = "5" ; LEFT


$mLeft = $mLeft - $mDistance
$rs = olecallfunc ( $actor, "moveto", "sss", "$mLeft", "$mTop", "$mSpeed" )


case $mStatus = "6" ; RIGHT


$mLeft = $mLeft + $mDistance
$rs = olecallfunc ( $actor, "moveto", "sss", "$mLeft", "$mTop", "$mSpeed" )


case $mStatus = "7" ; HIDE


$rs = olecallfunc ( $actor, "hide" )


case $mStatus = "8" ; SHOW


$rs = olecallfunc ( $actor, "show" )


case $mStatus = "99" ; EXIT


goto finish


endselect


$rs = oleputproperty ( $oStatus, "value", "s", "0" )


loop


:finish


$rs = olereleaseobject ( $actor )
$rs = olereleaseobject ( $chars )
$rs = olereleaseobject ( $agent )


$rs = olecallfunc ( $ie, "quit" )
$rs = olereleaseobject ( $ie )


exit



Shawn.


[This message has been edited by Shawn (edited 05 September 2000).]