amateur+ wrote: ↑20 Feb 2022, 12:55
@submeg, if you really want to grab Title+url, you can use this combination of maestro's codes:
Code: Select all
#IfWinExist ahk_exe chrome.exe
F3:: ; F3 = Get Chrome tab names and urls, and store them in a string
VarSetCapacity(tabs, 2048)
For each, oChild in Acc_Children(Acc_Get("Object", "4.1.1.2.1.1.1")) {
tabs .= (tabs > "" ? "`n`n" : "") oChild.accName(0)
oChild.accDoDefaultAction(0)
urlField := Acc_Get("Object", "4.1.1.2.1.2.5.3")
loop 2
urlField.accDoDefaultAction(0)
tabs .= "`n" urlField .accValue(0)
}
MsgBox, 64, Tabs, %tabs%
Return
#IfWinExist
EDIT: Added these lines to grab url with
https://(www.):
Code: Select all
urlField := Acc_Get("Object", "4.1.1.2.1.2.5.3")
loop 2
urlField.accDoDefaultAction(0)
Thanks
@amateur+, I ended up doing something very similar.
Now the only question is, how can I reactivate a particular tab?
EDIT:I just reused the code that populates the list box to cycle through until it finds the correct tab as opposed to the first tab. Is there a way to go
directly to a tab without cycling a second time?
Code: Select all
#SingleInstance, Force
Menu, Tray, Icon, % A_WinDir "\system32\netshell.dll", 86 ; Shows a world icon in the system tray
TabCount := 0 ;To count how many tabs there are.
;Create a string array.
TabArray := [] ;A way to store the tab names in an array. Not used, left for learning.
sListOfTabs := ""
iListBoxNumRows := 10 ;How many tabs to display in the ListBox
;==================================================
;--------------------------------------------------
#1::
TabCount := 0
FirstTitle := ""
TabTitle := ""
sListBox := ""
If WinExist("ahk_class Chrome_WidgetWin_1")
{
;https://www.autohotkey.com/board/topic/118664-count-open-tabs-in-chrome-browser/#entry678852
Loop
{
WinGetTitle, TabTitle, A ;<- first get the title
FirstTitle := Titl1 ;<- and see if it matches the first window checked
if (FirstTitle = TabTitle) ;<- if a match we've looped back to the first one
break
TabCount++ ;<- otherwise count it
titl%A_Index% = %TabTitle% ;<- save it's title
TabArray[TabCount] := TabTitle
sListBox := sListBox . TabTitle . "|"
;msgbox,0x1000,%A_LineNumber%,%vwintitl% ;<- and show the name
send ^{tab} ;<- move to the next possible window
}
; show how many tabs were found
;msgbox,0x1000,%A_LineNumber%,there are %TabCount% tabs in this chrome browser
;Reset variables.
TabTitle := ""
Titl1 := ""
x := 1
TabString := ""
/*
;Put all the values into a string array.
;NOTE: This is not used, leaving for learning / notes
Loop
{
if (x = (TabCount+1)) ;<- if a match we've looped back to the first one
break
TabString := TabString . "• " . TabArray[x] . "`r"
x++ ;<- otherwise count it
}
;msgbox % TabString
*/
;Build the List Box Window
Gui, ChromeTabSelection:New, -Caption +LastFound +AlwaysOnTop,Double Click to select tab ;Titled Double Click Option
Gui, ChromeTabSelection:Font, s11 Calibra ;Add user instructions with formatting
Gui, ChromeTabSelection:Font, Bold
Gui, ChromeTabSelection:Add, Text, ,Double Click
Gui, ChromeTabSelection:Font, Normal
Gui, ChromeTabSelection:Add, Text, yp x+5, to open the selected tab
Gui, ChromeTabSelection:Add, ListBox, x10 W500 h400 r%iListBoxNumRows% vguiChromeTabSelectionLB gguiChromeTabSelectionListBox multi, %sListBox%
Gui, ChromeTabSelection:Add, Button , x230 y210 vguiSettingsHelpbClose gguiChromeTabSelection, Close
Gui, ChromeTabSelection:Show, w520 h250
}
Return
;----------------------------------------------------------------------------
guiChromeTabSelection: ;Close Button
{
;Reset variables.
TabCount := 0
FirstTitle := ""
TabTitle := ""
sListBox := ""
Gui, ChromeTabSelection:Destroy
}
return
guiChromeTabSelectionListBox:
SetTitleMatchMode, 2
if (A_GuiEvent = "DoubleClick")
{
Gui, Submit, Hide ;Saves the GUI Control text double clicked to the LB variable 'guiSettingsHelpLB'
activateChromeTab(guiChromeTabSelectionLB)
}
return
;=====================================================================================================
;=====================================================================================================
activateChromeTab(TabTitle) {
;https://www.autohotkey.com/board/topic/118664-count-open-tabs-in-chrome-browser/#entry678852
Loop
{
WinGetTitle, CurrentTitle, A ;<- first get the title
if (CurrentTitle = TabTitle) ;<- if a match we've looped back to the first one
break
send ^{tab} ;<- move to the next possible window
}
}
;=====================================================================================================