AutoHotkey Community

It is currently May 27th, 2012, 1:29 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Tab List of Firefox
PostPosted: March 25th, 2009, 1:40 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
I got bored, so wrote it. It'll retrieve the list of tabs of the running firefox. I tested it with Firefox v3.0.7 in XPSP3.

NEED Accessibility Standard Library.

Chronological Order
Code:
ACC_Init()
MsgBox % FF_TabList()
ACC_Term()

FF_TabList()
{
   DetectHiddenWindows, On
   If Not   hWnd :=   WinExist("ahk_class MozillaUIWindowClass")
   Return
   Loop, %   COM_Invoke(pacc:=ACC_AccessibleObjectFromWindow(hWnd),"accChildCount")
   If   COM_Invoke(pacc,"accChild[" A_Index "].accRole[0]")=0x14
   {
      paccChild := COM_Invoke(pacc,"accChild",A_Index)
      Break
   }
   COM_Release(pacc)
   If Not   pacc :=   paccChild
   Return
   idx := 0
   Loop, %   COM_Invoke(pacc,"accChildCount")
   If   COM_Invoke(pacc,"accChild[" A_Index "].accRole[0]")=0x26
      sTabs .= "[TAB" (++idx) (COM_Invoke(pacc,"accChild[" A_Index "].accState[0]")&0x18000 ? "]`t":"]*`t") COM_Invoke(pacc,"accChild[" A_Index "].accChild[1].accChild[1].accName[0]") "`n`t" COM_Invoke(pacc,"accChild[" A_Index "].accChild[1].accChild[1].accValue[0]") "`n"
   COM_Release(pacc)
   Return   sTabs
}

TabBar Order
Code:
ACC_Init()
MsgBox % FF_TabList()
ACC_Term()

FF_TabList()
{
   DetectHiddenWindows, On
   If Not   hWnd :=   WinExist("ahk_class MozillaUIWindowClass")
   Return
   Loop, %   COM_Invoke(pacc:=ACC_AccessibleObjectFromWindow(hWnd),"accChildCount")
   If   COM_Invoke(pacc,"accChild[" A_Index "].accRole[0]")=0x14
   {
      paccChild := COM_Invoke(pacc,"accChild",A_Index)
      Break
   }
   COM_Release(pacc)
   If Not   pacc :=   paccChild
   Return
   paccChild:=0, COM_Invoke(pdic:=COM_CreateObject("Scripting.Dictionary"),"CompareMode",1)
   Loop, %   COM_Invoke(pacc,"accChildCount")
   If   (nRole:=COM_Invoke(pacc,"accChild[" A_Index "].accRole[0]"))=0x26
      COM_Invoke(pdic,"Item",COM_Invoke(pacc,"accChild[" A_Index "].accChild[1].accChild[1].accName[0]"),COM_Invoke(pacc,"accChild[" A_Index "].accChild[1].accChild[1].accValue[0]"))
   Else If   (nRole=0x3C)
      paccChild := COM_Invoke(pacc,"accChild",A_Index)
   COM_Release(pacc)
   If Not   pacc :=   paccChild
   Return   COM_Release(pdic)
   idx := 0
   Loop, %   COM_Invoke(pacc,"accChildCount")
   If   COM_Invoke(pacc,"accChild[" A_Index "].accRole[0]")=0x25
      sTabs .= "[TAB" (++idx) (COM_Invoke(pacc,"accChild[" A_Index "].accState[0]")&2 ? "]*`t":"]`t") (sName:=COM_Invoke(pacc,"accChild[" A_Index "].accName[0]")) "`n`t" COM_Invoke(pdic,"Item",sName) "`n"
   COM_Release(pacc)
   COM_Release(pdic)
   Return   sTabs
}


Last edited by Sean on March 25th, 2009, 3:41 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 25th, 2009, 3:05 pm 
Offline

Joined: June 6th, 2006, 3:19 pm
Posts: 1654
Location: Denmark
Nice! My firefox setup have the tabs on the second paccChild=0x14 hit.
I did a small rewrite:
Code:
ACC_Init()
MsgBox % FF_TabList()
ACC_Term()

FF_TabList()
{
  DetectHiddenWindows, On
  If Not hWnd := WinExist("ahk_class MozillaUIWindowClass")
    Return "Failed 1"
 
  Loop, % COM_Invoke(pacc:=ACC_AccessibleObjectFromWindow(hWnd),"accChildCount")
  {
    If COM_Invoke(pacc,"accChild[" A_Index "].accRole[0]")=0x14
    {
      paccChild := COM_Invoke(pacc,"accChild",A_Index)
      idx := 0
      Loop, % COM_Invoke(paccChild,"accChildCount")
      {
        If COM_Invoke(paccChild,"accChild[" A_Index "].accRole[0]")=0x26
          sTabs .= "[TAB" (++idx) (COM_Invoke(paccChild,"accChild[" A_Index "].accState[0]")&0x18000 ? "]`t":"]*`t") COM_Invoke(paccChild,"accChild[" A_Index "].accChild[1].accChild[1].accName[0]") "`n`t" COM_Invoke(paccChild,"accChild[" A_Index "].accChild[1].accChild[1].accValue[0]") "`n"
      }     
      COM_Release(paccChild)
    }
  }
  COM_Release(pacc)
  Return sTabs
}

_________________
RegEx Powered Dynamic Hotstrings
COM
AutoHotkey 2


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 25th, 2009, 3:42 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
tonne wrote:
Nice! My firefox setup have the tabs on the second paccChild=0x14 hit.
Thanks, I added another version which will respect the order of tabs in tabbar.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bon, Yahoo [Bot] and 14 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group