' Get the screen height/width, but call later
Function fnScreenRes()
Dim xH, xW
With CreateObject("InternetExplorer.Application")
.Navigate("about:blank")
Do Until .readyState = 4: Loop
xW = .document.ParentWindow.screen.width
xH = .document.ParentWindow.screen.height
.Quit
End With
fnScreenRes = array(xW, xH)
End Function
' Determine the architecture
Dim WshShell
Dim WshProcEnv
Dim sArchSys
Dim sArchProc
Dim nArchRes
iLoop = 2048
sArch = ""
Set WshShell = CreateObject("WScript.Shell")
Set WshProcEnv = WshShell.Environment("Process")
sArchProc = WshProcEnv("PROCESSOR_ARCHITECTURE")
If sArchProc = "x86" Then
sArchSys = WshProcEnv("PROCESSOR_ARCHITEW6432")
If sArchSys = "" Then
sArchSys = "x86"
End if
Else
sArchSys = sArchProc
End If
Do While iLoop <> 1
nArchRes = InStr(sArchSys, CStr(iLoop))
If nArchRes <> 0 Then
sArch = CStr(iLoop)
Exit Do
End If
iLoop = CInt(iLoop / 2)
Loop
If sArch = "x86" Then
sArch = "32"
End If
If sArch = "32" Then
sArch = ""
End If
' Invoke Merlin accordingly
sNameAgent = "Merlin"
sPathAgent = "C:\Windows\MSAgent" & sArch & "\Chars\" & sNameAgent & ".acs"
Set oAgent = CreateObject("Agent.Control.2")
' Connect to the agent service
oAgent.Connected = TRUE
' Load the character desired
oAgent.Characters.Load sNameAgent, sPathAgent
iWait = 500
Dim oAnim
With oAgent.Characters.Character(sNameAgent)
Set oAnim = .Show
' Chew on this while showing
oScreen = fnScreenRes()
iX = CInt(oScreen(0) / 2) - CInt(.Width / 2)
iY = CInt(oScreen(1) / 2) - CInt(.Height / 2)
Do Until oAnim.Status = 0
Wscript.Sleep iWait
Loop
Set oAnim = Nothing
Set oAnim = .Play("GetAttention")
Do Until oAnim.Status = 0
Wscript.Sleep iWait
Loop
Set oAnim = Nothing
Set oAnim = .Play("GetAttentionContinued")
Do Until oAnim.Status = 0
Wscript.Sleep iWait
Loop
Set oAnim = Nothing
Set oAnim = .Play("GetAttentionReturn")
Do Until oAnim.Status = 0
Wscript.Sleep iWait
Loop
Set oAnim = Nothing
' Move to the center of the screen.
' If you have two monitors, I'm sorry, but
' you're well and truly screwed because
' I just can't be bovvered.
Set oAnim = .MoveTo(iX, iY)
Do Until oAnim.Status = 0
Wscript.Sleep iWait
Loop
Set oAnim = Nothing
Set oAnim = .Play("Greet")
Do Until oAnim.Status = 0
Wscript.Sleep iWait
Loop
Set oAnim = Nothing
Set oAnim = .Play("RestPose")
Do Until oAnim.Status = 0
Wscript.Sleep iWait
Loop
Set oAnim = Nothing
Set oAnim = .Play("Pleased")
Do Until oAnim.Status = 0
Wscript.Sleep iWait
Loop
Set oAnim = Nothing
Set oAnim = .Speak("Hello, I am " & sNameAgent & "!")
Do Until oAnim.Status = 0
Wscript.Sleep iWait
Loop
Set oAnim = Nothing
Set oAnim = .Play("DoMagic1")
Do Until oAnim.Status = 0
Wscript.Sleep iWait
Loop
Set oAnim = Nothing
Set oAnim = .Speak("That's the way! Uh huh. Uh huh.")
.Speak("I like it! Uh huh. Uh huh.")
Do Until oAnim.Status = 0
Wscript.Sleep iWait
Loop
Set oAnim = Nothing
Set oAnim = .Play("DoMagic2")
Do Until oAnim.Status = 0
Wscript.Sleep iWait
Loop
Set oAnim = Nothing
Set oAnim = .Speak("Goodbye!")
Do Until oAnim.Status = 0
Wscript.Sleep iWait
Loop
Set oAnim = Nothing
Set oAnim = .Play("Wave")
Do Until oAnim.Status = 0
Wscript.Sleep iWait
Loop
Set oAnim = Nothing
.Hide
' Allow agent to finish whatever commanded before exiting
Do While .Visible = TRUE
Wscript.Sleep iWait
Loop
End With
' Clean up properly
oAgent.Characters.Unload sNameAgent
Wscript.Quit