JulienBoul

Chrome - Switch multiple tab

4 posts in this topic

Hi,

it's my first message about autoit, i'm realy newbie and realy bad english speaker... Nothing for the win... :-/ lol

I have 3 tabs on my Chrome browser.
I Have found this code (thx to Dan Craciun) with long search on google.

AutoItSetOption("WinTitleMatchMode", 2)
$searchString = "YouTube"

WinActivate ("Chrome")
For $i = 1 to 100
    Send("^" & $i)
    Sleep(250)
    If Not(StringInStr(WinGetTitle("[ACTIVE]"), $searchString) = 0) Then
        WinSetState($searchString,"",@SW_MAXIMIZE)
        ExitLoop
    EndIf
Next

Today, my Chrome browser stand up and activate on my screen, but tabs dont switch.
I have replace Send("^" & $i) by Send("^a") and all my tab is selected (all in blue). If I clic on youtube tab, my window Maximize and the scrip stop. The problem is just an the line ->

Send("^" & $i)

If I clic in the notepad when my script is on, it write 0123456789 0123...

How can i have a realy command ctrl+1, wait 250ms, ctrl +2... but now, my code is no good...

For test this code, you need just have a chrome session open with 2 tabs, 1 active tab, and 1 not active tab with youtube.

I think thix code can help everyone, if you would help me for my english i can edit, just MP me plz.

Thx realy for help, I'm all red and my hair fall, plz save me lol.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Your code worked fine for me, Make sure chrome is on default settings, could be a plugin messing things up in chrome.

Edited by Kovacic

C0d3 is P0etry( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Ok I lied.. I added 50 tabs and it started pumping numbers everywhere... I moved a few things around which should help...

 

AutoItSetOption("WinTitleMatchMode", 2)
$searchString = "YouTube"

For $i = 1 to 100
WinActivate ("Chrome")
    Send("^{TAB}")
    Sleep(250)
    If Not(StringInStr(WinGetTitle("[ACTIVE]"), $searchString) = 0) Then
        WinSetState($searchString,"",@SW_MAXIMIZE)
        ExitLoop
    EndIf
Next

 

I moved 'Winactivate' into the 'for' loop to keep focus on chrome, and instead of using a variable to count the number tabs, I just changed it to 'Ctrl + Tab', this will also let it loop over the tabs again. I did this because it doesn't seem chrome will support anything past Ctrl + 9 for tab switching.

You can keep this a 'for' loop if you want to limit the number of tabs searched, or move it to a 'Do Until' loop to just go until it finds what its looking for. 

Edited by Kovacic

C0d3 is P0etry( ͡° ͜ʖ ͡°)

Share this post


Link to post
Share on other sites

Thx very munch, it's ok now,

 

AutoItSetOption("WinTitleMatchMode", 2)
$searchString = "YouTube"

For $i = 1 to 100
WinActivate ("Chrome")
    Send("^{TAB}")
    Sleep(250)
    If Not(StringInStr(WinGetTitle("[ACTIVE]"), $searchString) = 0) Then
        WinSetState($searchString,"",@SW_MAXIMIZE)
        ExitLoop
    EndIf
Next

is the Key. You're my savior :-P
Thank you very much the subject is closed.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now