Browse chrome tabs looking for a specific one Topic is solved
Re: Browse chrome tabs looking for a specific one
@submeg, you can combine both loops in one:
Code: Select all
#IfWinExist ahk_exe chrome.exe
F3:: ; F3 = Get Chrome tab names and urls, and store them in a string
urlActiveField := Acc_Get("Object", "4.1.1.2.1.2.5.3")
loop 2
urlActiveField.accDoDefaultAction(0)
ActiveUrl := urlActiveField.accValue(0), urlActiveField := ""
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" (currentUrl := urlField.accValue(0))
if (currentUrl = ActiveUrl)
initialTab := oChild
}
initialTab.accDoDefaultAction(0)
MsgBox, 64, Tabs, %tabs%
Return
#IfWinExist
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.
Re: Browse chrome tabs looking for a specific one
Hey @amateur+, where do you get your acc library from? Just tried this and it returned a blank box; have a feeling that my code is old / incorrect.amateur+ wrote: ↑26 Feb 2022, 16:39@submeg, you can combine both loops in one:Code: Select all
#IfWinExist ahk_exe chrome.exe F3:: ; F3 = Get Chrome tab names and urls, and store them in a string urlActiveField := Acc_Get("Object", "4.1.1.2.1.2.5.3") loop 2 urlActiveField.accDoDefaultAction(0) ActiveUrl := urlActiveField.accValue(0), urlActiveField := "" 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" (currentUrl := urlField.accValue(0)) if (currentUrl = ActiveUrl) initialTab := oChild } initialTab.accDoDefaultAction(0) MsgBox, 64, Tabs, %tabs% Return #IfWinExist
____________________________________
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey
Re: Browse chrome tabs looking for a specific one
Hey @mikeyww , I tried this, but nothing happened. As above, I'm assuming it's my acc library is broken / outdated. Where can I find the latest / correct copy?
Edit: I've found the latest now, but all that happens is that it displays the name inside a msgbox. Is it supposed to activate the tab?
Last edited by submeg on 26 Feb 2022, 22:48, edited 1 time in total.
____________________________________
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey
Re: Browse chrome tabs looking for a specific one
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.
Re: Browse chrome tabs looking for a specific one
Thanks for confirming the correct file @amateur+.
@mikeyww, I ended up not using your suggestion; when I tried, it was just bringing up the title of the tab in a message box?
Please see below my code now. I realised that there are instances where the tab's name may have a pipe in it; had to eliminate those. Also I removed the name of the browser from the end of the tab, so that it could be used on other browsers.
The final step would be grabbing the actual URL as well and using that with the name in case you have multiple tabs with a similar name.
Code below:
What do you mean by that? The way I was visualising the code to work:
- Run code to find out all the tabs that are open.
- Box appears with the created list.
- Select which tab you wish to navigate to from the list.
@mikeyww, I ended up not using your suggestion; when I tried, it was just bringing up the title of the tab in a message box?
Please see below my code now. I realised that there are instances where the tab's name may have a pipe in it; had to eliminate those. Also I removed the name of the browser from the end of the tab, so that it could be used on other browsers.
The final step would be grabbing the actual URL as well and using that with the name in case you have multiple tabs with a similar name.
Code below:
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 WinActive("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
;To know when you've looped all the way around, save the name of the first title.
If (FirstTitle = "")
{
FirstTitle := TabTitle
;msgbox % "FirstTitle: `r`r" . FirstTitle
;Clean up the tab.
;1. Check for pipes.
If (InStr(FirstTitle, "|") > 0)
{
FirstTitle := StrReplace(FirstTitle, "|","_")
}
;2. Remove the name of the browser at the end.
;remove the name of the browser at the end.
FirstTitle := Trim(SubStr(FirstTitle,1, (StrLen(FirstTitle) - (StrLen(FirstTitle) - InStr(FirstTitle, "- Google Chrome") + 2)))) ;remove the hyphen and spaces too.
;msgbox % "FirstTitle: `r`r" . FirstTitle
}
;check for any pipes in the tab name
If (InStr(TabTitle, "|") > 0)
{
TabTitle := StrReplace(TabTitle, "|","_")
}
;remove the name of the browser at the end.
TabTitle := Trim(SubStr(TabTitle,1, (StrLen(TabTitle) - (StrLen(TabTitle) - InStr(TabTitle, "- Google Chrome") + 2))))
;msgbox % "First Title:`r" . FirstTitle . "`rTab Title:`r" . TabTitle
if (FirstTitle = TabTitle) And TabCount > 0 ;<- if a match we've looped back to the first one
break
TabCount++ ;<- otherwise count it
Sleep, 5
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
Send, {Ctrl up}
Send, {Shift up}
Send, {Tab up}
}
; 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 := ""
Send, {Ctrl up}
Send, {Shift up}
Send, {Tab up}
/*
;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
Send, {Ctrl up}
Send, {Shift up}
Send, {Tab up}
if (A_GuiEvent = "DoubleClick")
{
Gui, Submit, Hide ;Saves the GUI Control text double clicked to the LB variable 'guiSettingsHelpLB'
activateChromeTab(guiChromeTabSelectionLB)
;activateChromeTab2(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
;check for any pipes in the tab name
If (InStr(CurrentTitle, "|") > 0)
{
CurrentTitle := StrReplace(CurrentTitle, "|","_")
}
;remove the name of the browser at the end.
CurrentTitle := Trim(SubStr(CurrentTitle,1, (StrLen(CurrentTitle) - (StrLen(CurrentTitle) - InStr(CurrentTitle, "- Google Chrome") + 2))))
if (CurrentTitle = TabTitle) ;<- if a match we've looped back to the first one
break
send ^{tab} ;<- move to the next possible window
}
}
;=====================================================================================================
____________________________________
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey
Re: Browse chrome tabs looking for a specific one
You may create gui with titles+links. Link
And about your message to mikeyww, I think it may be reasonable for you to re-read the topic from the very beginning. Re-read carefully. And you'll understand what mikeyww meant in his recent post.
And about your message to mikeyww, I think it may be reasonable for you to re-read the topic from the very beginning. Re-read carefully. And you'll understand what mikeyww meant in his recent post.
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.
Re: Browse chrome tabs looking for a specific one
Thanks for the suggestion @amateur+, once I went back and re-read, I found that yes, it did take me directly to the tab, although, a blank messagebox was appearing. I realised that I had put the msgbox into Acc_Get! Fixing that, it now neatly activates the tab directly.
I could use a GUI with hyperlinks (great idea!), the only issue I could see is if a user has say 100 tabs open, the GUI may become so long it goes off the screen. At least with the ListBox, it has scroll bars and so you can scroll up and down to see all options. Any ideas on that front, or is a ListBox the best solution? With the ListBox option, I had replaced the pipe character with "_._" so that they only take up one line in the ListBox, so I reversed the conversion for it to work.
My code (which works), does the following:
- Cycles through all the open tabs and records their names; replacing "|" with "_._" and stripping the browser name from the title.
- Populates the listbox on the GUI with that list.
- When you double click one of the lines on the list, it takes you directly to that tab.
Also, does the ACC library / activateTab function only work with Chrome?
____________________________________
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey
Re: Browse chrome tabs looking for a specific one
Code: Select all
/* Chrome Tabs Menu ---------------------------------------------------------------------------------
This script displays a menu of Chrome tabs. The user selects a menu item. The tab is then activated.
For AutoHotkey 1.1.33.10 • By mikeyww on 27 February 2022
Required: acc.ahk • https://www.autohotkey.com/boards/viewtopic.php?f=6&t=26201
https://www.autohotkey.com/boards/viewtopic.php?p=448308#p448308
-----------------------------------------------------------------------------------------------------
*/
#Include D:\utils\acc.ahk
#IfWinExist ahk_exe chrome.exe
F3:: ; F3 = Display the menu of Chrome tabs
Try Menu, tabs, Delete
For each, oChild in Acc_Children(Acc_Get("Object", "4.1.1.2.1.1.1"))
Menu, tabs, Add, % oChild.accName(0), Activate ; Build the menu of tab names
Try Menu, tabs, Show
Return
#IfWinExist
Activate: ; Activate Chrome tab according to selected menu item
activateChromeTab(A_ThisMenuItem)
WinActivate, ahk_exe chrome.exe
Return
activateChromeTab(tabTitle) { ; https://www.autohotkey.com/boards/viewtopic.php?p=436429#p436429
For each, oChild in Acc_Children(Acc_Get("Object", TABS := "4.1.1.2.1.1.1",, "ahk_exe chrome.exe"))
If oChild.accName(0) = tabTitle
Return oChild.accDoDefaultAction(0)
}
Re: Browse chrome tabs looking for a specific one
Seems that there are some limitations.
Code: Select all
#Include D:\utils\acc.ahk
Links := "
(Join|
https://www.autohotkey.com/
https://www.autohotkey.com/docs/commands/Hotkey.htm
https://www.autohotkey.com/docs/commands/Hotkey.htm#Related
https://www.autohotkey.com/docs/commands/Hotkey.htm#ErrorLevel
https://www.autohotkey.com/docs/commands/Hotkey.htm#Remarks
https://www.autohotkey.com/docs/commands/Hotkey.htm#Examples
)"
loop, Parse, Links, |
run, Chrome.exe %A_LoopField%
return
#IfWinExist ahk_exe chrome.exe
F3:: ; F3 = Display the menu of Chrome tabs
Try Menu, tabs, Delete
For each, oChild in Acc_Children(Acc_Get("Object", "4.1.1.2.1.1.1"))
Menu, tabs, Add, % oChild.accName(0), Activate ; Build the menu of tab names
Try Menu, tabs, Show
Return
#IfWinExist
Activate: ; Activate Chrome tab according to selected menu item
activateChromeTab(A_ThisMenuItem)
WinActivate, ahk_exe chrome.exe
Return
activateChromeTab(tabTitle) { ; https://www.autohotkey.com/boards/viewtopic.php?p=436429#p436429
For each, oChild in Acc_Children(Acc_Get("Object", TABS := "4.1.1.2.1.1.1",, "ahk_exe chrome.exe"))
If oChild.accName(0) = tabTitle
Return oChild.accDoDefaultAction(0)
}
Have found any drawback in my code or approach? Please, point it out. /The moderator ordered to remove the rest of the signature, I had obeyed.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.
And I really apologize for our russian president. Being a citizen of an aggressor country is very shameful. Personally I tried to avoid this trying to defend elections from fraud being a member of the election commission of one of the precincts but only was subjected to a hooligan attack and right before the vote count was illegally escorted from the polling station and spent the night behind bars (in jail) in a result of illegal actions of corrupt policemen.
Re: Browse chrome tabs looking for a specific one
Yes, the approach just uses the tab title. It would need adjusting for duplicates, etc.
Re: Browse chrome tabs looking for a specific one
Is there any way around duplicates? If the title and the url are the same, are there any other identifiers that are different? Do browsers give each tab an ID number / handle?
@mikeyww, that's very cool. Damn, I wish I had that level of coding skill. Thank you for this; would love to know if there's any way to differentiate between two tabs with the same name.
@mikeyww, that's very cool. Damn, I wish I had that level of coding skill. Thank you for this; would love to know if there's any way to differentiate between two tabs with the same name.
____________________________________
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey
Re: Browse chrome tabs looking for a specific one
I actually find Acc not very straightforward to use! For me, it is a lot of trial and error.
There might be a way to get at leftmost vs. rightmost tabs. I guess the first question before getting to that point is how you would describe your approach to distinguishing the tabs yourself. In your mind, what is the difference between the tabs, and how would you describe the tab that you want to identify?
There might be a way to get at leftmost vs. rightmost tabs. I guess the first question before getting to that point is how you would describe your approach to distinguishing the tabs yourself. In your mind, what is the difference between the tabs, and how would you describe the tab that you want to identify?
Re: Browse chrome tabs looking for a specific one
There's no comments, so I have no idea what's going on!!
Thinking about it again, if it's the exact same URL, does it really matter? The subsequent versions are pretty much superfluous.mikeyww wrote: ↑27 Feb 2022, 19:09There might be a way to get at leftmost vs. rightmost tabs. I guess the first question before getting to that point is how you would describe your approach to distinguishing the tabs yourself. In your mind, what is the difference between the tabs, and how would you describe the tab that you want to identify?
____________________________________
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey
Re: Browse chrome tabs looking for a specific one
Exactly my thinking!
EDIT: Acc path to tabs in Google Chrome version 100.0.4896.60: 4.1.1.2.1.1.1.1
EDIT: Acc path to tabs in Google Chrome version 100.0.4896.60: 4.1.1.2.1.1.1.1
Re: Browse chrome tabs looking for a specific one
Just FYI: Please see below my working script.
What it does (in Chrome):
script:
What it does (in Chrome):
- Goes to the first tab
- Collates all the open tabs
- Displays a list box of all the tab names
script:
Code: Select all
#SingleInstance Force
#Include D:\AutoHotkey\Compiler\!TESTING\TabSelect\Acc.ahk ; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=26201
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
;==================================================
;--------------------------------------------------
- & =::
TabCount := 0
FirstTitle := ""
TabTitle := ""
sListBox := ""
If WinExist("ahk_class Chrome_WidgetWin_1")
{
;Go to the start of the tabs.
Send, ^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 := ""
;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
}
}
;=====================================================================================================
____________________________________
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey
Re: Browse chrome tabs looking for a specific one
I am having trouble trying to incorporate this into my "main script"...bugs:
@mikeyww, any ideas on what I should look at? As I mentioned it runs fine as a stand alone, but if I try and call it, it just returns one line and if I select it, tab is being held down...
My main script:
The actual function(s):
- Shows only one tab
- Doesn't cycle to any tab
- The tab key is held down
@mikeyww, any ideas on what I should look at? As I mentioned it runs fine as a stand alone, but if I try and call it, it just returns one line and if I select it, tab is being held down...
My main script:
Code: Select all
#Include Lib\acc.ahk ;For use with working with Chrome tabs.
...
;Define variables
global TabCount := 0 ;Counts how many tabs are open in a chrome instance.
global guiSettingsHelpbClose := "" ;Received an error saying variables need to be global...
...
;-------------------------------------------------------------
NumpadEnd & NumpadSub::
KeyWait NumpadEnd
Hotkey, ^Tab, off ;I have a hotkey on this combination
ChromeActions_TabSelect()
Hotkey, ^Tab, on
fUpdateCSV("ChromeActions_TabSelect") ;Used to record when I trigger hotkeys
Return
;-------------------------------------------------------------
The actual function(s):
Code: Select all
;----------------------------------------------------------------------------
ChromeActions_TabSelect()
{
If WinExist("ahk_class Chrome_WidgetWin_1")
{
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
FirstTitle := ""
TabTitle := ""
sListBox := ""
;Go to the start of the tabs.
Sleep, 250
Send, ^1
Sleep, 500
;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 := ""
;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
{
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 'guiChromeTabSelectionLB'
activateChromeTab(guiChromeTabSelectionLB)
;Reset keys.
SendInput, {Tab up}
SendInput, {LCtrl up}
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
FirstTitle := ""
TabTitle := ""
sListBox := ""
}
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
Sleep, 25
}
}
;----------------------------------------------------------------------------
____________________________________
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey
Re: Browse chrome tabs looking for a specific one
I'm afraid not!
Re: Browse chrome tabs looking for a specific one
No worries @mikeyww, I was able to sit down and work through it until I figured it out. Had a couple wonky variables, and it was having issues with any tab name that had a pipe in it. Please see below the working (on my PC, yet to test on a second device) script.
Triggering with Hotkey:
Code: Select all
;-------------------------------------------------------------
#F1::
ChromeActions_TabSelect()
Return
;-------------------------------------------------------------
Code: Select all
;----------------------------------------------------------------------------
ChromeActions_TabSelect()
{
;Create a string array.
TabArray := [] ;A way to store the tab names in an array. Not used, left for learning.
iListBoxNumRows := 10 ;How many tabs to display in the ListBox
;https://www.autohotkey.com/docs/Variables.htm#assigning
TabCount := 0 ;How many tabs there are
FirstTitle := "" ;The title of the first tab
TabTitle := "" ;The title of the tab you are currently reviewing
sListBox := "" ;The list of all open tabs
PipePos := 0 ;Used to convert | to <> and back again
If WinExist("ahk_class Chrome_WidgetWin_1")
{
;--------------------------------------------------
;FIRST TAB
;Go to the start of the tabs.
Send, ^1
Sleep, 25
;Grab the name of the first tab.
WinGetTitle, FirstTitle, A ;<- first get the title
;Check tab title for |
PipePos := InStr(FirstTitle, "|")
If PipePos != 0
{
FirstTitle := StrReplace(FirstTitle, "|" , "<>")
;Reset pipe search.
PipePos := 0
;Go to the next window.
}
TabCount++ ;count it
;Add the title to the list.
TabArray[TabCount] := FirstTitle
sListBox := sListBox . FirstTitle . "|"
send ^{tab} ;<- move to the next possible window
;--------------------------------------------------
;--------------------------------------------------
;OTHER TABS
;https://www.autohotkey.com/board/topic/118664-count-open-tabs-in-chrome-browser/#entry678852
Loop
{
;Reset pipe search.
PipePos := 0
WinGetTitle, TabTitle, A ;<- first get the title
;Check tab title for |
PipePos := InStr(TabTitle, "|")
If PipePos != 0
{
TabTitle := StrReplace(TabTitle, "|" , "<>")
;Reset pipe search.
PipePos := 0
}
if (TabTitle = FirstTitle) ;<- if a match we've looped back to the first one
break
TabCount++ ;<- otherwise count it
TabArray[TabCount] := TabTitle
sListBox := sListBox . TabTitle . "|"
send ^{tab} ;<- move to the next possible window
}
;Reset variables.
FirstTitle := "" ;The title of the first tab
TabTitle := "" ;The title of the tab you are currently reviewing
PipePos := 0 ;Used to convert | to <> and back again
;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 gguiChromeTabSelection, Close
Gui, ChromeTabSelection:Show, w520 h250
}
}
Return
;----------------------------------------------------------------------------
guiChromeTabSelection: ;Close Button
{
;Reset variables.
TabCount := 0
FirstTitle := ""
TabTitle := ""
sListBox := ""
;Make sure no keys are stuck.
Send, {Ctrl up}
Send, {Tab up}
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'
;If there's <> in the title, convert it back to a pipe.
;Check tab title for |
PipePos := InStr(guiChromeTabSelectionLB, "<>")
If PipePos != 0
{
guiChromeTabSelectionLB := StrReplace(guiChromeTabSelectionLB, "<>" , "|")
;Reset pipe search.
PipePos := 0
}
;Activate the chrome tab.
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
}
;Make sure no keys are stuck.
Send, {Ctrl up}
Send, {Tab up}
}
;----------------------------------------------------------------------------
;============================================================================
____________________________________
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey
Check out my site, submeg.com
Connect with me on LinkedIn
Courses on AutoHotkey
Who is online
Users browsing this forum: Google [Bot] and 67 guests