1

I want to open current active tab in Chrome to a new window.

The intention of this to split tabs side by side (for use with BetterSnapTool).

I am new with AppleScript and find reading this a bit difficult. Can't really discern from methods and properties.

2

This works for me using the latest version of Mac OS High Sierra.

tell application "Google Chrome"
    tell its window 1
        set theURL to URL of active tab
        close active tab
    end tell
    set the URL of active tab of (make new window) to theURL
end tell

If you would like to see the two windows now side-by-side, Try this...

tell application "Finder"
    set currentDesktopBounds to bounds of window of desktop
end tell

copy currentDesktopBounds to leftBounds
set l to item 3 of leftBounds
set l to l / 2 as integer
set item 3 of leftBounds to l

copy leftBounds to rightBounds
set r to item 3 of rightBounds as integer
set r to r + 1 as integer
set item 1 of rightBounds to r
set item 2 of rightBounds to 22
set item 3 of rightBounds to item 3 of currentDesktopBounds
set item 4 of rightBounds to item 4 of currentDesktopBounds

tell application "Google Chrome"
    tell its window 1
        set theURL to URL of active tab
        close active tab
    end tell
    set the URL of active tab of (make new window) to theURL
    delay 0.2
    tell its window 1
        set bounds to leftBounds
    end tell
    delay 0.2
    tell its window 2
        set bounds to rightBounds
    end tell
end tell
  • But that reloads the page - I can't afford loosing app state :( – Dzh Jun 2 '18 at 16:02
  • 1
    Hey everyone - be sure to +1 great answers like this - even if it's not the perfect answer or has side effects - this is some serious good code being put out for everyone to learn. – bmike Jun 15 '18 at 22:00
  • @bmike thanks a lot for the "kudos" on the quality of my code. It's nice to be recognized.Truth be told, though, I'm still teaching myself AppleScript. I've only been at it for just about a year and a half. Even though it's all in the spirit of helping others... There is a selfish side to this also Every script I write to help someone else, actually helps me learn a little bit more. ... And the more I learn the more fun it gets LOL – wch1zpink Jun 16 '18 at 0:38
  • Experts are the worst to learn from - especially if you are new. You want someone just a little more advanced than you if you’re totally new IMO. And you want someone competent if you’re ready to stretch a bit. Only advanced people want experts unless the expert is super talented at teaching all levels in addition to being an expert. – bmike Jun 16 '18 at 0:50
  • True that... Speaking for myself though, there is no better way to learn than through trial and error. (This didn't work… Let me try that…That didn't work, Let me try this and that…BINGO!! It worked) LOL For me, It's all about "the journey" If that makes sense ;-) – wch1zpink Jun 16 '18 at 0:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .