arract=array("Read","RestPose","Write","Process","Pleased","Idle3_1","Idle1_1","Show","GestureUp")
Set fso=CreateObject("scripting.filesystemobject")
Set ffile=fso.OpenTextFile("d:\shi.txt")
strAgentName = "Merlin"
strAgentPath = "C:\Windows\Msagent\Chars\" & strAgentName & ".acs"
Set objAgent = WScript.CreateObject("Agent.Control.2","agent_")
objAgent.Connected = TRUE
objAgent.Characters.Load strAgentName, strAgentPath
Set objCharacter = objAgent.Characters.Character(strAgentName)
objCharacter.LanguageID = &H409
objcharacter.MoveTo 900, 600
objcharacter.Show
objcharacter.MoveTo 900, 0
i=0
timespeak="good " & GetTimeOfDay()
objcharacter.Speak(timespeak)
objCharacter.Play("DoMagic1")
objcharacter.speak("背个唐诗给你们听!")
objCharacter.Play("DoMagic2")
Do While ffile.AtEndOfLine<>True
str=ffile.ReadLine
objcharacter.speak(str)
If i<=7 Then
i=i+1
Else
i=0
End If
speak=arract(i)
objCharacter.Play(speak)
Loop
Sub agent_click(ByVal CharacterID, ByVal Button, ByVal Shift, ByVal X, ByVal Y)
objcharacter.StopAll
If shift=1 Then
biao=0
Else
biao=1000
End if
Do While 1=1
Randomize
objcharacter.moveto Int(601*Rnd()),Int(901*Rnd()),biao
loop
End Sub
Sub agent_dblclick(ByVal CharacterID, ByVal Button, ByVal Shift, ByVal X, ByVal
Y)
objcharacter.StopAll
If shift=1 Then
objCharacter.Think "朋友们,再见了,我要回去睡觉了"
objcharacter.hide
WScript.Sleep 4000
WScript.Quit
Else
objcharacter.moveto 450,300
objcharacter.play("Pleased")
objcharacter.speak ("来让我老梅林给你们唱首歌吧,唱什么呢?")
objcharacter.speak "郑伊健-虫儿飞,看看我老梅林唱的怎么样!","d:\ge.wav"
objcharacter.moveto 900,0
End If
End Sub
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
Do
WScript.Sleep 1000
Loop Until ScriptComplete
这是我编写的vbs调用agent组件的代码,运行起来倒也是蛮有趣的,可是系统不是只支持鼠标双击,就是只响应鼠标单击,真是奇怪!不知道原因何在?
Set fso=CreateObject("scripting.filesystemobject")
Set ffile=fso.OpenTextFile("d:\shi.txt")
strAgentName = "Merlin"
strAgentPath = "C:\Windows\Msagent\Chars\" & strAgentName & ".acs"
Set objAgent = WScript.CreateObject("Agent.Control.2","agent_")
objAgent.Connected = TRUE
objAgent.Characters.Load strAgentName, strAgentPath
Set objCharacter = objAgent.Characters.Character(strAgentName)
objCharacter.LanguageID = &H409
objcharacter.MoveTo 900, 600
objcharacter.Show
objcharacter.MoveTo 900, 0
i=0
timespeak="good " & GetTimeOfDay()
objcharacter.Speak(timespeak)
objCharacter.Play("DoMagic1")
objcharacter.speak("背个唐诗给你们听!")
objCharacter.Play("DoMagic2")
Do While ffile.AtEndOfLine<>True
str=ffile.ReadLine
objcharacter.speak(str)
If i<=7 Then
i=i+1
Else
i=0
End If
speak=arract(i)
objCharacter.Play(speak)
Loop
Sub agent_click(ByVal CharacterID, ByVal Button, ByVal Shift, ByVal X, ByVal Y)
objcharacter.StopAll
If shift=1 Then
biao=0
Else
biao=1000
End if
Do While 1=1
Randomize
objcharacter.moveto Int(601*Rnd()),Int(901*Rnd()),biao
loop
End Sub
Sub agent_dblclick(ByVal CharacterID, ByVal Button, ByVal Shift, ByVal X, ByVal
Y)
objcharacter.StopAll
If shift=1 Then
objCharacter.Think "朋友们,再见了,我要回去睡觉了"
objcharacter.hide
WScript.Sleep 4000
WScript.Quit
Else
objcharacter.moveto 450,300
objcharacter.play("Pleased")
objcharacter.speak ("来让我老梅林给你们唱首歌吧,唱什么呢?")
objcharacter.speak "郑伊健-虫儿飞,看看我老梅林唱的怎么样!","d:\ge.wav"
objcharacter.moveto 900,0
End If
End Sub
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
Do
WScript.Sleep 1000
Loop Until ScriptComplete
这是我编写的vbs调用agent组件的代码,运行起来倒也是蛮有趣的,可是系统不是只支持鼠标双击,就是只响应鼠标单击,真是奇怪!不知道原因何在?