Jump to content

Trouble with ObjCreate("TLI.TLIApplication")


Recommended Posts

I'm trying to convert the VBScript here: See the second Reply to AU3 format.

Dim $TLA, $TLI, $CstEnum, $CstObj, $CstString, $myApp

ConsoleWrite("--> Autoit Version: " & @AutoItVersion  & @CR)

$myApp = ObjCreate("Excel.Application")
If IsObj($myApp) Then ConsoleWrite("--> $myApp Object: OK" & @CR)
$TLA   = ObjCreate("TLI.TLIApplication")
    If @error Then
        ConsoleWrite("!!! $TLA Error: " & Hex(@error, 8) & @CR)
        Exit
    EndIf
If IsObj($TLA) Then ConsoleWrite("--> $TLA OK" & @CR)
$TLI   = $TLA.InterfaceInfoFromObject($myApp).Parent 
ConsoleWrite(";Enums from: " & $TLI.ContainingFile & @CRLF)
For $CstEnum in $TLI.Constants 
    If "_" <> StringLeft($CstEnum.Name, 1) Then 
        ConsoleWrite(";" & $CstEnum.Name & @CR)
        For $CstObj In $CstEnum.Members 
            ConsoleWrite("Const " & "$" & $CstObj.Name & " = " & $CstObj.Value & @CR)
        Next 
    EndIf 
Next

This produces the following output and the error 80004002 on the ObjCreate. This is working in VBScript.

--> Autoit Version: 3.1.1.30
--> $myApp Object: OK
!!! $TLA Error: 80004002

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

I'm trying to convert the VBScript here: See the second Reply to AU3 format.

...

--> Autoit Version: 3.1.1.30
--> $myApp Object: OK
!!! $TLA Error: 80004002

<{POST_SNAPBACK}>

Hello Dale,

I did some testing between VBscript and AutoIt. It seems that some Objects do not like to be opened using the 'Dispatch' interface immediately.

Fixed this one using a dumb trick and your script works! I will submit the modified code to jpm asap.

Thanks for finding this bug ! (Nah, bug: Microsoft didn't write it's own objects conform COM standards..)

Regards,

-Sven

Edited by SvenP
Link to comment
Share on other sites

Dale,

Your script works now in V3.1.1.31. When you substitute the ConsoleWrite("Const " & .. line with Eval("Const " & ... then all your constants will be assigned automagically.

Regards,

-Sven

Link to comment
Share on other sites

Dale,

Your script works now in V3.1.1.31.  When you substitute the ConsoleWrite("Const " & .. line with Eval("Const " & ... then all your constants will be assigned automagically.

Regards,

-Sven

<{POST_SNAPBACK}>

Yes -- I just tested with .31 and it works great thanks!

Thanks for the tip on Eval("Const " & ... -- your recommendation on how to do that was going to be my next question! Very cool.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Yes -- I just tested with .31 and it works great thanks!

Thanks for the tip on Eval("Const " & ... -- your recommendation on how to do that was going to be my next question!  Very cool.

Dale

<{POST_SNAPBACK}>

Doesn't look like the Eval("Const " & ... can work... I get a syntax error and from the docs, it looks like the expresstion in Eval("expression") must resolve into a variable rather than to a command. If there is a way to do this, please let me know.

The only approach I can think of at this point it to write the commands out to a file and then include that file... any other ideas? Can things be done with stdout and stdin?

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Doesn't look like the Eval("Const " & ... can work... I get a syntax error and from the docs, it looks like the expresstion in Eval("expression") must resolve into a variable rather than to a command.  If there is a way to do this, please let me know.

The only approach I can think of at this point it to write the commands out to a file and then include that file...  any other ideas?  Can things be done with stdout and stdin?

Dale

<{POST_SNAPBACK}>

Dale,

You are absolutely right. It won't work with Eval.

However there are no other means to define a new variable/contstant within a script.

Executing an external script will define the variables in the scope of the external script. Thus when the script exists, your constants are gone.

I was trying to implement an Execute() functions for these kind of things. I will submit the code to jpm when it's finished.

Regards,

-Sven

Link to comment
Share on other sites

Dale,

Stupid me, AutoIt has so many functions that I oversaw the 'assign' command.

Just do:

Assign( $CstObj.Name , $CstObj.Value )
And the magic starts...

-Sven

<{POST_SNAPBACK}>

Magic indeed! Such a small bit of code...

I don't have the gumption to do it, but this feels like the beginning of a UDF library for COM...

#cs
Func AssignCOMEnums($sApp [, $bShow])
    ABSTRACT:
        Retrieve the Enumerated Constants for an Applcation Class and assign their values to AutoIt3 global variables
        Example: AssignCOMEnums("Excel.application", 1)
    REQUIRED:
        $sApp - string containing the class name.  Ex. "Excel.application"
    OPTIONAL:
        $bShow - if set to 1, ConsoleWrite will display the resulting constants and their associated values
#ce
Func AssignCOMEnums($sApp, $bShow = 0)

Dim $oTLA, $oTLI, $CstEnum, $CstObj, $CstString, $sApp, $oApp, $bShow

$oApp   = ObjCreate($sApp)
$oTLA   = ObjCreate("TLI.TLIApplication")
$oTLI   = $oTLA.InterfaceInfoFromObject($oApp).Parent
    
For $CstEnum in $oTLI.Constants 
    If "_" <> StringLeft($CstEnum.Name, 1) Then 
        For $CstObj In $CstEnum.Members 
            Assign("$" & $CstObj.Name, $CstObj.Value, 2)
            If $bShow Then ConsoleWrite("$" & $CstObj.Name & " = " & Eval("$" & $CstObj.Name) & @CR)
        Next 
    EndIf 
Next

EndFunc

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
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
 Share

  • Recently Browsing   0 members

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