Firefox/Chrome, get tab names/focus tab

Post your working scripts, libraries and tools
User avatar
jeeswg
Posts: 6819
Joined: 19 Dec 2016, 01:58
Location: UK

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

03 Oct 2018, 15:45

@Pikoloco: The new functions might work, otherwise the old functions might work, otherwise you could try to modify them.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Johnny R
Posts: 261
Joined: 03 Oct 2013, 02:07

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

04 Oct 2018, 01:16

Hallo jeeswg!
how to change "x.x.x.x.x"? "4.1.2.2.1" (for Chrome) doesn't work for Firefox v54.0.1, too. Your script https://autohotkey.com/boards/viewtopic.php?f=6&t=40615 works for notepad.
Thank You!
User avatar
jeeswg
Posts: 6819
Joined: 19 Dec 2016, 01:58
Location: UK

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

10 Oct 2018, 05:35

I've added 2 functions to get the index of the focused tab, here:
Firefox/Chrome, get tab names/focus tab - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 12#p241912

JEE_FirefoxGetFocusedTabNum(hWnd)
JEE_ChromeGetFocusedTabNum(hWnd)
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
nallan
Posts: 5
Joined: 16 Dec 2018, 00:50

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

16 Dec 2018, 00:58

Hi
I'm having an issue getting the JEE_ChromeFocusTabByName function working in google chrome 71. As far as I can tell it looks like the
oChild.accDoDefaultAction(0)
line isn't working. Has anyone else had this issue. I wonder if chrome broke the dodefaultaction on the tab to click it?
User avatar
jeeswg
Posts: 6819
Joined: 19 Dec 2016, 01:58
Location: UK

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

19 Dec 2018, 20:15

- @nallan: Hello, do you manually or automatically update? My Chrome just updated to v71, and I had the same problem as you.
- I fixed the functions by replacing 4.1.2.2.1 with 4.1.2.1.1. I used this script to give me the numbers:
Acc: get text from all window/control elements - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=40615

- Here are functions to get the url for the active tab from Firefox/Chrome. Note: I can only get the url for the active tab, the urls for other tabs are not made available via Acc. (Note: the Firefox function is old, I haven't looked at it in a long time.)

Code: Select all

JEE_FirefoxGetUrl(hWnd, vOpt:="")
{
	local
	Loop, 10
	{
		vIndex := A_Index
		vAccPath := "application.tool_bar3.combo_box1.editable_text"
		;vAccPath := "4.25.3.2"
		if InStr(vOpt, "p") ;(pop-up window)
			vAccPath := "application.tool_bar1.combo_box1.editable_text"
		oAcc := Acc_Get("Object", vAccPath, 0, "ahk_id " hWnd)
		if !ErrorLevel
			break
		Sleep, 100
	}
	if (vIndex = 10)
		return

	vUrl := ""
	try vUrl := oAcc.accValue(0)
	oAcc := ""
	if !(vUrl = "") && !InStr(vUrl, "://")
		vUrl := "http://" vUrl
	return vUrl
}

Code: Select all

;acc path: 4.1.2.2.2.5.2
;acc path: 4.1.2.1.2.5.2
JEE_ChromeGetUrl(hWnd, vOpt:="")
{
	local
	oAcc := Acc_Get("Object", "4.1.2.2.2.5.2", 0, "ahk_id " hWnd)
	if !IsObject(oAcc)
	|| !(oAcc.accName(0) = "Address and search bar")
		oAcc := Acc_Get("Object", "4.1.2.1.2.5.2", 0, "ahk_id " hWnd)
	vUrl := oAcc.accValue(0)
	oAcc := ""
	return vUrl
}
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
AHKStudent
Posts: 576
Joined: 05 May 2018, 12:23

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

04 Jan 2019, 17:50

Every update of Chrome (68 69 70 71) The numbers change.

Is there a way to know what the new numbers are without manually updating scripts?
20170201225639
Posts: 28
Joined: 01 Feb 2017, 22:57

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

01 Aug 2019, 13:36

The current path to use for getting tab counts in chrome (version 75) is: "4.1.2.1.1.1":

updated version:


Code: Select all

; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=26947
JEE_ChromeGetTabCount(hWnd){
	oAcc := Acc_Get("Object", "4.1.2.1.1.1", 0, "ahk_id " hWnd)
	for _, oChild in Acc_Children(oAcc)
	{
		vTabText := oChild.accName(0)
		if !(vTabText == "")
		&& !(vTabText == "New Tab")
			vCount++
	}
	oAcc := oChild := ""
	return vCount
}
potroveio
Posts: 8
Joined: 17 Sep 2019, 13:45

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

27 Sep 2019, 13:40

how to invoke this function to show open tabs in Chrome on a tooltip when a hotkey is pressed?

thanks!

Martin
potroveio
Posts: 8
Joined: 17 Sep 2019, 13:45

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

29 Sep 2019, 12:01

Code: Select all

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

JEE_ChromeGetFocusedTabNum(hWnd)
{
	oAcc := Acc_Get("Object", "4.1.2.2.1", 0, "ahk_id " hWnd)
	vRet := 0
	for _, oChild in Acc_Children(oAcc)
	{
		;STATE_SYSTEM_SELECTED := 0x2
		if (oChild.accState(0) & 0x2)
		{
			vRet := A_Index
			break
		}
	}
	oAcc := oChild := ""
	return vRet
}

Many thanks for these helfpul function - somehow I get tab number "0" for any tab on Chrome 77... any hints on how can I fix it? thanks!
User avatar
jeeswg
Posts: 6819
Joined: 19 Dec 2016, 01:58
Location: UK

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

29 Sep 2019, 18:35

- Hello potroveio! I've updated the Chrome functions to work with v77.
- I've also added a few functions.
- [EDIT: 2019-10-01] And added Firefox equivalents that work with v69.
- Note: JEE_ChromeAccInit is where I now store the Acc paths, so if the Acc paths change again in future, you'll only have to change the paths inside that one function.
- Note: to use the functions with AHK versions pre-v1.1.27, remove the 'local' keyword in each function.

Code: Select all

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

;Firefox functions suite (tested on Firefox v69):

;requires Acc.ahk:
;Acc library (MSAA) and AccViewer download links - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=6&t=26201

;JEE_FirefoxAccInit(vValue)
;JEE_FirefoxGetUrl(hWnd:="", vOpt:="")
;JEE_FirefoxGetTabCount(hWnd:="")
;JEE_FirefoxGetTabNames(hWnd:="", vSep:="`n")
;JEE_FirefoxFocusTabByNum(hWnd:="", vNum:="")
;JEE_FirefoxFocusTabByName(hWnd:="", vTitle:="", vNum:="")
;JEE_FirefoxGetFocusedTabNum(hWnd:="")
;JEE_FirefoxAddressBarIsFoc(hWnd:="")
;JEE_FirefoxCloseOtherTabs(hWnd:="", vOpt:="", vNum:="")

;warning: JEE_FirefoxCloseOtherTabs:
;there is no separate Close button Acc element to do accDoDefaultAction on,
;so at present, each tab is focused, and Ctrl+W is sent to it, which is unreliable

;note: you can only get the url for the *active* tab via Acc,
;to get the urls for other tabs, you could use a browser extension, see:
;Firefox/Chrome: copy titles/urls to the clipboard - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=22&t=66246

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

;note: this function is redundant
;note: an equivalent function is needed for Chrome
JEE_FirefoxAccInit(vValue)
{
	local
}

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

JEE_FirefoxGetUrl(hWnd:="", vOpt:="")
{
	local
	if (hWnd = "")
		hWnd := WinExist("A")
	Loop 10
	{
		vIndex := A_Index
		vAccPath := "application.tool_bar3.combo_box1.editable_text"
		;vAccPath := "4.25.3.2"
		if InStr(vOpt, "p") ;(pop-up window)
			vAccPath := "application.tool_bar1.combo_box1.editable_text"
		oAcc := Acc_Get("Object", vAccPath, 0, "ahk_id " hWnd)
		if !ErrorLevel
			break
		;Sleep(100)
		DllCall("kernel32\Sleep", "UInt",100)
	}
	if (vIndex = 10)
		return

	vUrl := ""
	try vUrl := oAcc.accValue(0)
	oAcc := ""

	if InStr(vOpt, "x")
	{
		if !(vUrl = "") && !InStr(vUrl, "://")
			vUrl := "http://" vUrl
	}
	return vUrl
}

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

JEE_FirefoxGetTabCount(hWnd:="")
{
	local
	if (hWnd = "")
		hWnd := WinExist("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
	}

	vCount := 0
	for _, oChild in Acc_Children(oAcc)
	{
		;ROLE_SYSTEM_PUSHBUTTON := 0x2B
		if (oChild.accRole(0) = 0x2B)
			continue
		vCount++
	}
	oAcc := oChild := ""
	return vCount
}

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

JEE_FirefoxGetTabNames(hWnd:="", vSep:="`n")
{
	local
	if (hWnd = "")
		hWnd := WinExist("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
	}

	vHasSep := !(vSep = "")
	if vHasSep
		vOutput := ""
	else
		oOutput := []
	for _, oChild in Acc_Children(oAcc)
	{
		;ROLE_SYSTEM_PUSHBUTTON := 0x2B
		if (oChild.accRole(0) = 0x2B)
			continue
		try vTabText := oChild.accName(0)
		catch
			vTabText := ""
		if vHasSep
			vOutput .= vTabText vSep
		else
			oOutput.Push(vTabText)
	}
	oAcc := oChild := ""
	return vHasSep ? SubStr(vOutput, 1, -StrLen(vSep)) : oOutput
}

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

JEE_FirefoxFocusTabByNum(hWnd:="", vNum:="")
{
	local
	if (hWnd = "")
		hWnd := WinExist("A")
	if !vNum
		return
	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 || !Acc_Children(oAcc)[vNum]
		vNum := ""
	else
		Acc_Children(oAcc)[vNum].accDoDefaultAction(0)
	oAcc := oChild := ""
	return vNum
}

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

JEE_FirefoxFocusTabByName(hWnd:="", vTitle:="", vNum:="")
{
	local
	if (hWnd = "")
		hWnd := WinExist("A")
	if (vNum = "")
		vNum := 1
	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
	}

	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
}

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

JEE_FirefoxGetFocusedTabNum(hWnd:="")
{
	local
	if (hWnd = "")
		hWnd := WinExist("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
			break
		}
	}
	oAcc := oChild := ""
	return vRet
}

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

JEE_FirefoxAddressBarIsFoc(hWnd:="")
{
	local
	if (hWnd = "")
		hWnd := WinExist("A")
	oAcc := Acc_Get("Object", "4", 0, "ahk_id " hWnd)
	vRet := 0
	for _, oChild in Acc_Children(oAcc)
	{
		if (oChild.accName(0) == "Navigation Toolbar")
			oAcc := oChild, vRet := 1
	}
	if !vRet
	{
		oAcc := oChild := ""
		return
	}

	oAcc := Acc_Children(oAcc).6
	oAcc := Acc_Children(oAcc).2
	;STATE_SYSTEM_FOCUSED := 0x4
	vIsFoc := !!(oAcc.accState(0) & 0x4)
	oAcc := oChild := ""
	return vIsFoc
}

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

;vOpt: L (close tabs to the left)
;vOpt: R (close tabs to the right)
;vOpt: LR (close other tabs)
;vOpt: (blank) (close other tabs)
;vNum: specify a tab other than the focused tab
JEE_FirefoxCloseOtherTabs(hWnd:="", vOpt:="", vNum:="")
{
	local
	if (hWnd = "")
		hWnd := WinExist("A")
	;vWinClass := WinGetClass("ahk_id " hWnd)
	WinGetClass, vWinClass, % "ahk_id " hWnd
	if !(vWinClass = "MozillaWindowClass")
		return
	if (vNum = "")
		vNum := JEE_FirefoxGetFocusedTabNum(hWnd)
	if (vOpt = "")
		vOpt := "LR"
	vDoCloseLeft := !!InStr(vOpt, "L")
	vDoCloseRight := !!InStr(vOpt, "R")

	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
	oChildren := Acc_Children(oAcc)
	vIndex := oChildren.Length() + 1
	Loop % vIndex - 1
	{
		vIndex--
		oChild := oChildren[vIndex]
		;ROLE_SYSTEM_PUSHBUTTON := 0x2B
		try
		{
			if (oChild.accRole(0) = 0x2B)
				continue
		}
		if (vIndex = vNum)
			continue
		if (vIndex > vNum) && !vDoCloseRight
			continue
		if (vIndex < vNum) && !vDoCloseLeft
			continue
		;note: cf. Chrome, Firefox doesn't have a separate Close button element
		;oChild2 := Acc_Children(oChild).4
		;if (oChild2.accName(0) = "Close")
		;	oChild2.accDoDefaultAction(0)
		;oChild2 := ""
		;instead we focus each tab and send Ctrl+W to it
		JEE_FirefoxFocusTabByNum(hWnd, vIndex)
		;Sleep(500)
		DllCall("kernel32\Sleep", "UInt",500)
		;ControlSend("{Ctrl down}w{Ctrl up}",, "ahk_id " hWnd)
		ControlSend, ahk_parent, {Ctrl down}w{Ctrl up}, % "ahk_id " hWnd
	}
	oAcc := oChild := ""
	return vRet
}

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

Code: Select all

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

;Chrome functions suite (tested on Chrome v77):

;requires Acc.ahk:
;Acc library (MSAA) and AccViewer download links - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=6&t=26201

;JEE_ChromeAccInit(vValue)
;JEE_ChromeGetUrl(hWnd:="", vOpt:="")
;JEE_ChromeGetTabCount(hWnd:="")
;JEE_ChromeGetTabNames(hWnd:="", vSep:="`n")
;JEE_ChromeFocusTabByNum(hWnd:="", vNum:="")
;JEE_ChromeFocusTabByName(hWnd:="", vTitle:="", vNum:="")
;JEE_ChromeGetFocusedTabNum(hWnd:="")
;JEE_ChromeAddressBarIsFoc(hWnd:="")
;JEE_ChromeCloseOtherTabs(hWnd:="", vOpt:="", vNum:="")

;note: you can only get the url for the *active* tab via Acc,
;to get the urls for other tabs, you could use a browser extension, see:
;Firefox/Chrome: copy titles/urls to the clipboard - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=22&t=66246

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

;note: these Acc paths often change:
;Acc paths determined via:
;[JEE_AccGetTextAll function]
;Acc: get text from all window/control elements - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=6&t=40615

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)
}

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

JEE_ChromeGetUrl(hWnd:="", vOpt:="")
{
	local
	static vAccPath1 := JEE_ChromeAccInit("U1")
	static vAccPath2 := JEE_ChromeAccInit("U2")
	if (hWnd = "")
		hWnd := WinExist("A")
	oAcc := Acc_Get("Object", vAccPath1, 0, "ahk_id " hWnd)
	if !IsObject(oAcc)
	|| !(oAcc.accName(0) = "Address and search bar")
		oAcc := Acc_Get("Object", vAccPath2, 0, "ahk_id " hWnd)
	vUrl := oAcc.accValue(0)
	oAcc := ""

	if InStr(vOpt, "x")
	{
		if !(vUrl = "") && !InStr(vUrl, "://")
			vUrl := "http://" vUrl
	}
	return vUrl
}

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

JEE_ChromeGetTabCount(hWnd:="")
{
	local
	static vAccPath := JEE_ChromeAccInit("T")
	if (hWnd = "")
		hWnd := WinExist("A")
	oAcc := Acc_Get("Object", vAccPath, 0, "ahk_id " hWnd)
	vCount := 0
	for _, oChild in Acc_Children(oAcc)
	{
		;ROLE_SYSTEM_PUSHBUTTON := 0x2B
		if (oChild.accRole(0) = 0x2B)
			continue
		vCount++
	}
	oAcc := oChild := ""
	return vCount
}

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

JEE_ChromeGetTabNames(hWnd:="", vSep:="`n")
{
	local
	static vAccPath := JEE_ChromeAccInit("T")
	if (hWnd = "")
		hWnd := WinExist("A")
	oAcc := Acc_Get("Object", vAccPath, 0, "ahk_id " hWnd)

	vHasSep := !(vSep = "")
	if vHasSep
		vOutput := ""
	else
		oOutput := []
	for _, oChild in Acc_Children(oAcc)
	{
		;ROLE_SYSTEM_PUSHBUTTON := 0x2B
		if (oChild.accRole(0) = 0x2B)
			continue
		try vTabText := oChild.accName(0)
		catch
			vTabText := ""
		if vHasSep
			vOutput .= vTabText vSep
		else
			oOutput.Push(vTabText)
	}
	oAcc := oChild := ""
	return vHasSep ? SubStr(vOutput, 1, -StrLen(vSep)) : oOutput
}

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

JEE_ChromeFocusTabByNum(hWnd:="", vNum:="")
{
	local
	static vAccPath := JEE_ChromeAccInit("T")
	if (hWnd = "")
		hWnd := WinExist("A")
	if !vNum
		return
	oAcc := Acc_Get("Object", vAccPath, 0, "ahk_id " hWnd)
	if !Acc_Children(oAcc)[vNum]
		vNum := ""
	else
		Acc_Children(oAcc)[vNum].accDoDefaultAction(0)
	oAcc := ""
	return vNum
}

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

JEE_ChromeFocusTabByName(hWnd:="", vTitle:="", vNum:="")
{
	local
	static vAccPath := JEE_ChromeAccInit("T")
	if (hWnd = "")
		hWnd := WinExist("A")
	if (vNum = "")
		vNum := 1
	oAcc := Acc_Get("Object", vAccPath, 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
}

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

JEE_ChromeGetFocusedTabNum(hWnd:="")
{
	local
	static vAccPath := JEE_ChromeAccInit("T")
	if (hWnd = "")
		hWnd := WinExist("A")
	oAcc := Acc_Get("Object", vAccPath, 0, "ahk_id " hWnd)
	vRet := 0
	for _, oChild in Acc_Children(oAcc)
	{
		;STATE_SYSTEM_SELECTED := 0x2
		if (oChild.accState(0) & 0x2)
		{
			vRet := A_Index
			break
		}
	}
	oAcc := oChild := ""
	return vRet
}

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

JEE_ChromeAddressBarIsFoc(hWnd:="")
{
	local
	static vAccPath1 := JEE_ChromeAccInit("U1")
	static vAccPath2 := JEE_ChromeAccInit("U2")
	if (hWnd = "")
		hWnd := WinExist("A")
	oAcc := Acc_Get("Object", vAccPath1, 0, "ahk_id " hWnd)
	if !IsObject(oAcc)
	|| !(oAcc.accName(0) = "Address and search bar")
		oAcc := Acc_Get("Object", vAccPath2, 0, "ahk_id " hWnd)
	;STATE_SYSTEM_FOCUSED := 0x4
	vIsFoc := !!(oAcc.accState(0) & 0x4)
	oAcc := ""
	return vIsFoc
}

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

;vOpt: L (close tabs to the left)
;vOpt: R (close tabs to the right)
;vOpt: LR (close other tabs)
;vOpt: (blank) (close other tabs)
;vNum: specify a tab other than the focused tab
JEE_ChromeCloseOtherTabs(hWnd:="", vOpt:="", vNum:="")
{
	local
	static vAccPath := JEE_ChromeAccInit("T")
	if (hWnd = "")
		hWnd := WinExist("A")
	if (vNum = "")
		vNum := JEE_ChromeGetFocusedTabNum(hWnd)
	if (vOpt = "")
		vOpt := "LR"
	vDoCloseLeft := !!InStr(vOpt, "L")
	vDoCloseRight := !!InStr(vOpt, "R")

	oAcc := Acc_Get("Object", vAccPath, 0, "ahk_id " hWnd)
	vRet := 0
	oChildren := Acc_Children(oAcc)
	vIndex := oChildren.Length() + 1
	Loop % vIndex - 1
	{
		vIndex--
		oChild := oChildren[vIndex]
		;ROLE_SYSTEM_PUSHBUTTON := 0x2B
		if (oChild.accRole(0) = 0x2B)
			continue
		if (vIndex = vNum)
			continue
		if (vIndex > vNum) && !vDoCloseRight
			continue
		if (vIndex < vNum) && !vDoCloseLeft
			continue
		oChild2 := Acc_Children(oChild).4
		if (oChild2.accName(0) = "Close")
			oChild2.accDoDefaultAction(0)
		oChild2 := ""
	}
	oAcc := oChild := ""
	return vRet
}

;==================================================
Last edited by jeeswg on 01 Oct 2019, 13:31, edited 3 times in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
potroveio
Posts: 8
Joined: 17 Sep 2019, 13:45

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

30 Sep 2019, 06:19

Lovely, many thanks, jeeswg! GetTabNum tested and working on Chrome 77 :)
Conrad
Posts: 1
Joined: 01 Nov 2019, 18:22

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

01 Nov 2019, 19:22

I'm currently using the firefox functions to add media key support in youtube music. However, when I use focustab and ControlSend when firefox is not the active window, it does not send the keystroke to the new tab. It just sends it to the original tab. Here is what I have.

Code: Select all

  
  JEE_FirefoxFocusTabByName(FF, TabName)
  Sleep 200
  ControlSend, ahk_parent, {%Key%}, ahk_class MozillaWindowClass
  JEE_FirefoxFocusTabByName(FF, CurrentTitle)
In this case %Key% is "Space" to play/pause

It works as intended when firefox is the active window. Does anyone know how to fix this?

Return to “Scripts and Functions”

Who is online

Users browsing this forum: AHK_user, Antoine, burque505, Google [Bot], guest3456 and 37 guests