Jump to content

Accessing properties and values of COM object


Recommended Posts

Hello,

 

Is there a way to get all the properties and method of a COM object thru Autoit.

I am looking in a way of display the imbricated structure of object and method.

 

Example of COm objects are "itunes.application", "Shell.application" and so on.

The idea is to have a code looking like

$objtobrowse = objcreate("itunes.application")

if isobj($objtobrowse) then
$colItems = $objtobrowse.buildinproperty
    For $objItem In $colItems
        ConsoleWrite($objItem.<Name> & " - " & $objItem.<Value> & @CRLF)
    Next
EndIf

 

Link to comment
Share on other sites

Link to comment
Share on other sites

Maybe this helps:

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Or this one:

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

32 minutes ago, Danyfirex said:

I think you could do it using something like this.

 

Saludos

Unfortunately as in this thread

Func AssignCOMEnums($sApp, $bShow = 0)

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

$oApp   = ObjCreate($sApp)
$oTLA   = ObjCreate("TLI.TLIApplication")

$oTLI   = $oTLA.InterfaceInfoFromObject($oApp)

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

$objx= "Shell.application"

AssignCOMEnums($objx,1)

$oTLA.InterfaceInfoFromObject seems not to works

: ==> Variable must be of type "Object".:
$oTLI   = $oTLA.InterfaceInfoFromObject($oApp)
$oTLI   = $oTLA^ ERROR

 

Any idea why  ?

Link to comment
Share on other sites

Link to comment
Share on other sites

Did you register the DLL after downloading?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

19 minutes ago, gillesg said:

Should something appear in Oleview ?

Don't know.

Did you try the TLBViewer I suggested in post #4? It is a pure AutoIt implementation without the need for any DLLs etc.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Hello. Here is the way for fixing the create object issue.

Local Const $sCLSID_TLI = "{8B21775E-717D-11CE-AB5B-D41203C10000}"
Local Const $sIID_ITLI = "{8B21775D-717D-11CE-AB5B-D41203C10000}"
Local $oTLI = ObjCreateInterface($sCLSID_TLI, $sIID_ITLI)
ConsoleWrite("$oTLI: " & IsObj($oTLI) & @CRLF)

Add it to your code. I have no too much time for do it.

I dont know the exactly issue of ObjCreate and I will not look into...

Saludos

Link to comment
Share on other sites

All,

Despite the help provided, it is still not working

Func AssignCOMEnums($sApp, $bShow = 0)
    Dim $oTLA, $oTLI, $CstEnum, $CstObj, $CstString, $oApp

    $oApp = ObjCreate($sApp)
    $oTLA = ObjCreate("TLI.TLIApplication")
    If IsObj($oTLA) Then
        ConsoleWrite("objName of bjCreate(""TLI.TLIApplication"") is " & ObjName($oTLA) & @CRLF)
        $oTLI = $oTLA.InterfaceInfoFromObject($oApp)
    Else
        Local Const $sCLSID_TLI = "{8B21775E-717D-11CE-AB5B-D41203C10000}"
        Local Const $sIID_ITLI = "{8B21775D-717D-11CE-AB5B-D41203C10000}"
        $oTLA = ObjCreateInterface($sCLSID_TLI, $sIID_ITLI)
        If isobj($oTLA) Then
            ConsoleWrite("$oTLA object name is  " & ObjName($oTLA) & @CRLF)
        Else
            ConsoleWrite("$oTA is still not an object"&@CRLF)
            exit
        EndIf
    EndIf

    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   ;==>AssignCOMEnums

$objx = "Shell.application"
AssignCOMEnums($objx, 1)

 I think i will pass on this one.

Thanks for your time

Link to comment
Share on other sites

Here is an Example. 

 

#AutoIt3Wrapper_Run_AU3Check=n


Func AssignCOMEnums($sApp, $bShow = 0)
    Local $oTLA, $oTLI, $CstEnum, $CstObj, $oApp

    $oApp = ObjCreate($sApp)
    $oTLA = ObjCreate("TLI.TLIApplication")
    If IsObj($oTLA) Then
        ConsoleWrite("objName of bjCreate(""TLI.TLIApplication"") is " & ObjName($oTLA) & @CRLF)
        $oTLI = $oTLA.InterfaceInfoFromObject($oApp).Parent
    Else
        Local Const $sCLSID_TLI = "{8B21775E-717D-11CE-AB5B-D41203C10000}"
        Local Const $sIID_ITLI = "{8B21775D-717D-11CE-AB5B-D41203C10000}"
        $oTLA = ObjCreateInterface($sCLSID_TLI, $sIID_ITLI)
        $oTLI = $oTLA.InterfaceInfoFromObject($oApp).Parent
        If isobj($oTLA) Then
            ConsoleWrite("$oTLA object name is  " & ObjName($oTLA) & @CRLF)
        Else
            ConsoleWrite("$oTA is still not an object"&@CRLF)
            exit
        EndIf
    EndIf

    For $CstEnum In $oTLI.Constants
        ConsoleWrite($CstEnum.Name & @CRLF)
        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) & @CRLF)
            Next
        EndIf
    ExitLoop
    Next

EndFunc   ;==>AssignCOMEnums

Local $objx = "Excel.application"
AssignCOMEnums($objx, 1)
MsgBox(0,"","$xlDrawingObject IsDeclared = " & IsDeclared("xlDrawingObject") & @CRLF & "$xlDrawingObject Value= " & $xlDrawingObject)

Saludos

Link to comment
Share on other sites

Hello,

testing the provided example (but removing last line "Msgbox"). Still have the same error.

Func AssignCOMEnums($sApp, $bShow = 0)
    Local $oTLA, $oTLI, $CstEnum, $CstObj, $oApp

    $oApp = ObjCreate($sApp)
    $oTLA = ObjCreate("TLI.TLIApplication")
    If IsObj($oTLA) Then
        ConsoleWrite("objName of objCreate(""TLI.TLIApplication"") is " & ObjName($oTLA) & @CRLF)
        $oTLI = $oTLA.InterfaceInfoFromObject($oApp).Parent
    Else
        Local Const $sCLSID_TLI = "{8B21775E-717D-11CE-AB5B-D41203C10000}"
        Local Const $sIID_ITLI = "{8B21775D-717D-11CE-AB5B-D41203C10000}"
        $oTLA = ObjCreateInterface($sCLSID_TLI, $sIID_ITLI)
        $oTLI = $oTLA.InterfaceInfoFromObject($oApp).Parent
        If isobj($oTLA) Then
            ConsoleWrite("$oTLA object name is  " & ObjName($oTLA) & @CRLF)
        Else
            ConsoleWrite("$oTA is still not an object"&@CRLF)
            exit
        EndIf
        $oTLI = $oTLA.InterfaceInfoFromObject($oApp).Parent
    EndIf

    For $CstEnum In $oTLI.Constants
        ConsoleWrite($CstEnum.Name & @CRLF)
        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) & @CRLF)
            Next
        EndIf
    ExitLoop
    Next
EndFunc   ;==>AssignCOMEnums

Local $objx = "Excel.application"
AssignCOMEnums($objx, 1)

reuslt is 

--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
"D:\Users\gigros\Desktop\Perso Films\AutoIt - itunes\WPD test.au3" (139) : ==> Variable must be of type "Object".:
$oTLI = $oTLA.InterfaceInfoFromObject($oApp).Parent
$oTLI = $oTLA^ ERROR
->09:45:24 AutoIt3.exe ended.rc:1
+>09:45:24 AutoIt3Wrapper Finished.
>Exit code: 1    Time: 4.875

 

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

×
×
  • Create New...