Sign in to follow this  
Followers 0
wouteronline55

Change tabs of multiple browser windows

13 posts in this topic

The situation:

- 1 PC

- 2 monitors

- 2 Chrome browser windows with 2 tabs each (the same)

What I need:

- Switch tabs in both Chrome browser windows.

I already tried different things, but I can't get it to work in both browser windows.

Can anyone help me out?

Share this post


Link to post
Share on other sites



Welcome to AutoIt and the forum!

I already tried different things, but I can't get it to work in both browser windows.

Can you post what you tried so far?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Welcome to AutoIt and the forum!

Can you post what you tried so far?

I've been working with simulating CTRL + TAB, but that only works for the window that is active, not the second window. Also, worked with "If WinExists("title","unique text from left most tab") then ControlCommand and TabRight" (found in other topic) but can't get it to work.

Share this post


Link to post
Share on other sites

If you want to send keystrokes you need to activate the respective window.

Search the forum for "Chrome UDF" and you will find some threads about


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

If you want to send keystrokes you need to activate the respective window.

Search the forum for "Chrome UDF" and you will find some threads about

Thanks. However, what the difficult think for me is that there are 2 browser windows with each the same 2 tabs open. So, the titles are 100% the same...

Share this post


Link to post
Share on other sites

Then use function WinList to get a list of all windows with this title. Pass the HWND to WinActivate and the send the required keys.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Example: Get a list of all windows with title "xxxx". Activate each window and send Ctrl+6 (switch to tab #6) .

$aWinList = WinList("xxxx")
For $i = 1 To $aWinList[0][0]
    If WinActivate($aWinList[$i][1]) <> 0 Then Send("^6")
Next
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Example: Get a list of all windows with title "xxxx". Activate each window and send Ctrl+6 (switch to tab #6) .

$aWinList = WinList("xxxx")
For $i = 1 To $aWinList[0][0]
If WinActivate($aWinList[$i][1]) <> 0 Then Send("^6")
Next

Thanks, that looks good. When I run it with $aWinList = WinList() it works, but when I use $aWinList = WinList("Chrome"), it doesn't.

Share this post


Link to post
Share on other sites

Try this one:

#include <array.au3>
AutoItSetOption("WinTitleMatchMode", 2) ; Match any substring in the title
$aWinList = WinList("xxxx")
_ArrayDisplay($aWinList)
For $i = 1 To $aWinList[0][0]
    If WinActivate($aWinList[$i][1]) <> 0 Then Send("^6")
Next


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Try this one:

#include <array.au3>
AutoItSetOption("WinTitleMatchMode", 2) ; Match any substring in the title
$aWinList = WinList("xxxx")
_ArrayDisplay($aWinList)
For $i = 1 To $aWinList[0][0]
If WinActivate($aWinList[$i][1]) <> 0 Then Send("^6")
Next

Yes, that works! Thanks a lot!

Now there is 1 more challange I need to overcome: I have a infinite (While 1) loop to constantly change the tabs. In the loop, I added a sleep() to slow down the switch. However, I need to change the sleep() statement (nr. of seconds) based on the currently selected tab.

What I need:

if(tabname contains X){

sleep(10000)

}

else{

sleep(20000)

}

I know how to create a if/else statement, but can't find the object where the tab name is stored ("tabname contains X" in example above)...

Share this post


Link to post
Share on other sites

Can't you extract the name from the WIndows title? What does _ArrayDisplay return?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Can't you extract the name from the WIndows title? What does _ArrayDisplay return?

Ah yes, I have $aWinList[$i][0] I can use for the matching. Now just need a commant to check if string contains "x"...

Share this post


Link to post
Share on other sites

StringInStr?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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
Sign in to follow this  
Followers 0