Here's a nice piece of VBScript to run with Macro. You could run without Macro Scheduler, but why would you want to.
The script calls the Microsoft .acs agent 'Merlin' who will appear on screen with a little animation and some messages.
It can help anyone looking to learn VBS, simply due to each step and perfomance of the script.
Have fun .. and turn your volume down if you're at work it plays sounds.
Ed
VBSTART
Option Explicit
Const Complete = 0, Pending = 2
Dim objAgent, objChar, objRequest, txtSpeak
Dim strCharacter, Shell, strFirstName
strFirstName = "MS Forum Friend"
strCharacter = "Merlin"
'strCharacter = "Genie"
Set Shell = CreateObject("WScript.Shell")
If HaveAgent() Then
objAgent.Characters.Load strCharacter, strCharacter & ".acs"
Set objChar = objAgent.Characters(strCharacter)
With objChar
.Top = 50
.Left = 50
.LanguageID = &h409
.Show
End With
objChar.Play "Greet"
objChar.Speak "Hello, " & strFirstName & "\Vol=100"
objChar.Play "GetAttention"
objChar.Play "GetAttentionReturn"
objChar.Speak "Hello! " & strFirstName
objChar.Play "Idle2_2"
objChar.Play "Acknowledge"
objChar.Play "Announce"
objChar.Speak "Reviewing the code may help you with VBScripting"
objChar.MoveTo 800, 600
objChar.Play "Idle3_1"
objChar.Play "Wave"
objChar.Speak "Goodbye and happy Scripting!" & strFirstName
Set objRequest = objChar.Hide
Do Until objRequest.Status = Complete
Wscript.Sleep 100
Loop
Set objChar = Nothing
objAgent.Characters.Unload strCharacter
WScript.Quit
Else
Shell.Popup "MS Agent NOT Found !" & vbCrLf, _
10, _
"Error Message", _
vbInformation + vbOKOnly + vbSystemModal
Wscript.Quit
End If
Function HaveAgent()
HaveAgent = False
On Error Resume Next
Set objAgent = CreateObject("Agent.Control.1")
objAgent.Connected = True
HaveAgent = IsObject(objAgent)
End Function
VBEND
Fun with VBScript and Macro Sheduler
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
This doesn't actually work from within Macro Scheduler as is because it needs to use the WSH sleep function which is not available to Macro Scheduler. You'd have to run this natively.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Workaround:
Here's the compiled EXE (in a zip file):
http://www.mjtnet.com/software/merlin.zip
Code: Select all
VBSTART
Option Explicit
Const Complete = 0, Pending = 2
Dim objAgent
Sub DoWizard(tmpscp)
Dim objChar, objRequest, txtSpeak
Dim strCharacter, Shell, strFirstName
strFirstName = "Macro Scheduler User"
strCharacter = "Merlin"
'strCharacter = "Genie"
Set Shell = CreateObject("WScript.Shell")
If HaveAgent() Then
objAgent.Characters.Load strCharacter, strCharacter & ".acs"
Set objChar = objAgent.Characters(strCharacter)
With objChar
.Top = 50
.Left = 50
.LanguageID = &h409
.Show
End With
objChar.Play "Greet"
objChar.Speak "Hello, " & strFirstName & "\Vol=100"
objChar.Play "GetAttention"
objChar.Play "GetAttentionReturn"
objChar.Speak "Hello! " & strFirstName
objChar.Play "Idle2_2"
objChar.Play "Acknowledge"
objChar.Play "Announce"
objChar.Speak "This EXE was built with Macro Scheduler"
objChar.MoveTo 800, 600
objChar.Play "Idle3_1"
objChar.Play "Wave"
objChar.Speak "Goodbye and happy Scripting " & strFirstName & "!"
Set objRequest = objChar.Hide
Do Until objRequest.Status = Complete
Call Shell.Run (tmpscp, ,true)
Loop
Set objChar = Nothing
objAgent.Characters.Unload strCharacter
'Shell.Quit
Else
Shell.Popup "MS Agent NOT Found !" & vbCrLf, _
10, _
"Error Message", _
vbInformation + vbOKOnly + vbSystemModal
'Shell.Quit
End If
End Sub
Function HaveAgent()
HaveAgent = False
On Error Resume Next
Set objAgent = CreateObject("Agent.Control.1")
objAgent.Connected = True
HaveAgent = IsObject(objAgent)
End Function
VBEND
WriteLn>%TEMP_DIR%\sleep.vbs,r,WScript.sleep 100
VBRun>DoWizard,%TEMP_DIR%\sleep.vbs
DeleteFile>%TEMP_DIR%\sleep.vbs
http://www.mjtnet.com/software/merlin.zip
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
There are other characters besides Merlin: Genie, Reedy and Robby. You can download the others here from Microsoft.
http://www.microsoft.com/msagent/downlo ... #character
Below are some extra Merlin movements for your macro script. Let the forum know if you do something really clever with Macro Scheduler and your MS Agent.
Enjoy. Ed
http://www.microsoft.com/msagent/downlo ... #character
Below are some extra Merlin movements for your macro script. Let the forum know if you do something really clever with Macro Scheduler and your MS Agent.
Enjoy. Ed
Code: Select all
Acknowledge
Announce
Blink
Congratulate
DoMagic1
DoMagic2
Explain
GestureDown
GestureLeft
GestureRight
GetAttention
LookUpBlink
MoveDown
MoveLeft
MoveRight
MoveUp
Pleased
Process
Read
Sad
Search
Show
Think
Wave
Write