大家好,又见面了,我是你们的朋友全栈君。Microsoft Agent是微软公司发布的一项代理软件开发技术,我们知道,在Office帮助系统中有一种叫作Office助手的代理软件,但其只允许Office各个组件调用,Agent动画人物可由任何Windows程序调用;
Agent支持文字气球和输入提示条,在输出语音的同时把文字输出至一个卡通式文字气球中。如果电脑系统中安装有Agent语音识别引擎,当用户可以通过声卡、麦克风与用户交谈。下午无事,就尝试着写了一段简单的代码调用MsAgent:
GenieID = “Genie”
GenieACS = “genie.acs”
ScriptComplete=0
Set AgentControl = WScript.CreateObject(“Agent.Control.2″,”agent_”)
AgentControl.Connected = True’连接控件
AgentControl.Characters.Load GenieID,GenieACS
Set Genie = AgentControl.Characters(GenieID)
Genie.LanguageID = &H409
Genie.MoveTo 900, 600
Genie.Show
Genie.MoveTo 900, 0
timespeak=”good ” & GetTimeOfDay()
Genie.Speak(timespeak)
Genie.Play “Acknowledge” ‘承认
Genie.Speak(“眨眼”)
Genie.Play “Blink” ‘眨眼
Genie.Speak(“i love you”)
Genie.Speak(“回复动作”)
genie.Play(“RestPose”) ‘回復动作
Genie.Speak(“向上”)
genie.Play(“GestureUp”) ‘向上
Genie.Speak(“向下”)
genie.Play(“GestureDown”) ‘向下
Genie.Speak(“伸出左手”)
genie.Play(“GestureLeft”) ‘ 伸出左手
Genie.Speak(“伸出右手”)
genie.Play(“GestureRight”) ‘ 伸出右手
Genie.Speak(“叹气”)
genie.Play(“Sad”) ‘嘆气
Genie.Speak(“惊奇”)
genie.Play(“Surprised”) ‘惊奇
Genie.Speak(“握掌”)
genie.Play(“Pleased”) ‘握掌
Genie.Speak(“喇叭”)
genie.Play(“Announce”) ‘喇叭
Genie.Speak(“眯眼”)
genie.Play(“Blink”) ‘瞇眼
Genie.Speak(“无奈”)
genie.Play(“Decline”) ‘无奈
Genie.Speak(“抓头”)
genie.Play(“Confused”) ‘抓头
Genie.Speak(“鼓掌”)
genie.Play(“Congratulate”) ‘奖盃
Genie.Speak(“回手”)
genie.Play(“Wave”) ‘挥手
Genie.Speak(“惊讶”)
genie.Play(“Alert”) ‘惊讶
Genie.Speak(“魔术棒1”)
genie.Play(“DoMagic1”) ‘魔术棒-1
Genie.Speak(“魔术棒2”)
genie.Play(“DoMagic2”) ‘魔术棒-2
Genie.Speak(“摊手”)
genie.Play(“Explain”) ‘摊手
Genie.Speak(“敲门”)
genie.Play(“GetAttention”) ‘敲门
genie.Play(“GetAttentionContinued”) ‘敲门-敲
genie.Play(“GetAttentionReturn”) ‘敲门-放下
genie.Play(“Greet”) ‘弯腰
genie.Play(“Idle2_1”) ‘观察魔术棒
genie.Play(“Idle2_2”) ‘两手在腹前交叉
genie.Play(“Idle3_1”) ‘打呵欠
Genie.Speak(“向上看”)
genie.Play(“LookUp”) ‘上看
genie.Play(“LookDown”) ‘下看
genie.Play(“LookLeft”) ‘左看
genie.Play(“LookRight”) ‘右看
genie.Play(“MoveUp”) ‘上移
genie.Play(“MoveDown”) ‘下移
genie.Play(“MoveLeft”) ‘左移
genie.Play(“MoveRight”) ‘右移
genie.Play(“Process”) ‘魔法调配
genie.Play(“Read”) ‘阅读
Do ‘此处存疑,高手请看最后
WScript.Sleep 1000
Loop Until ScriptComplete
Function GetTimeOfDay()
Dim TimeOfDay
Dim h
h = Hour(Now())
If h < 12 Then
TimeOfDay = “Morning”
ElseIf h < 17 Then
TimeOfDay = “Afternoon”
Else
TimeOfDay = “Evening”
End If
GetTimeOfDay = TimeOfDay
End Function
Sub agent_dblclick(ByVal CharacterID, ByVal Button, ByVal Shift, ByVal X, ByVal
Y)
Genie.StopAll
MsgBox “白白,再见了!”
WScript.Quit
End Sub
本来代码写的就没有什么难度,可是写完之后,每次可爱的小人总是一闪而过,屏幕上什么也看不见,在网络上查找也找不出原因,我实验了好多次,终于发觉了加红的那段代码必不可少,程序异步执行,没有最后的代码,程序没有执行完就退出了
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/149969.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...