Help to find the active tab number in Firefox Topic is solved
Help to find the active tab number in Firefox
I would like to get the tab number of the active tab I am reading in Firefox. By tab number I am referring to the order (sequence) number of the tab from the left. If it is the left-most (first) tab, then the number should be 1. if it is the second tab from the left the number should be 2, etc.
Re: Help to find the active tab number in Firefox
- I have some half-answers.
- If the tab title is unique then these functions will work (in conjunction with WinGetTitle):
Firefox/Chrome, get tab names/focus tab - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 14#p139114
- If the tab title is not unique, then you can use code from the functions above, to get the screen coordinates of each tab button (using the Acc_Location function) and apply PixelGetColor to a tab, and the colour will tell you if the tab is focused or not.
- When I used AccViewer, I couldn't see any information that differentiated between the focused tab and the other tabs.
- There may be other methods that I don't know about.
Link:
Acc library (MSAA) and AccViewer download links - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=26201
- If the tab title is unique then these functions will work (in conjunction with WinGetTitle):
Firefox/Chrome, get tab names/focus tab - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 14#p139114
- If the tab title is not unique, then you can use code from the functions above, to get the screen coordinates of each tab button (using the Acc_Location function) and apply PixelGetColor to a tab, and the colour will tell you if the tab is focused or not.
- When I used AccViewer, I couldn't see any information that differentiated between the focused tab and the other tabs.
- There may be other methods that I don't know about.
Link:
Acc library (MSAA) and AccViewer download links - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=26201
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: Help to find the active tab number in Firefox
Thanks! Are you specifically referring to this part of your code?:
Code: Select all
JEE_FirefoxFocusTabByName(hWnd, vTitle, vNum=1)
{
oAcc := Acc_Get("Object", "4", 0, "ahk_id " hWnd)
vRet := 0
for each, oChild in Acc_Children(oAcc)
if (oChild.accName(0) == "Browser tabs")
{
oAcc := Acc_Children(oChild)[1], vRet := 1
break
}
if !vRet
{
oAcc := oChild := ""
return
}
vCount := 0, vRet := 0
for each, oChild in Acc_Children(oAcc)
{
vTabText := oChild.accName(0)
if (vTabText = vTitle)
vCount++
if (vCount = vNum)
{
oChild.accDoDefaultAction(0), vRet := A_Index
break
}
}
oAcc := oChild := ""
return vRet
}
Re: Help to find the active tab number in Firefox Topic is solved
Eureka! I think I've got it. I used some information that AccViewer doesn't show, but that arguably it *should* show.
Code: Select all
q:: ;Mozilla Firefox - get index of focused tab
WinGet, hWnd, ID, A
oAcc := Acc_Get("Object", "4", 0, "ahk_id " hWnd)
vRet := 0
for _, oChild in Acc_Children(oAcc)
if (oChild.accName(0) == "Browser tabs")
{
oAcc := Acc_Children(oChild)[1], vRet := 1
break
}
if !vRet
{
oAcc := oChild := ""
return
}
vRet := 0
for _, oChild in Acc_Children(oAcc)
{
;STATE_SYSTEM_SELECTED := 0x2
if (oChild.accState(0) & 0x2)
vRet := A_Index
}
oAcc := oChild := ""
MsgBox, % vRet
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: Help to find the active tab number in Firefox
- I was referring to any of the Firefox functions, they all do roughly the same thing.
- Anyhow, that code needed some tidying up, to add a bit more indentation, and to remove the word 'each', and use := instead of = for default values, I've just fixed it in the original link.
- Anyhow, that code needed some tidying up, to add a bit more indentation, and to remove the word 'each', and use := instead of = for default values, I've just fixed it in the original link.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: Help to find the active tab number in Firefox
Thanks VERY much!! It works beautifully and that's all I wanted. Just the tab order number and it works like magic.
Who is online
Users browsing this forum: adam86shadow, balawi28, JKJadan and 261 guests