Google Chrome – Opening Ten Different Tabs in Ten Different Windows

Hi Guys. I'm looking for the following solution.

I have a list of URLs and 10 different Chrome Windows. Each Window should open 10 URLs.

My idea is that in each Loop I just delete the first 10 Lines of the Variable and just create 1 for each Loop for the 10 Chrome Windows, but I'm not sure how I can delete the first 10 Lines of the Variable. Anyone here who can help me?

Thank you!

This thread should help get you on your way:

I forgot to say that a subroutine to extract batches of lines from a list of items exists and may also help you out. You can find it here:

Hey @BaoHoang,

With this sort of task I'm always going to default to using AppleScript, because I generally prefer the compactness of code over the UI of Keyboard Maestro – and because one stream of Apple Events is just more efficient. (KM uses AppleScript to control Google Chrome behind the scenes.)

Here's the pure AppleScript in which I'm storing the URLs in a script object.

--------------------------------------------------------
# Auth: Christopher Stone <scriptmeister@thestoneforge.com>
# dCre: 2023/03/21 10:46
# dMod: 2023/03/21 10:46 
# Appl: Google Chrome
# Task: Open a List of URLs – 10 Per Window.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Google_Chrome, @Open, @List, @URLs
--------------------------------------------------------

set urlList to getURLs's urlList

if ((length of urlList) / 10) mod 1 > 0 then
   error "URL List is not Divisible by 10!"
end if

set _cntr to 0
tell application "Google Chrome"
   repeat with theURL in urlList
      set _cntr to _cntr + 1
      if _cntr = 1 or _cntr mod 10 = 1 then
         set newWindow to make new window
         set URL of active tab of newWindow to item 1 of urlList
      else
         tell newWindow to make new tab at end of tabs with properties {URL:theURL}
      end if
   end repeat
end tell

--------------------------------------------------------
--» SCRIPTS
--------------------------------------------------------
script getURLs -- A simple method of storing and retrieving the URL list.
   property urlList : paragraphs of text 2 thru -2 of "
https://www.google.com/
https://www.google.com/
https://www.google.com/
https://www.google.com/
https://www.google.com/
https://www.google.com/
https://www.google.com/
https://www.google.com/
https://www.google.com/
https://www.google.com/
https://www.google.com/
https://www.google.com/
https://www.google.com/
https://www.google.com/
https://www.google.com/
https://www.google.com/
https://www.google.com/
https://www.google.com/
https://www.google.com/
https://www.google.com/
"
   return getURLs's urlList
end script
--------------------------------------------------------

Here's a Keyboard Maestro macro that makes entering the URL list a trifle easier for the user:


Download: Google Chrome – Open a List of URLs 10 Each in 10 Windows v1.00.kmmacros (8.7 KB)

Macro-Image

Keyboard Maestro Export

Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.

System Information
  • macOS 10.14.6
  • Keyboard Maestro v10.2

-Chris