Cycle through chrome tabs until a specific one is found

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
Elermino
Posts: 114
Joined: 29 Nov 2021, 17:43

Cycle through chrome tabs until a specific one is found

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
Last edited by Elermino on 27 Jul 2023, 09:27, edited 1 time in total.
carno
Posts: 265
Joined: 20 Jun 2014, 16:48

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

23 Jul 2023, 11:16

Tested and works great!
User avatar
Elermino
Posts: 114
Joined: 29 Nov 2021, 17:43

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

26 Jul 2023, 19:23

carno wrote:
23 Jul 2023, 11:16
Tested and works great!
Thanks :thumbup:

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 87 guests