Page 1 of 1

Cycle through chrome tabs until a specific one is found

Posted: 21 Jul 2023, 09:39
by Elermino
This script go to Chrome and cycle through the tabs until it finds a specified one (in this case YouTube), then send a command and return to the initial window.

Code: Select all

settitlematchmode, 2

^f1::
If Not WinExist("ahk_exe chrome.exe")
    Return
WinGetTitle, Title, A
WinActivate, ahk_class Chrome_WidgetWin_1
WinWaitActive, ahk_class Chrome_WidgetWin_1
Loop
{
    WinGetTitle, CurrentWindowTitle, ahk_class Chrome_WidgetWin_1
    If CurrentWindowTitle contains YouTube    ; The title of the Chrome tab to which the command is to be sent 
    {
       send {Space}    ;The command that is sent 
       break
    } else {
        Send, ^{Tab}
    }
}
WinActivate, %Title%
WinWaitActive, %Title%
Return

Re: Cycle through chrome tabs until a specific one is found

Posted: 23 Jul 2023, 11:16
by carno
Tested and works great!

Re: Cycle through chrome tabs until a specific one is found

Posted: 26 Jul 2023, 19:23
by Elermino
carno wrote:
23 Jul 2023, 11:16
Tested and works great!
Thanks :thumbup: