Firefox/Chrome, get tab names/focus tab

Post your working scripts, libraries and tools for AHK v1.1 and older
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Firefox/Chrome, get tab names/focus tab

19 Aug 2021, 19:17

jwwpua wrote:
19 Aug 2021, 17:48
AHKStudent wrote:
13 Aug 2021, 05:55
new path is 4.1.1.1.1.2.5.3
Chrome V. 92
I'm using a fork of iswitchw.ahk (link: https://www.autohotkey.com/boards/viewtopic.php?f=6&t=89871), and it uses these lines:

Code: Select all

JEE_ChromeAccInit(vValue)
{
	if (vValue = "U1")
		return "4.1.2.1.2.5.2" ;address bar
	if (vValue = "U2")
		return "4.1.2.2.2.5.2" ;address bar
	if (vValue = "T")
		return "4.1.2.1.1.1" ;tabs (append '.1' to get the first tab)
}
Do you know which values U1, U2, and T should be updated to for use with Chrome 92? I'm fairly new to AHK so I'm just trying to figure out how to make Chrome tabs show up in iswitchw. I'm not sure which one should use the new path you mentioned, or what values the other 2 lines need. Thank you!
Try this

Code: Select all

JEE_ChromeAccInit(vValue)
{
	if (vValue = "U1")
		return "4.1.1.1.1.2.5.3" ;address bar
	if (vValue = "U2")
		return "4.1.1.1.1.2.5.3" ;address bar
	if (vValue = "T")
		return "4.1.1.1.1.1.1" ;tabs (append '.1' to get the first tab)
}
jwwpua
Posts: 13
Joined: 06 Aug 2021, 15:03

Re: Firefox/Chrome, get tab names/focus tab

24 Aug 2021, 21:29

AHKStudent wrote:
19 Aug 2021, 19:17
jwwpua wrote:
19 Aug 2021, 17:48
AHKStudent wrote:
13 Aug 2021, 05:55
new path is 4.1.1.1.1.2.5.3
Chrome V. 92
I'm using a fork of iswitchw.ahk (link: https://www.autohotkey.com/boards/viewtopic.php?f=6&t=89871), and it uses these lines:

Code: Select all

JEE_ChromeAccInit(vValue)
{
	if (vValue = "U1")
		return "4.1.2.1.2.5.2" ;address bar
	if (vValue = "U2")
		return "4.1.2.2.2.5.2" ;address bar
	if (vValue = "T")
		return "4.1.2.1.1.1" ;tabs (append '.1' to get the first tab)
}
Do you know which values U1, U2, and T should be updated to for use with Chrome 92? I'm fairly new to AHK so I'm just trying to figure out how to make Chrome tabs show up in iswitchw. I'm not sure which one should use the new path you mentioned, or what values the other 2 lines need. Thank you!
Try this

Code: Select all

JEE_ChromeAccInit(vValue)
{
	if (vValue = "U1")
		return "4.1.1.1.1.2.5.3" ;address bar
	if (vValue = "U2")
		return "4.1.1.1.1.2.5.3" ;address bar
	if (vValue = "T")
		return "4.1.1.1.1.1.1" ;tabs (append '.1' to get the first tab)
}
Works great, thank you!
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Firefox/Chrome, get tab names/focus tab

17 Feb 2022, 10:32

@AHKStudent (& friends) :)
Modern browsers evolve very rapidly. Thus this function is obsolete and does not provide the designed functionality anymore.
[...]
new path is 4.1.1.1.1.2.5.3
Chrome V. 92
I'm pretty sure to ignore the elephant in the room, but how can I identify that 'new path' number thing in Chrome (v98)? A tool? A script? A miracle?? :eh:

[Edit] Had a try with ACCViewer and was able to get a value that looks like "the one": 4.1.1.2.1.1.1.3. (where 3 is pointing to the third TAB in the row). Confirmed? :think:

PS. JFTR the path for the address bar is: 4.1.1.2.1.2.5.3 (Chrome v98)
User avatar
submeg
Posts: 328
Joined: 14 Apr 2017, 20:39
Contact:

Re: Firefox/Chrome, get tab names/focus tab

19 Feb 2022, 19:31

Is this still active / working? Trying to do a count of the chrome tabs:

Code: Select all


#SingleInstance, Force
#Include D:\AutoHotkey\Lib\Acc.ahk

;==================================================

#1::

If WinExist("ahk_class Chrome_WidgetWin_1")
{
	WinActivate
	Sleep, 25
	
	;https://www.autohotkey.com/docs/commands/WinGet.htm
	WinGet, ChromeID, ID, A
	
	;msgbox % "Chrome ID is: " ChromeID

	CountIs := JEE_ChromeGetTabCount(ChromeID)

	msgbox % "countIs: " CountIs
	
}	
else
{
	msgbox chrome not running...

}

return 

;==================================================
;==================================================

;https://www.autohotkey.com/boards/viewtopic.php?p=139114#p139114

;requires Acc.ahk:
;Acc library (MSAA) and AccViewer download links - AutoHotkey Community
;https://github.com/Drugoy/Autohotkey-scripts-.ahk/blob/master/Libraries/Acc.ahk
;==================================================

JEE_ChromeGetTabCount(hWnd)
{
	vCount := 0
	msgbox % "Chrome ID is: " hWnd
	
	oAcc := Acc_Get("Object", "4.1.2.2.2", 0, "ahk_id " hWnd)
	
	for _, oChild in Acc_Children(oAcc)
	{
		vTabText := oChild.accName(0)
		if !(vTabText == "") && !(vTabText == "New Tab")
		{
			
			vCount++
			msgbox Add
			
		}
	}
	oAcc := oChild := ""
	
	return vCount
	
}

;==================================================

JEE_ChromeGetTabNames(hWnd, vSep:="`n")
{
	oAcc := Acc_Get("Object", "4.1.2.2.2", 0, "ahk_id " hWnd)
	vOutput := ""
	for _, 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_Get("Object", "4.1.2.2.2", 0, "ahk_id " hWnd)
	if !Acc_Children(oAcc)[vNum+1]
		vNum := ""
	else
		Acc_Children(oAcc)[vNum+1].accDoDefaultAction(0)
	oAcc := ""
	return vNum
}

;==================================================

JEE_ChromeFocusTabByName(hWnd, vTitle, vNum:=1)
{
	oAcc := Acc_Get("Object", "4.1.2.2.2", 0, "ahk_id " hWnd)
	vCount := 0, vRet := 0
	for _, 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
}

;==================================================

I grabbed the acc.ahk library from HERE. No variable is being counted?
____________________________________
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey :ugeek:

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: jsong55 and 55 guests