웹마스터 팁
page_full_width">
[re] 아래 행복한고니님의 할아버지 소스의 업글(?) 버젼입니다.
2002.12.02 01:15
제가 관리하는 홈페이지에 사용한 ms agent의 소스입니다...
그리고 자바가 아닌 VBScript 입니다. 그리고 <head>와 </head> 사이에 삽입하시면 링크에러가 날 것입니다.
<body> 부분에 넣어서 사용하세요..
<Script Language="VBScript">
' * Character Objects
Dim Genie
'+ ' * Variables
Dim UsedChars
Dim GenieID
Dim GenieACS
Dim GenieURL
Dim GenieStates
Dim GenieAnimations
Dim GenieReq
Dim GenieStatesReq
Dim GenieAnimationsReq
Dim GenieLoaded
Dim HideReq
Dim Req
' * Initialize
UsedChars = "Genie"
' * Genie
Genie = "Genie"
GenieACS = "Genie.acs"
GenieURL = "http://agent.microsoft.com/agent2/chars/genie/genie.acf"
GenieStates = "Showing, Hiding, Speaking, Moving, Gesturing"
GenieAnimations = "GestureRight, DoMagic1, DoMagic2, Idle1_1, Idle1_2, Idle1_3, Idle1_4, Idle1_5, Idle1_6, Idle2_1, Idle2_2, Idle2_3, Idle3_1, Process, GetAttentionReturn, Greet"
GenieLoaded = False
' * Prevent Auto-Download of Microsoft Agent if not already installed
If AgentInstalled() Then
Document.WriteLn "<Object ID=""AgentControl"" Width=0 Height=0"
Document.WriteLn " ClassID=""CLSID:D45FD31B-5C6E-11D1-9EC1-00C04FD7081F"""
Document.WriteLn " CodeBase=""#VERSION=2,0,0,0"">"
Document.WriteLn "</Object>"
Document.WriteLn "<Object ID=""L&HTruVoice"" Width=0 Height=0"
Document.WriteLn " ClassID=""CLSID:B8F2846E-CE36-11D0-AC83-00C04FD97575"""
Document.WriteLn " CodeBase=""#VERSION=6,0,0,0"">"
Document.WriteLn "</Object>"
End If
Function AgentInstalled()
' Purpose: Returns True if Agent 2.0 is installed, else False
On Error Resume Next
Dim AgentControl
Dim ScriptVersion
ScriptVersion = GetScriptVersion()
If ScriptVersion > 1 Then
Set AgentControl = CreateObject("Agent.Control.2")
AgentInstalled = IsObject(AgentControl)
Else
AgentInstalled = False
End If
End Function
Function GetScriptVersion()
' Purpose: Returns major version of the Scripting Engine
On Error Resume Next
Dim Ver
Ver = 0
Ver = ScriptEngineMajorVersion
If Ver = 0 Then Ver = 1
GetScriptVersion = Ver
End Function
Sub Window_OnLoad()
' Purpose: Runs automatically when page is loaded
On Error Resume Next
' * INSERT ANY NON-AGENT RELATED SCRIPTING HERE
If Not AgentInstalled() Then
Exit Sub
End If
AgentControl.Connected = True
GenieLoaded = LoadLocalAgent(GenieID, GenieACS)
If GenieLoaded Then
Call SetCharObj
End If
Call CheckLoadStatus
End Sub
Function LoadLocalAgent(ByVal CharID, ByVal CharACS)
' Purpose: Attempts to load the specified character
' Returns: True if successful, False if not
On Error Resume Next
AgentControl.Characters.Load CharID, CharACS
If Err = 0 Then
LoadLocalAgent = True
Exit Function
End If
LoadLocalAgent = False
End Function
Sub SetCharObj()
' Purpose: Sets the character reference and TTS Language ID
On Error Resume Next
Set Genie = AgentControl.Characters(GenieID)
Genie.LanguageID = &H412
End Sub
Sub CheckLoadStatus()
' Purpose: Determines if required characters have been loaded.
' If not, issue request to load next character
' else run the AgentIntro routine
If Not GenieLoaded Then
Window.Status = "Loading " & GenieID & " Character. Please Wait..."
Set GenieReq = AgentControl.Characters.Load(GenieID, GenieURL)
Exit Sub
End If
Window.Status = ""
Call AgentIntro
End Sub
Sub AgentControl_RequestComplete(ByVal RequestObject)
' Purpose: Take action on completion or failure of requests
On Error Resume Next
Select Case RequestObject
Case GenieReq
If RequestObject.Status = 0 Then
Call SetCharObj
If GenieStates <> "" Then
Window.Status = "Loading " & GenieID & " States. Please Wait..."
Set GenieStatesReq = AgentControl.Characters(GenieID).Get("State", GenieStates, True)
ElseIf GenieAnimations <> "" Then
Window.Status = "Loading " & GenieID & " Animations. Please Wait..."
Set GenieAnimationsReq = AgentControl.Characters(GenieID).Get("Animation", GenieAnimations, True)
Else
GenieLoaded = True
Call CheckLoadStatus
End If
Else
Call LoadError
End If
Exit Sub
Case GenieStatesReq
If RequestObject.Status = 0 Then
If GenieAnimations <> "" Then
Window.Status = "Loading " & GenieID & " Animations. Please Wait..."
Set GenieAnimationsReq = AgentControl.Characters(GenieID).Get("Animation", GenieAnimations, True)
Else
GenieLoaded = True
Call CheckLoadStatus
End If
Else
Call LoadError
End If
Exit Sub
Case GenieAnimationsReq
If RequestObject.Status = 0 Then
GenieLoaded = True
Call CheckLoadStatus
Else
Call LoadError
End If
Exit Sub
Case HideReq
AgentControl.Characters.Unload GenieID
End Select
End Sub
Sub LoadError()
Dim strMsg
Window.Status = ""
strMsg = "Error Loading Character: " & GenieID
strMsg = strMsg & Chr(13) & Chr(13) & "This Microsoft Agent Script requires the character(s):"
strMsg = strMsg & Chr(13) & UsedChars
MsgBox strMsg, 48
End Sub
Sub AgentControl_Click(ByVal CharacterID, ByVal Button, ByVal Shift, ByVal X, ByVal Y)
End Sub
Sub AgentControl_DblClick(ByVal CharacterID, ByVal Button, ByVal Shift, ByVal X, ByVal Y)
' Purpose: Stop and Hide all characters on double-click
On Error Resume Next
Genie.StopAll
If Not GenieID.HasOtherClients Then
If Genie.Visible Then
Set HideReq = Genie.Hide()
Else
AgentControl.Characters.Unload GenieID
End If
End If
End Sub
Function GetDay()
' Purpose: Returns current weekday name
Dim aDay
aDay = Array("","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
GetDay = aDay(WeekDay(Now()))
End Function
Function GetDate()
' Purpose: Returns current long date
Dim aMon
Dim sDay
aMon = Array("","January","February","March","April","May","June","July","August","September","October","November","December")
sDay = Day(Now())
If sDay = "11" Or sDay = "12" Or sDay = "13" Then
sDay = sDay & "th"
Else
Select Case Right(sDay, 1)
Case "1": sDay = sDay & "st"
Case "2": sDay = sDay & "nd"
Case "3": sDay = sDay & "rd"
Case Else
sDay = sDay & "th"
End Select
End If
GetDate = aMon(Month(Now())) & " " & sDay & ", " & Year(Now())
End Function
Function GetTime()
' Purpose: Returns current time
On Error Resume Next
Dim sTime
sTime = Left(Time(), 5)
If Right(sTime, 1) = ":" Then
sTime = Left(sTime, Len(sTime) - 1)
End If
sTime = sTime & Mid(Time(), InStr(Time(), " "))
GetTime = sTime
End Function
Function GetTimeOfDay()
' Purpose: Returns current time of day
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 InitAgentCommands()
' Purpose: Initialize the Commands menu
On Error Resume Next
Genie.Commands.RemoveAll
Genie.Commands.Caption = "My Menu Name"
Genie.Commands.Add "ACO", "Advanced Character Options", "Advanced Character Options"
End Sub
Sub AgentControl_Command(ByVal UserInput)
' Purpose: Determine Command that was selected either by menu or voice
' and run the applicable Command Script
On Error Resume Next
Dim BadConfidence
BadConfidence = 10
If (UserInput.Confidence <= -40) Then
' Bad Recognition
Exit Sub
ElseIf (UserInput.Alt1Name <> "") And Abs(Abs(UserInput.Alt1Confidence) - Abs(UserInput.Confidence)) < BadConfidence Then
' Bad Confidence - too close to another command
Exit Sub
ElseIf (UserInput.Alt2Name <> "") And Abs(Abs(UserInput.Alt2Confidence) - Abs(UserInput.Confidence)) < BadConfidence Then
' Bad Confidence - too close to another command
Exit Sub
Else ' High Confidence
' *** BEGIN MASH USER COMMANDS ***
Select Case UserInput.Name
Case "ACO"
AgentControl.PropertySheet.Visible = True
End Select
' *** END MASH USER COMMANDS ***
End If
End Sub
Sub AgentControl_Bookmark(ByVal BookmarkID)
On Error Resume Next
End Sub
Sub AgentIntro()
On Error Resume Next
Call InitAgentCommands
' *** BEGIN MASH USER SCRIPT ***
Genie.Show
Genie.MoveTo 870, 170
Genie.Play "MoveDown"
Genie.Play "Greet"
Genie.Speak "안녕하세요 Good " & GetTimeOfDay() & "! 지니입니다. 오늘은 " & GetDay() & ", " & GetDate() & "."
Genie.Speak "소리사랑 홈페이지를 방문해주셔서 감사합니다."
Genie.Play "Process"
Genie.MoveTo 30, 170
Genie.Speak "원하는 메뉴를 선택하세요!! "
Genie.Play "Gestureleft"
Genie.Play "Acknowledge"
Genie.Play "Confused"
Genie.Play "Process"
Genie.MoveTo 800, 280
Genie.Play "DoMagic1"
Genie.Play "DoMagic2"
Genie.Speak "참 먼저 로그인을 해주세요!! "
Genie.Play "GestureRight"
Genie.Speak "그리고 회원은 소리사랑가족만 받습니다!!"
Genie.Speak "그리고 비밀번호 혹은 아이디를 잊어 먹었을때는 비밀번호찾기를.. ^^ "
Genie.MoveTo 800, 480
Genie.Play "Congratulate"
Genie.Speak "박수 박수"
Genie.Speak "생일도 축하해줍시다. "
Genie.MoveTo 870, 170
Genie.Play "Idle1_1"
Genie.Play "Idle1_2"
Genie.Play "Idle1_3"
Genie.Play "Idle1_4"
Genie.Play "Idle1_5"
Genie.Play "Idle1_6"
Genie.Play "Idle2_1"
Genie.Play "Idle2_2"
Genie.Play "Idle2_3"
Genie.Play "Idle1_1"
Genie.Play "Idle1_2"
Genie.Play "Idle1_3"
Genie.Play "Idle1_4"
Genie.Play "Idle1_5"
Genie.Play "Idle1_6"
Genie.Play "Idle1_1"
Genie.Play "Idle1_2"
Genie.Play "Idle1_3"
Genie.Play "Idle1_4"
Genie.Play "Idle1_5"
Genie.Play "Idle1_6"
Genie.Play "Idle2_1"
Genie.Play "Idle2_2"
Genie.Play "Idle2_3"
Genie.Play "Idle3_1"
Genie.Play "Process"
Genie.Play "GetAttentionReturn"
Genie.Speak "앗 저의 주인님이 부르시는군요!!"
Genie.Speak "급히 가봐야겠습니다."
Genie.MoveTo 490, 350
Genie.Play "Greet"
Genie.Speak "Good bye 먼저 갑니다..."
Genie.hide
' *** END MASH USER SCRIPT ***
End Sub
</Script>
그리고 자바가 아닌 VBScript 입니다. 그리고 <head>와 </head> 사이에 삽입하시면 링크에러가 날 것입니다.
<body> 부분에 넣어서 사용하세요..
<Script Language="VBScript">
' * Character Objects
Dim Genie
'+ ' * Variables
Dim UsedChars
Dim GenieID
Dim GenieACS
Dim GenieURL
Dim GenieStates
Dim GenieAnimations
Dim GenieReq
Dim GenieStatesReq
Dim GenieAnimationsReq
Dim GenieLoaded
Dim HideReq
Dim Req
' * Initialize
UsedChars = "Genie"
' * Genie
Genie = "Genie"
GenieACS = "Genie.acs"
GenieURL = "http://agent.microsoft.com/agent2/chars/genie/genie.acf"
GenieStates = "Showing, Hiding, Speaking, Moving, Gesturing"
GenieAnimations = "GestureRight, DoMagic1, DoMagic2, Idle1_1, Idle1_2, Idle1_3, Idle1_4, Idle1_5, Idle1_6, Idle2_1, Idle2_2, Idle2_3, Idle3_1, Process, GetAttentionReturn, Greet"
GenieLoaded = False
' * Prevent Auto-Download of Microsoft Agent if not already installed
If AgentInstalled() Then
Document.WriteLn "<Object ID=""AgentControl"" Width=0 Height=0"
Document.WriteLn " ClassID=""CLSID:D45FD31B-5C6E-11D1-9EC1-00C04FD7081F"""
Document.WriteLn " CodeBase=""#VERSION=2,0,0,0"">"
Document.WriteLn "</Object>"
Document.WriteLn "<Object ID=""L&HTruVoice"" Width=0 Height=0"
Document.WriteLn " ClassID=""CLSID:B8F2846E-CE36-11D0-AC83-00C04FD97575"""
Document.WriteLn " CodeBase=""#VERSION=6,0,0,0"">"
Document.WriteLn "</Object>"
End If
Function AgentInstalled()
' Purpose: Returns True if Agent 2.0 is installed, else False
On Error Resume Next
Dim AgentControl
Dim ScriptVersion
ScriptVersion = GetScriptVersion()
If ScriptVersion > 1 Then
Set AgentControl = CreateObject("Agent.Control.2")
AgentInstalled = IsObject(AgentControl)
Else
AgentInstalled = False
End If
End Function
Function GetScriptVersion()
' Purpose: Returns major version of the Scripting Engine
On Error Resume Next
Dim Ver
Ver = 0
Ver = ScriptEngineMajorVersion
If Ver = 0 Then Ver = 1
GetScriptVersion = Ver
End Function
Sub Window_OnLoad()
' Purpose: Runs automatically when page is loaded
On Error Resume Next
' * INSERT ANY NON-AGENT RELATED SCRIPTING HERE
If Not AgentInstalled() Then
Exit Sub
End If
AgentControl.Connected = True
GenieLoaded = LoadLocalAgent(GenieID, GenieACS)
If GenieLoaded Then
Call SetCharObj
End If
Call CheckLoadStatus
End Sub
Function LoadLocalAgent(ByVal CharID, ByVal CharACS)
' Purpose: Attempts to load the specified character
' Returns: True if successful, False if not
On Error Resume Next
AgentControl.Characters.Load CharID, CharACS
If Err = 0 Then
LoadLocalAgent = True
Exit Function
End If
LoadLocalAgent = False
End Function
Sub SetCharObj()
' Purpose: Sets the character reference and TTS Language ID
On Error Resume Next
Set Genie = AgentControl.Characters(GenieID)
Genie.LanguageID = &H412
End Sub
Sub CheckLoadStatus()
' Purpose: Determines if required characters have been loaded.
' If not, issue request to load next character
' else run the AgentIntro routine
If Not GenieLoaded Then
Window.Status = "Loading " & GenieID & " Character. Please Wait..."
Set GenieReq = AgentControl.Characters.Load(GenieID, GenieURL)
Exit Sub
End If
Window.Status = ""
Call AgentIntro
End Sub
Sub AgentControl_RequestComplete(ByVal RequestObject)
' Purpose: Take action on completion or failure of requests
On Error Resume Next
Select Case RequestObject
Case GenieReq
If RequestObject.Status = 0 Then
Call SetCharObj
If GenieStates <> "" Then
Window.Status = "Loading " & GenieID & " States. Please Wait..."
Set GenieStatesReq = AgentControl.Characters(GenieID).Get("State", GenieStates, True)
ElseIf GenieAnimations <> "" Then
Window.Status = "Loading " & GenieID & " Animations. Please Wait..."
Set GenieAnimationsReq = AgentControl.Characters(GenieID).Get("Animation", GenieAnimations, True)
Else
GenieLoaded = True
Call CheckLoadStatus
End If
Else
Call LoadError
End If
Exit Sub
Case GenieStatesReq
If RequestObject.Status = 0 Then
If GenieAnimations <> "" Then
Window.Status = "Loading " & GenieID & " Animations. Please Wait..."
Set GenieAnimationsReq = AgentControl.Characters(GenieID).Get("Animation", GenieAnimations, True)
Else
GenieLoaded = True
Call CheckLoadStatus
End If
Else
Call LoadError
End If
Exit Sub
Case GenieAnimationsReq
If RequestObject.Status = 0 Then
GenieLoaded = True
Call CheckLoadStatus
Else
Call LoadError
End If
Exit Sub
Case HideReq
AgentControl.Characters.Unload GenieID
End Select
End Sub
Sub LoadError()
Dim strMsg
Window.Status = ""
strMsg = "Error Loading Character: " & GenieID
strMsg = strMsg & Chr(13) & Chr(13) & "This Microsoft Agent Script requires the character(s):"
strMsg = strMsg & Chr(13) & UsedChars
MsgBox strMsg, 48
End Sub
Sub AgentControl_Click(ByVal CharacterID, ByVal Button, ByVal Shift, ByVal X, ByVal Y)
End Sub
Sub AgentControl_DblClick(ByVal CharacterID, ByVal Button, ByVal Shift, ByVal X, ByVal Y)
' Purpose: Stop and Hide all characters on double-click
On Error Resume Next
Genie.StopAll
If Not GenieID.HasOtherClients Then
If Genie.Visible Then
Set HideReq = Genie.Hide()
Else
AgentControl.Characters.Unload GenieID
End If
End If
End Sub
Function GetDay()
' Purpose: Returns current weekday name
Dim aDay
aDay = Array("","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
GetDay = aDay(WeekDay(Now()))
End Function
Function GetDate()
' Purpose: Returns current long date
Dim aMon
Dim sDay
aMon = Array("","January","February","March","April","May","June","July","August","September","October","November","December")
sDay = Day(Now())
If sDay = "11" Or sDay = "12" Or sDay = "13" Then
sDay = sDay & "th"
Else
Select Case Right(sDay, 1)
Case "1": sDay = sDay & "st"
Case "2": sDay = sDay & "nd"
Case "3": sDay = sDay & "rd"
Case Else
sDay = sDay & "th"
End Select
End If
GetDate = aMon(Month(Now())) & " " & sDay & ", " & Year(Now())
End Function
Function GetTime()
' Purpose: Returns current time
On Error Resume Next
Dim sTime
sTime = Left(Time(), 5)
If Right(sTime, 1) = ":" Then
sTime = Left(sTime, Len(sTime) - 1)
End If
sTime = sTime & Mid(Time(), InStr(Time(), " "))
GetTime = sTime
End Function
Function GetTimeOfDay()
' Purpose: Returns current time of day
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 InitAgentCommands()
' Purpose: Initialize the Commands menu
On Error Resume Next
Genie.Commands.RemoveAll
Genie.Commands.Caption = "My Menu Name"
Genie.Commands.Add "ACO", "Advanced Character Options", "Advanced Character Options"
End Sub
Sub AgentControl_Command(ByVal UserInput)
' Purpose: Determine Command that was selected either by menu or voice
' and run the applicable Command Script
On Error Resume Next
Dim BadConfidence
BadConfidence = 10
If (UserInput.Confidence <= -40) Then
' Bad Recognition
Exit Sub
ElseIf (UserInput.Alt1Name <> "") And Abs(Abs(UserInput.Alt1Confidence) - Abs(UserInput.Confidence)) < BadConfidence Then
' Bad Confidence - too close to another command
Exit Sub
ElseIf (UserInput.Alt2Name <> "") And Abs(Abs(UserInput.Alt2Confidence) - Abs(UserInput.Confidence)) < BadConfidence Then
' Bad Confidence - too close to another command
Exit Sub
Else ' High Confidence
' *** BEGIN MASH USER COMMANDS ***
Select Case UserInput.Name
Case "ACO"
AgentControl.PropertySheet.Visible = True
End Select
' *** END MASH USER COMMANDS ***
End If
End Sub
Sub AgentControl_Bookmark(ByVal BookmarkID)
On Error Resume Next
End Sub
Sub AgentIntro()
On Error Resume Next
Call InitAgentCommands
' *** BEGIN MASH USER SCRIPT ***
Genie.Show
Genie.MoveTo 870, 170
Genie.Play "MoveDown"
Genie.Play "Greet"
Genie.Speak "안녕하세요 Good " & GetTimeOfDay() & "! 지니입니다. 오늘은 " & GetDay() & ", " & GetDate() & "."
Genie.Speak "소리사랑 홈페이지를 방문해주셔서 감사합니다."
Genie.Play "Process"
Genie.MoveTo 30, 170
Genie.Speak "원하는 메뉴를 선택하세요!! "
Genie.Play "Gestureleft"
Genie.Play "Acknowledge"
Genie.Play "Confused"
Genie.Play "Process"
Genie.MoveTo 800, 280
Genie.Play "DoMagic1"
Genie.Play "DoMagic2"
Genie.Speak "참 먼저 로그인을 해주세요!! "
Genie.Play "GestureRight"
Genie.Speak "그리고 회원은 소리사랑가족만 받습니다!!"
Genie.Speak "그리고 비밀번호 혹은 아이디를 잊어 먹었을때는 비밀번호찾기를.. ^^ "
Genie.MoveTo 800, 480
Genie.Play "Congratulate"
Genie.Speak "박수 박수"
Genie.Speak "생일도 축하해줍시다. "
Genie.MoveTo 870, 170
Genie.Play "Idle1_1"
Genie.Play "Idle1_2"
Genie.Play "Idle1_3"
Genie.Play "Idle1_4"
Genie.Play "Idle1_5"
Genie.Play "Idle1_6"
Genie.Play "Idle2_1"
Genie.Play "Idle2_2"
Genie.Play "Idle2_3"
Genie.Play "Idle1_1"
Genie.Play "Idle1_2"
Genie.Play "Idle1_3"
Genie.Play "Idle1_4"
Genie.Play "Idle1_5"
Genie.Play "Idle1_6"
Genie.Play "Idle1_1"
Genie.Play "Idle1_2"
Genie.Play "Idle1_3"
Genie.Play "Idle1_4"
Genie.Play "Idle1_5"
Genie.Play "Idle1_6"
Genie.Play "Idle2_1"
Genie.Play "Idle2_2"
Genie.Play "Idle2_3"
Genie.Play "Idle3_1"
Genie.Play "Process"
Genie.Play "GetAttentionReturn"
Genie.Speak "앗 저의 주인님이 부르시는군요!!"
Genie.Speak "급히 가봐야겠습니다."
Genie.MoveTo 490, 350
Genie.Play "Greet"
Genie.Speak "Good bye 먼저 갑니다..."
Genie.hide
' *** END MASH USER SCRIPT ***
End Sub
</Script>
댓글 2
-
Mahican
2002.12.02 01:17
참 참고로 미리보기는 없습니다. 에러 없이 동작하는것 확인하고 올리는 것입니다. -
완전범죄
2002.12.02 17:33
저희집만 그런지 로딩시간이 약간 있네요..^^