Cycle through chrome tabs until a specific one is found
Posted: 21 Jul 2023, 09:39
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