Sign in to follow this  
Followers 0
oktoberfest2

!Help - Return Value From a COM object

6 posts in this topic

Problem Description:

The $retVal variable below is not returning any value. It should return an encrypted value of the $passwordToEnrypt.

The same code in VB works.

I have tried the following with no luck as well...

$retValue = $test1.EncryptPassword ($passwordToEncrypt, $retVal)

I'm hoping that someone has called a function and needed a return value similar to what I'm trying to do. I don't get any error message. The messagebox is simply blank.

I appreciate any help that you can offer.

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
dim $retVal
dim $passwordToEncrypt= "test"
$test = ObjCreate("Session")
$test1 = $test.CreateInstance("Instance.UserName")

$test1.EncryptPassword ($passwordToEncrypt, $retVal)

Msgbox(0,"Encrypted Password", $retVal)

Func MyErrFunc()
  $HexNumber=hex($oMyError.number,8)
  Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !"       & @CRLF  & @CRLF & _
             "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
             "err.windescription:"     & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "         & @TAB & $HexNumber              & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "     & @TAB & $oMyError.scriptline     & @CRLF & _
             "err.source is: "         & @TAB & $oMyError.source         & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile       & @CRLF & _
             "err.helpcontext is: "    & @TAB & $oMyError.helpcontext _
            )
  SetError(1)  ; to check for after this function returns
  Exit
Endfunc

Share this post


Link to post
Share on other sites



Do you have the actual function from VB, because this does return an error for me (ObjCreate).


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Using a variable ByRef through COM is still not supported. I've posted a request here.

Share this post


Link to post
Share on other sites

Thanks for the responses. I'm sure the functionality will come shortly.

Share this post


Link to post
Share on other sites

is there a solution for this, I'm having the same problem with my current script

Share this post


Link to post
Share on other sites

I'm just guessing, but could you use VB scripting objects inside AutoIt? If VBScript supported ByRef, then you could create some kind of a hack...

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