How to Move a Tab to New Window in Browser?

Apparently there is no shortcut to activate the "move tab to new window" menu option in chrome so I'm trying to achieve that in KM. I was not able to find a fitting action for this. Any way to do this?

The first step is to make sure that that option is enabled (not grayed out) in Chrome itself:

Screenshot 2021-12-27 at 09.22.11

(Chrome's design is a little weak and inconsistent here – you may need to create an additional tab in order to 'de-gray' the Move tab to new window)

Once you have done that, however, (and borne in mind that Keyboard Maestro, like Chrome itself, may not always have access to that option) you will find that Move tab to new window is, in fact, as accessible to KM's Show/Select Menu action as it is to Chrome.

Clicking on the Menu dropdown at top-right of the action:


Awesome! Thank you

I have a similar request about Firefox. There is no Tab menu like in Chrome, just a Window menu and this doesn't have the "Move to New Window" item in the menu. However, if I right-click on the tab, there is a contextual menu with this item. How can I access this contextual menu using KM?
I have a slight work around by copying the URL, closing the tab, then opening a new Private window (I can't just open a new window with Cmd+n because I have a group of tabs as my home page and it gets opened with all the tabs), and then pasting the URL in the new window (very clunky and doesn't really achieve what I need). I also want it to move the new window to the left of the screen. Any guidance would be greatly appreciated!
Warmest regards,

Your most flexible option is probably to look for a Firefox extension.

Any idea what that extension would be called?

Is your workaround automated or do you do it manually?

The short answer is "use something other than Firefox" -- not only is it not AppleScriptable, its Accessibility provision is almost non-existent so you can't use GUI-scripting either.

There's a long-shot though -- for me, at least, the active tab is a different colour to the others and the name of the tab doesn't overlap the the "Close tab" button. You might be able to use image detection tightly on the button and its background and right-click at a slight left offset from that point, do a similar image detection and click on the "Move Tab" menu item, and finally the same on "Move to New Window". I've thrown in an obvious "Move and Resize" to show that once you have that window you can use KM "normally":

FF Tab to new Window.kmmacros (44.8 KB)


You'll have to change the images to match your theme and/or OS mode, and might have to play with the pauses.

Thank you Nige for the great feedback and kmmacros. This is a great community!

That said, I think I figured it out. I am using an AppleScript that uses osascript command to simulate the key presses directly in Firefox.

I just learned that in FF, if you press command-l (command-lowercase L), it selects the URL in the address bar, and then press shift-enter, it will automatically duplicate the current page in a new window. Pretty cool in itself!

From there, I use KM to Resize and Move the window, as well as close the previous page. I didn't have to use a KM click image, but instead told it to just go to the tab location using pixels from the screen's edge and click, then have it do a command-w to close it. This gives me the pages I want to see side-by-side.

I am using a 37inch LG monitor, so the page sizes are very specific to my needs.

Thanks again for the suggestion and macros!

1 Like

Why use AppleScript via osascript?

A) Keyboard Maestro has it's own Type a Keystroke action.

B) Keyboard Maestro has a straight-up Execute an AppleScript action, and the mechanism it uses is osascript. It's not necessary to add another layer of execution on...

@ccstone, you bring up a really good point, and I should have mentioned that I originally did just that (using KM Type a Keystroke). However, I found that using AppleScript (within KM) was slightly faster, especially when doing a collection of successive key-presses… but just slightly. :grin: Thanks for your feedback. Great community!

AppleScript running from KM has some overhead getting started, and it doesn't have any feedback mechanism – you just fire off the events and forget them.

Try experimenting with KM's action delay, and see what you get.

Awesome. Thank you!

1 Like