I found this article but I am not having any luck piecing it together. Any help is appreciated. Or other suggestions to accomplish this.
My code as is right now:
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#Include .\Lib\Acc.ahk
#Hotstring EndChars `n `t
GroupAdd, vGroupFirefoxAndChrome, ahk_class Chrome_WidgetWin_1
#IfWinActive, ahk_group vGroupFirefoxAndChrome
[my host strings] :o:short::expanded text is here.
WinGet, hWnd, ID, A
WinGetClass, vWinClass, ahk_id %hWnd%
vLetter := SubStr(A_ThisHotkey, 1-1)
vNum := Asc(vLetter)-96
if (vWinClass = "Chrome_WidgetWin_1")
JEE_ChromeGetTabNames(hWnd, vSep="`n")
Return
#IfWinActive
;==================================================
JEE_ChromeGetTabNames(hWnd, vSep="`n")
{
oAcc := Acc_Get("Object", "4.1.2.2.2", 0, "ahk_id " hWnd)
vOutput := ""
for each, oChild in Acc_Children(oAcc)
{
vTabText := oChild.accName(0)
if !(vTabText == "")
&& !(vTabText == "New Tab")
vOutput .= vTabText vSep
}
vOutput := SubStr(vOutput, 1, -StrLen(vSep)) ;trim right
oAcc := oChild := ""
return vOutput
}
;==================================================
JEE_ChromeFocusTabByNum(hWnd, vNum)
{
oAcc := Acc_ObjectFromWindow(hWnd)
oAcc := Acc_Child(oAcc, 1), oAcc := Acc_Child(oAcc, 2)
oAcc := Acc_Child(oAcc, 2), oAcc := Acc_Child(oAcc, 2)
vRet := 0
For each, oChild in Acc_Children(oAcc)
{
if (A_Index = vNum+1)
if (1, oChild.accDoDefaultAction(0), vRet := A_Index)
break
}
Return vRet
}
;==================================================
JEE_ChromeFocusTabByName(hWnd, vTitle, vNum=1)
{
oAcc := Acc_ObjectFromWindow(hWnd)
oAcc := Acc_Child(oAcc, 1), oAcc := Acc_Child(oAcc, 2)
oAcc := Acc_Child(oAcc, 2), oAcc := Acc_Child(oAcc, 2)
vCount := 0
vRet := 0
For each, oChild in Acc_Children(oAcc)
{
vTabText := oChild.accName(0)
if (vTabText = vTitle)
vCount ++
if (vCount = vNum)
if (1, oChild.accDoDefaultAction(0), vRet := A_Index)
break
}
oAcc := ""
Return vRet
}
;==================================================