Jump to content

How to use com&obj to show the ms agent?


 Share

Recommended Posts

I want to use the com&obj function to show the ms agent,but ....

here is the code: Hold the expert could help me ,thanks.

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Form1", 223, 182, 193, 125)

$Obj1 = ObjCreate("Agent.Control.2")

$Obj1_ctrl = GUICtrlCreateObj($Obj1, 56, 80, 32, 32)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

dim $name="merlin"

$Obj1.Connected = true;

$Obj1.Characters.Load("merlin","merlin.acs");< --- the function could not run at this point

$name = agent.Characters("merlin");

$name.MoveTo(200,200);

$name.Show();

Exit

EndSwitch

WEnd

Link to comment
Share on other sites

  • Developers

Here is a working version of merlin which is a translation of the vbs script found here ... maybe that helps:

$strAgentName = "Merlin"
$strAgentPath = "C:\Windows\Msagent\Chars\" & $strAgentName & ".acs"
$Obj1 = ObjCreate("Agent.Control.2")
$Obj1.Connected = 1
$Obj1.Characters.Load ($strAgentName, $strAgentPath)
if @error then exit 
$objCharacter = $obj1.Characters.Character($strAgentName)
$objCharacter.Show
sleep(200)
$objCharacter.Play("GetAttention")
$objCharacter.Speak("Hello, how are you?")
$objCharacter.Speak("I'm going now. Goodbye.")
$objCharacter.Hide
While $objCharacter.Visible = TRUE
    Sleep(250)
WEnd

; This is my custom error handler 
Func MyErrFunc() 
   $HexNumber=hex($oMyError.number,8) 
   Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _
                "LineNumber is: " & $oMyError.scriptline & @CRLF & _
                "Number is: " & $HexNumber & @CRLF & _
                "Desc is: " & $oMyError.description & @CRLF & _
                "Windescription is: " & $oMyError.windescription ) 

   SetError(1); something to check for when this function returns 
Endfunc
Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...