Sign in to follow this  
Followers 0
ilovecui

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

4 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

thanks for your help :^^

Share this post


Link to post
Share on other sites

And... 2 years later....

How do you change the language of Merlin?

Thanks.

Best regards.

T@PµZ.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0