Sign in to follow this  
Followers 0
kjactive

Working on a com object editer

9 posts in this topic

#1 ·  Posted (edited)

I've been working on a com object editor for some time now, got the main intuition finished and method to edit, move, remove and add new components done but I'm stuck in one single problem - I can't get the created componets real ID or used library location...

I need a components function, something like a GetRealComID function and not the created components object internal ID as I'll get with GetObj - the trouble is that there could be several components doing the same object BUT they are not exatctly and has difference in parametres etc. - questen: does the editer in this condition use the OWC.Spreadsheet.9 / OWC.Spreadsheet.10 or is it a compleatly different object or I could do with information on: from what file C:\PROGRA~1\MICROS~2\Office10\MSOWC.DLL. This makes a huge difference in the editer process and I'm stuck here and need some help!!!!

The application is build around some form components, one scans the computer for available components, There is a components toolbox where one can edit available components and make related component groups, a rubberband forms window and a Properties window related to all componets and all is working and the application can already generate an example script BUT to what object - dam it...

kjactive :lmao:

Edited by kjactive

Share this post


Link to post
Share on other sites



I've been working on a com object editor for some time now, got the main intuition finished and method to edit, move, remove and add new components done but I'm stuck in one single problem - I can't get the created componets real ID or used library location...

...

kjactive :lmao:

Hello kjactive,

It sounds to me a job for ObjName(). Currently this function only returns the Interface name, or the description of the Object.

I could extend this function to return the AppID and/or a CLSID. I'm not sure if returning a DLL name is reliable, because some controls are being 'proxied' through other DLL's.

Will that help you?

Regards,

-Sven

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I've been working with your 'component interfase' for some time now and it's very reliable and well featured in most conditions - reminds me of the VB method and I stumbeled over some components to write an editer with copy, cut and paste in a rubberband interface, I realy like the idear to use componts to create componets scripts and in the same time do some deep testing on the components all in one process but as you'r aware of, componets can be treated in manny different ways and is target all sorts of different platforms and not all componets is leagal and can do all sorts of bad things if used wrong.

You can see in my attached graphics that there is attached a Medieplayer and a spreadsheet componets, both treats as normal components as one can insert a movie to be played in the medieplayer etc. but here comes my trouble as to what component is used on this particulare computer: is it WMPlayer 7 / 8 / 9 / 10 revision or is it the old VideoPreview...

ObjName() with more extensions would help a lot, the best result would be the PROGID but CLSID would help too as I then could scan the reqisty and find what ProgID used, the same goes for library used but it would slow the appliaction down - well a file description and date attached would also be nice, how about making these informations available as an returned array?

Keep up your nice component work as it really expand autoit3 gui applications and really works well...

kjactive :lmao:

Edited by kjactive

Share this post


Link to post
Share on other sites

..

kjactive,

Did the revised ObjName() function in beta version 3.1.1.104 solve your problems?

-Sven

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Well Sven your last update to 'ObjName' helped me over the hurdle, I can now get information on what components is used on the particulare computer and the com editer do now scan the computer for components and inserts all available into the editer toolbox alright and put the right PROGID into the final script - all functional as a simple script...

As it is now the component script editer writes a native scipt on all components with size and location, a component pool and free the components again at end, all functional BUT...

I can't find a smart way to revieve the properties available to every component - do you know a smart method or have some idears that would help - I would appriciate all help here. I have the components name, ID and PROGID available and I can already get values from known properties and write these into the generated script.

I could easy write all general properties into the script like Backcolor / frontcolor, Borderstyle etc. but there got to be a smart way to recieve all properties available to the components - would be nice...

kjactive :lmao:

Edited by kjactive

Share this post


Link to post
Share on other sites

kjactive,

What you are asking for is access to the Type Library of Objects. Currently AutoIt has no native functions to do so. Maybe it will be included in the future, but first I want to get the current COM implementation stable before I add new functionality.

You could build a 'plugin' if you are good in C++ COM programming :-)

The only way I know to do it using native AutoIt functions is from an idea of Dale Holm (see his amazing discovery at: http://www.autoitscript.com/forum/index.php?showtopic=11466 )

However, that solution requires the tlbinf32.dll file, which is only distributed with MS Visual Studio (as far as I know..). I don't even know whether it is allowed to be distributed separately, but when you 'Google' around, you will find enough links to download this file.

Here is a working example using tlbinfo32.dll:

; Example file showing the usage of the TypeLibInformation object (TLI)
; The required DLL (tlbinf32.dll) is distributed with MS Visual Studio
; or use Google to retrieve it.
;
; 2006-01-29 SvenP
;
; More information about the TLI.TLIApplication can be downloaded from: 
; http://support.microsoft.com/?scid=kb;en-us;224331&spid=3042&sid=global
;
#include <guiconstants.au3>

; We use a Forms2.0 button as an example
$oForm = ObjCreate("Forms.Form.1") ; Create a new Forms collection
$oForm.caption = "Change properties of this button and click 'Go get info!'" 
$oForm.Designmode=-1    ; So we can move around with the example button
$oForm.ShowToolBox=0    ; Don't show toolbox for this example.

; Create an example button to retrieve info from.
$oButton=$oForm.Add("Forms.CommandButton.1","TestButton",1) 

; Set some example properties
With $oButton
    .caption="Test Button"
    .Left=10
    .Top=8
    .Height=20
    .Width=70
    .Visible=1
EndWith

; Create a simple GUI for our example
GUICreate ( "Embedded ActiveX Test", 460, 480 )

$GUI_ActiveX    =   GUICtrlCreateObj    ( $oForm, 10, 30 , 400 , 180 )
$GUI_Button     =   GUICtrlCreateButton ( "Go get info!", 10, 215 , 80 , 30 )
$GUI_Edit       =   GUICtrlCreateEdit   ( "", 10, 250 , 400 , 220 )
GUISetState ()    ;Show GUI

While 1
    $msg = GUIGetMsg()
    Select
        case $msg = $GUI_EVENT_CLOSE 
            ExitLoop
        case $msg = $GUI_Button         ; Note: Example currently FIXED for $oButton variable only !
            GUICtrlSetData( $GUI_Edit, ""); clear editbox
            $aProperties=ObjectGetProperties($oButton)
            for $Property in $aProperties; Display each property in Editbox
                GUICtrlSetData( $GUI_Edit, "$oButton." & $Property & "=" & _
                Execute( "$oButton." & $Property  ) & @CRLF , "append")
            Next
    EndSelect
    
Wend

GUIDelete ()

$oButton="" ; Remove the button
$oForm=""   ; Clear form

Exit        ; That's all folks


Func ObjectGetProperties($oObj)
;DESCRIPTION:   Retrieves the description of all writable properties of the given Object.
;REQUIRES:      tlbinf32.dll  (distributed with Visual Studio)
;PARAMETERS:    $oApp - Pointer to an active object
;DATE:          2006-01-29
;AUTHOR:        SvenP
;CREDITS:       To Dale Holm

Dim $oTLA, $oTLI, $TLIMember, $aProperties[1]

Const $cINVOKE_FUNC=1           ; A method (=function)
Const $cINVOKE_PROPERTYGET=2    ; Read-only property
Const $cINVOKE_PROPERTYPUT=4    ; Read/write property
Const $cINVOKE_PROPERTYPUTREF=8 ; Reference property

if not IsObj($oObj) then Return

$oTLA   = ObjCreate("TLI.TLIApplication"); oTLA is a _TLIApplication interface
$oTLI   = $oTLA.InterfaceInfoFromObject($oObj) ; oTLI is a InterfaceInfo interface

For $TLIMember in $oTLI.Members           ; This interface contains both methods and properties
    if $TLIMember.InvokeKind=$cINVOKE_PROPERTYPUT then; Get only WRITABLE properties
        Redim $aProperties[UBound($aProperties)+1]  ; We don't know the number of properties in advance
        $aProperties[UBound($aProperties)-1]=$TLIMember.Name; Add the name of the property to array.
    EndIf
Next

return $aProperties

EndFunc

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Thanks Sven and ofcourse the same goes to Daleholm - this brings me closer but the trouble here is that the components ID is not known and there is something I don't quiet get but maybe someone can cast some light in here...

With $oForm
  For $a = 0 To $oForm.Count // count return available components
    .Item($a).Name // this return all available unknown components names alright....
     ObjName(.Item($a),3) // this return the right component PROGID alright...
      $aProperties = ObjectGetProperties(.Item($a))
       for $Property in $aProperties; Display each property...
           $Property & ' = ' & Execute( .Item($a) & '.' & $Property  )
          ; This display the $oForm. mother component properties and not the attached componets as 
          ; previous and Execute( .Item($a) & '.' & $Property ) do not provide any values evaluated...
       Next
  Next
Endwith

This is a stripped down example code but the function is very long and integreated...

The trouble is that related to Daleholms function, I do not know the componets Memory ID but has to messure it out from the mother component and that should be $oForm.Item($a) // 0/1/2 etc. and $oForm.Item($a).Name do responce to the right components and return the true name attach to every components BUT $aProperties = ObjectGetProperties(.Item($a)) only responce to the mother $oForm values

I know this is a hard one, Any suggestions...

kjactive :lmao:

Edited by kjactive

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

@kjactive

I have a major need for a COM Object viewer... I am assuming "editor" would allow me to do this.

If you have this finished, or wouldnt mind sending me something that would help me out I would greatly appreciate it.

I havent done much COM programming, but I am working to create some QuickBooks programs.

Edit: Okay... well I found (thanks to the Helpfile) the MS OLE/COM Object Viewer. Thats great, but now I dont know how to use that information to do what I want :-p. I'll eventually get it.

Thanks,

JS

Edited by JSThePatriot

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

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