Q. Why can't I load MSAgents other than Merlin?
May 1, 2008
A. The Character.Load command actually takes two parameters, the name of the agent and the file name for the agent. If you run the following command,
PS C:Usersjohn.SAVILLTECH> $null = $agent.Characters.Load("Robby")
then you actually load the default Merlin character even though you specified Robby. Instead, you need to use:
$null = $agent.Characters.Load("Robby","robby.acs")
Note that you can't load multiple agents into a single control. Instead, you need to create two agent control objects. Run the following commands to see my first attempt at an agent show:
$agent = new-object -com Agent.Control.2
$agent2 = new-object -com Agent.Control.2
$null = $agent.connected = 1
$null = $agent2.connected = 1
$null = $agent.Characters.Load("Merlin")
$null = $agent2.Characters.Load("Robby","robby.acs")
$null = $merlin = $agent.Characters.Character("Merlin")
$null = $robby = $agent2.Characters.Character("Robby")
$null = $merlin.show()
$null = $merlin.MoveTo(250, 250, 1)
Start-Sleep –s 5
$null = $robby.show()
$null = $robby.MoveTo(650, 250, 1)
Start-Sleep –s 5
$null = $merlin.Play("GestureLeft")
Start-Sleep –s 2
$null = $robby.Play("GestureRight")
Start-Sleep –s 2
$null = $merlin.Speak("The Windows Server 2008 IT/24 Robot looks cooler than you")
Start-Sleep –s 5
$null = $robby.Play("Sad")
Start-Sleep –s 4
$null = $robby.Play("LookRight")
Start-Sleep –s 3
$null = $robby.Speak("At least I don't wear a dress")
Start-Sleep –s 5
$null = $robby.MoveTo(250, 250, 1)
Start-Sleep –s 1
$null = $merlin.Hide()
$null = $robby.Play("Congratulate")
Start-Sleep –s 5
$null = $robby.Hide()
$merlin = $null
$agent = $null
$robby = $null
$agent2 = $null
You can see this in action in the videocast at this URL:
http://www.savilltech.com/Videos/PowerShellAgents/PowerShellAgents.htm
About the Author
You May Also Like