Page 1 of 1

How to count the number of open Firefox browser tabs?

Posted: 13 Nov 2013, 15:04
by Coldblackice
This might be a longshot, but would it be possible for AHK to count the number of Firefox browser tabs currently open?

Re: How to count the number of open Firefox browser tabs?

Posted: 13 Nov 2013, 15:42
by Guest
You could cycle through the windows/tabs and count. Probably fails when you have two tabs on the same page - here is some code you might be able to use:
http://www.autohotkey.com/board/topic/1 ... t-re-find/

Alternatively you might try with Mozrepl (=FF addon + google the AHK library for it) and some javascript http://www.benjiegillam.com/2008/09/eve ... have-open/

Re: How to count the number of open Firefox browser tabs?

Posted: 13 Nov 2013, 17:46
by Coldblackice
Guest wrote:You could cycle through the windows/tabs and count. Probably fails when you have two tabs on the same page - here is some code you might be able to use:
http://www.autohotkey.com/board/topic/1 ... t-re-find/

Alternatively you might try with Mozrepl (=FF addon + google the AHK library for it) and some javascript http://www.benjiegillam.com/2008/09/eve ... have-open/
Thanks, much obliged for that.

I'm going to check up on the Mozrepl when I get home from work tonight, but do you think it might be possible to do this on an "OS" level, so to speak -- whether through some third party Firefox API, or perhaps "peeking" into Firefox's memory (rather than having to manually paginate through hundreds of tabs every time a count is done)?

Re: How to count the number of open Firefox browser tabs?

Posted: 14 Nov 2013, 00:44
by jethrow

Code: Select all

list := Acc_Get("Object", "application.tool_bar3.page_tab_list", 0, "ahk_class MozillaWindowClass")
MsgBox % list.accChildCount-1
for posterity, this could be done more effectively using UIA.

Re: How to count the number of open Firefox browser tabs?

Posted: 15 Nov 2013, 05:04
by Guest10
wow! this is totally unbelievable! :ugeek: can you also create a list of each open tab "title"? :ugeek:
jethrow wrote:

Code: Select all

list := Acc_Get("Object", "application.tool_bar3.page_tab_list", 0, "ahk_class MozillaWindowClass")
MsgBox % list.accChildCount-1
for posterity, this could be done more effectively using UIA.

Re: How to count the number of open Firefox browser tabs?

Posted: 17 Nov 2013, 21:07
by jethrow

Code: Select all

list := Acc_Get("Object", "application.tool_bar3.page_tab_list", 0, "ahk_class MozillaWindowClass")
for each, tab in Acc_Children(list)
   t .= tab.accName(0) "`n"
MsgBox %t%

Re: How to count the number of open Firefox browser tabs?

Posted: 17 Nov 2013, 22:02
by Guest10
WOW!!! totally unbelievable, thanks! :shock: :ugeek:

Re: How to count the number of open Firefox browser tabs?

Posted: 31 Jul 2023, 03:59
by OmTatSat
jethrow wrote:
14 Nov 2013, 00:44

Code: Select all

list := Acc_Get("Object", "application.tool_bar3.page_tab_list", 0, "ahk_class MozillaWindowClass")
MsgBox % list.accChildCount-1
for posterity, this could be done more effectively using UIA.
Hello.
I tried this for Firefox 102.13.0esr (64 бита) and it doesn't work, maybe some update is needed?

Re: How to count the number of open Firefox browser tabs?

Posted: 31 Jul 2023, 04:55
by GEV

Code: Select all

list := Acc_Get("Object", "application.tool_bar2.page_tab_list", 0, "ahk_class MozillaWindowClass")
MsgBox % list.accChildCount-1
Tested with Firefox 115.0.3 (64-Bit)

Re: How to count the number of open Firefox browser tabs?

Posted: 31 Jul 2023, 05:00
by OmTatSat
GEV wrote:
31 Jul 2023, 04:55

Code: Select all

list := Acc_Get("Object", "application.tool_bar2.page_tab_list", 0, "ahk_class MozillaWindowClass")
MsgBox % list.accChildCount-1
Tested with Firefox 115.0.3 (64-Bit)
Thanks for the quick response!)
I tried but got an empty msgbox
Do you have any idea why this might be happening? and how to find a solution?

Re: How to count the number of open Firefox browser tabs?

Posted: 31 Jul 2023, 05:14
by GEV
OmTatSat wrote:
31 Jul 2023, 03:59
I tried this for Firefox 102.13.0esr (64 бита) and it doesn't work, maybe some update is needed?
Why should I update my web browser?

Re: How to count the number of open Firefox browser tabs?

Posted: 31 Jul 2023, 05:59
by OmTatSat
GEV wrote:
31 Jul 2023, 05:14
OmTatSat wrote:
31 Jul 2023, 03:59
I tried this for Firefox 102.13.0esr (64 бита) and it doesn't work, maybe some update is needed?
Why should I update my web browser?
I don't want to use the latest version, because sometimes add-ons stop working after updating Firefox for a few weeks/months - until the creators fix them.
And on the latest version - it's the same as with often not working add-ons. And if use Firefox several versions ago, then add-ons almost always normally work)

For me worked

Code: Select all

list := Acc_Get("Object", "4.14.1", 0, "ahk_class MozillaWindowClass")
;list := Acc_Get("Object", "окно.приложение Orders - Mozilla Firefox.список табуляций", 0, "ahk_class MozillaWindowClass")
MsgBox % list.accChildCount-1
In older version it is ..."Object", "4.21.1",... so i think it can be modified in future versions like "4.var.1"
i have cyrillic ui, and think this is issue why application.tool_bar2.page_tab_list and application.tool_bar3.page_tab_list do not work for me(

Re: How to count the number of open Firefox browser tabs?

Posted: 31 Jul 2023, 08:05
by OmTatSat
managed to set with the text for cyrillic ui

Code: Select all

list := Acc_Get("Object", "приложение.панель инструментов2.список табуляций", 0, "ahk_class MozillaWindowClass")
Question, comes out the text is determined by Role, but there are many Role = tool_bar but they are have different Name. So i wonder are there way to specify a Name for search instead Role?