Help me understand ComObject()

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
doctorMe
Posts: 8
Joined: 07 Jul 2016, 03:31

Help me understand ComObject()

26 Jul 2016, 05:38

I want to translate a code from AHK to VB6. I have managed to understand and translate all the commands but one: ComObject(9, <xxx>, 1) where <xxx> is a ComObjQuery() statement. What exactly ComObject() does and what is the equivalent for Microsoft?
doctorMe
Posts: 8
Joined: 07 Jul 2016, 03:31

Re: Help me understand ComObject()

01 Aug 2016, 09:11

ComObj(9, ComObjQuery(Acc,"{618736e0-3c3d-11cf-810c-00aa00389b71}"), 1)

Can anyone tell me what this command does exactly? What exactly is retrieved from the registry with ComObjQuery() and what exactly does ComObj()?
User avatar
Blackholyman
Posts: 1293
Joined: 29 Sep 2013, 22:57
Location: Denmark
Contact:

Re: Help me understand ComObject()

01 Aug 2016, 10:45

What script are you trying to convert?

You may not need this function

The inner is querying for a raw interface pointer and the outer is then getting a script usable com object from that pointer
Also check out:
Courses on AutoHotkey

My Autohotkey Blog
:dance:
doctorMe
Posts: 8
Joined: 07 Jul 2016, 03:31

Re: Help me understand ComObject()

01 Aug 2016, 11:30

Blackholyman wrote:What script are you trying to convert?

You may not need this function

The inner is querying for a raw interface pointer and the outer is then getting a script usable com object from that pointer
I am trying to translate this: https://autohotkey.com/boards/viewtopic ... rowser+tab
I think I know how to translate the inner with objectIa.QueryInterface() but I have no idea for the outer.
User avatar
Blackholyman
Posts: 1293
Joined: 29 Sep 2013, 22:57
Location: Denmark
Contact:

Re: Help me understand ComObject()

02 Aug 2016, 02:28

I don't know vba that well so can't really tell you where to find that info
Also check out:
Courses on AutoHotkey

My Autohotkey Blog
:dance:
lexikos
Posts: 9599
Joined: 30 Sep 2013, 04:07
Contact:

Re: Help me understand ComObject()

02 Aug 2016, 03:07

I haven't touched VB6 in over a decade, and never had to do the equivalent of QueryInterface, but don't think you actually call QueryInterface. Just add the right type library as a reference, declare a variable of the right interface type, and assign the object to it.

ComObject() is highly specific to AutoHotkey. VB6 is a COM-based language; you typically don't deal with the pointers directly in VB6, just references to objects.

I would suggest looking for resources on the topic of using Active Accessibility in VB6.

@Blackholyman: VBA is not VB6.
doctorMe
Posts: 8
Joined: 07 Jul 2016, 03:31

Re: Help me understand ComObject()

02 Aug 2016, 04:26

To be honest, I use another type of Basic which is VB with some extra abilities. Do not worry about that. The only thing is to understand what ComObj does. For example, I understood that ComObjQuery retrieves something from the IAccessible interface from Windows Registry. The acc variable indicates what to retrieve. I want to understand something like that for ComObj too.
lexikos
Posts: 9599
Joined: 30 Sep 2013, 04:07
Contact:

Re: Help me understand ComObject()

02 Aug 2016, 06:10

If you want my description of it, look in the manual. If that's not good enough, you'll need to ask a more specific question (or wait for someone else to answer).
For example, I understood that ComObjQuery retrieves something from the IAccessible interface from Windows Registry. The acc variable indicates what to retrieve.
No, it does nothing like that.
doctorMe
Posts: 8
Joined: 07 Jul 2016, 03:31

Re: Help me understand ComObject()

02 Aug 2016, 07:48

lexikos wrote:If you want my description of it, look in the manual. If that's not good enough, you'll need to ask a more specific question (or wait for someone else to answer).
I have already read it but it didn't help. I don't want to get rude, but, what more should I ask? I have posted the initial code that I want to translate, I ask what exactly these commands do, what more should I say? The only thing that I should say now, is that I want to translate these two lines in C++. Forget VB6.
lexikos wrote:No, it does nothing like that.
Are you referring to ComObj or ComObjQuery?
just me
Posts: 9482
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Help me understand ComObject()

02 Aug 2016, 09:52

This is my version of Acc_Query():

Code: Select all

; ----------------------------------------------------------------------------------------------------------------------------------
; Retrieves the IAccessible interface from an IDispatch interface, if any, and releases the IDispatch interface on success.
; Thanks Lexikos - www.autohotkey.com/forum/viewtopic.php?t=81731&p=509530#509530
; ----------------------------------------------------------------------------------------------------------------------------------
Acc_Query(Acc) {
   Try
      IA := ComObjQuery(Acc, "{618736e0-3c3d-11cf-810c-00aa00389b71}")
   Catch E
      Return Acc_Error(A_ThisFunc, E)
   ObjRelease(Acc)
   Return ComObj(9, IA, 1)
}
For ComObject() see ComObjActive()
doctorMe
Posts: 8
Joined: 07 Jul 2016, 03:31

Re: Help me understand ComObject()

02 Aug 2016, 10:35

just me wrote:This is my version of Acc_Query():

Code: Select all

; ----------------------------------------------------------------------------------------------------------------------------------
; Retrieves the IAccessible interface from an IDispatch interface, if any, and releases the IDispatch interface on success.
; Thanks Lexikos - www.autohotkey.com/forum/viewtopic.php?t=81731&p=509530#509530
; ----------------------------------------------------------------------------------------------------------------------------------
Acc_Query(Acc) {
   Try
      IA := ComObjQuery(Acc, "{618736e0-3c3d-11cf-810c-00aa00389b71}")
   Catch E
      Return Acc_Error(A_ThisFunc, E)
   ObjRelease(Acc)
   Return ComObj(9, IA, 1)
}
For ComObject() see ComObjActive()
I have already read it and didn't help. Why do you need ComObj()? What does it do for you? What does parameter 9 do? What does parameter 1 do? What's the point?
just me
Posts: 9482
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Help me understand ComObject()

02 Aug 2016, 11:20

Wraps ... a raw IDispatch pointer in a usable object ...
lexikos
Posts: 9599
Joined: 30 Sep 2013, 04:07
Contact:

Re: Help me understand ComObject()

02 Aug 2016, 20:47

doctorMe wrote:The only thing that I should say now, is that I want to translate these two lines in C++. Forget VB6.
ComObject() is highly specific to AutoHotkey. Just use the pointer directly in C++.

As for the C++ equivalent of ComObjQuery, see 'General Remarks' in the documentation.
lexikos wrote:No, it does nothing like that.
Are you referring to ComObj or ComObjQuery?
I was referring to the part of your post that I quoted, hence the quote; i.e. ComObjQuery.
User avatar
lmstearn
Posts: 695
Joined: 11 Aug 2016, 02:32
Contact:

Re: Help me understand ComObject()

31 May 2020, 10:29

Just for the record, it can be inferred from @JustMe's code snippet that ComObj() appears to be a functional, but (to-date) undocumented equivalent to ComObject().
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
gregster
Posts: 9056
Joined: 30 Sep 2013, 06:48

Re: Help me understand ComObject()

31 May 2020, 14:10

lmstearn wrote:
31 May 2020, 10:29
Just for the record, it can be inferred from @JustMe's code snippet that ComObj() appears to be a functional, but (to-date) undocumented equivalent to ComObject().
Wouldn't this apply :?:
https://www.autohotkey.com/docs/commands/ComObjActive.htm#Remarks wrote:In current versions, any function-call beginning with "ComObj" that does not match one of the other COM functions actually calls ComObjActive.
User avatar
lmstearn
Posts: 695
Joined: 11 Aug 2016, 02:32
Contact:

Re: Help me understand ComObject()

01 Jun 2020, 00:55

Missed the remarks section, sorry. Given that, all the possible alternatives should be explicitly listed in (the header area of, if not, at least in bold or code) the docs for ComObjActive, or else there would be no reason to suppose why any random functions Foo like ComObjFoo won't work.

Googling something like ComObj brings up the ComObjActive page, and the Google search hit sample includes the remarks section with the highlighted ComObj, Unfortunately. I've been in the habit of Googling things like "ComObj AHK" where ComObj is not highlighted in the search hit sample for ComObjActive as it should.
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
lexikos
Posts: 9599
Joined: 30 Sep 2013, 04:07
Contact:

Re: Help me understand ComObject()

01 Jun 2020, 22:28

lmstearn wrote:Given that, all the possible alternatives should be explicitly listed
I think you missed the implication of any function-call beginning with "ComObj" . I can't be bothered to do the math to calculate how many alternatives are possible; it is too many to list in the documentation, unless you want the documentation to include a script to generate all possible combinations. :lol:

Just use one of the two listed at the top of the page.
However, this behaviour will be unavailable in a future release, so it is best to use only ComObject() and ComObjActive() as shown on this page.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Aqualest, Bing [Bot], Google [Bot], Perpendie and 326 guests