Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

AHK_L / COM confusion


  • Please log in to reply
7 replies to this topic
edison
  • Members
  • 29 posts
  • Last active: May 10 2015 11:15 PM
  • Joined: 13 Feb 2013

Hi all,

 

I've been playing with AHK for a few months now and don't know how I lived without it prior.

 

That said, there's a number of things that are rather confusing to me and I'm hoping to get them cleared up so I can get back to writing scripts. I wouldn't be surprised if these questions haven't already been answered, but I have scoured the forums and have ended up even more confused.

 

Here's my understanding so far. Please correct any misinformation.

 

AutoHotKey_L *was* an improved branch/version of the orignal version of AutoHotKey, but has since been merged into the trunk. Any references to AutoHotKey_L or AHK_L should now be taken to mean the latest version of AHK (v1.1.09.03 as of this writing) and as such, the canonical documentation can be found here: http://l.autohotkey.net/docs/

 

I also understand that there was a crash of the forums around August of 2012 and that many of the scripts archived on the site were lost. Many of those scripts have been recovered through various mechanisms (Google cache, user/author re-ups, etc).

 

I'm still a bit confused about COM support.

 

From what I've read, COM was originally supported by a COM.ahk library script. There was also a COM_L.ahk (referenced in the same post), which was supported by AutoHotKey_L. Subsequent posts on that thread indicate that COM support was merged into AHK_L prior to the AHK/AHK_L merge, which means it should be available out-of-the-box in the current version of AHK.

 

Is this true? And if so, with the now-built-in COM support, do you need the original COM.ahk or COM_L.ahk scripts? If so, where can they be found?

 

This all stems from getting errors about a call to the noneistent function "COM_Error()".

 

Thanks in advance for the clarification and I hope this can save other users the hours I've spent on the issue.

 

-edison



sinkfaze
  • Moderators
  • 6367 posts
  • Last active: Nov 30 2018 08:50 PM
  • Joined: 18 Mar 2008

Here's my understanding so far. Please correct any misinformation.

AutoHotKey_L *was* an improved branch/version of the orignal version of AutoHotKey, but has since been merged into the trunk. Any references to AutoHotKey_L or AHK_L should now be taken to mean the latest version of AHK (v1.1.09.03 as of this writing) and as such, the canonical documentation can be found here: http://l.autohotkey.net/docs/

 

Correct.

 

I also understand that there was a crash of the forums around August of 2012 and that many of the scripts archived on the site were lost. Many of those scripts have been recovered through various mechanisms (Google cache, user/author re-ups, etc).

 

It didn't crash, it was taken offline due to a script kiddie breach (which is what deleted most of the files).

 

From what I've read, COM was originally supported by a COM.ahk library script. There was also a COM_L.ahk (referenced in the same post), which was supported by AutoHotKey_L. Subsequent posts on that thread indicate that COM support was merged into AHK_L prior to the AHK/AHK_L merge, which means it should be available out-of-the-box in the current version of AHK.

Is this true? And if so, with the now-built-in COM support, do you need the original COM.ahk or COM_L.ahk scripts? If so, where can they be found?

 

Correct, COM.ahk and COM_L.ahk are now pretty much deprecated; cases where you might need them are pretty rare (and possibly non-existent since the server crash).

 

This all stems from getting errors about a call to the noneistent function "COM_Error()".

 

What code are you attempting to use that's giving you that error?



edison
  • Members
  • 29 posts
  • Last active: May 10 2015 11:15 PM
  • Joined: 13 Feb 2013

What code are you attempting to use that's giving you that error?

 

This is a function I found here that is supposed to fetch the Firefox status bar text.

FF_StatusBarText(hwnd="") {

    IfEqual, hwnd, , WinGet, hwnd, id, ahk_class MozillaUIWindowClass

    Com_Error(false)

    if hWnd

        if FF := Com_AccessibleObjectFromWindow(hwnd) ; access Firefox window

            if SubWindow := FF.accChild(FF.accChildCount) ; access StatusBar Sub-window (may cause com error)

                if StatusBar := SubWindow.accChild(1) ; access the StatusBar

                    SBarText := StatusBar.accName(0) ; store Status Bar text

    Com_Error(true)

    return, SBarText
}


sinkfaze
  • Moderators
  • 6367 posts
  • Last active: Nov 30 2018 08:50 PM
  • Joined: 18 Mar 2008
You shouldn't need COM.ahk for that any longer, although you will want jethrow's Acc Library:
FF_StatusBarText(hwnd="") {

	IfEqual, hwnd, , WinGet, hwnd, id, ahk_class MozillaUIWindowClass

	ComObjError(False)

	if	hWnd
        	if	FF :=	Acc_ObjectFromWindow(hwnd) ; access Firefox window
			if	SubWindow :=	FF.accChild(FF.accChildCount)	; access StatusBar Sub-window (may cause com error)
				if	StatusBar :=	SubWindow.accChild(1)	; access the StatusBar
					SBarText :=	StatusBar.accName(0)	; store Status Bar text

	ComObjError(True)
	return	SBarText
}


Guest10
  • Members
  • 1216 posts
  • Last active: Oct 30 2015 05:12 PM
  • Joined: 27 Oct 2012

I used the above code but it didn't fetch the Firefox status bar text.



jethrow
  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009

I tried for 45mins to get the status bar text from FF18.0.2 using Acc, but no success. Maybe someone can prove my coding skills are getting rusty ...

 

I also find it interesting that the status bar accRole is showing as "div" - considering the accRole should be an object role constant. You can see this doing something like this:

;// hit f1 when status bar is showing (mouse over a link)

F1:: 
MouseGetPos, , , hwnd
WinGetPos, x, y, , h, ahk_id %hwnd%
Acc := Acc_ObjectFromPoint(child, x+20, y+h-20)
MsgBox % Acc.accRole(0)

;// MsgBox % Acc.accName(child) ;// blank - should be status bar text?

 

Edit: edison pointed out the correct way to access the status bar:

MsgBox % Acc_Get("Name", "application.grouping2.property_page1.status_bar1", 0, "ahk_class MozillaWindowClass")


edison
  • Members
  • 29 posts
  • Last active: May 10 2015 11:15 PM
  • Joined: 13 Feb 2013

jethrow,

 

I wonder if that's because it may actually BE a div. Since the old status bar is gone, it may be they just showing the link previews and page loading status via a div. If so, how would you access the content?

 

Interestingly enough, when I added the Status-4-Evar extension, your above code worked perfectly. The accRole was 41 (ROLE_SYSTEM_STATICTEXT) and Acc.accName(child) returned the status bar text, which was a URL while I was mousing over a link. From what I can tell, that extension uses the Add-on toolbar as the status bar.

 

In your test, was the Add-on toolbar visible?



edison
  • Members
  • 29 posts
  • Last active: May 10 2015 11:15 PM
  • Joined: 13 Feb 2013

For those who stumble across this thread while looking to either read the Firefox status bar text and/or determine when a page has finished loading in Firefox, see this thread.