Move Current Tab from Browser A to Browser B on a Different Monitor

I typically use 3 monitors and I'd like to use Keyboard Maestro to move the active Chrome tab from a browser window on one screen to a browser window on a different screen.

Chrome doesn't have a shortcut to convert the current tab into its own window, but the Vimium extension includes the shortcut Shift+W which does this.

I can also already move windows to specific screens using this approach:

Here's my entire approach so far, which I've attached below:

  1. Shift+W -- make current tab its own window
  2. Pause for 5 hundredths of a second for potential loading
  3. Run the above approach to send that window to the desired screen
  4. Pause for 5 hundredths of a second for potential loading
  5. Using the Record button, I learned of the Move and Click and Drag action, which I use to drag the tab to where it should be released so that it joins the other tabs of the browser on the other screen.

Move Tab to Window 1.kmmacros (3.6 KB)

This approach works when sending tabs to screen 1, but I haven't been able to get it to work for moving tabs to screen 2 or screen 3. They get to where they need to be but don't get integrated in the browser window for some reason. For example, the image below shows the end position of a tab that was sent from a different screen, but it doesn't get added to the tabs of the window behind it. If I grab that tab with my mouse and move it even 1 pixel, it gets integrated with the window behind, so I'm not sure why it's not working when Keyboard Maestro does it.

Does anyone have a theory as to why this approach would work when sending a tab to one screen but not to others? If anyone can think of an alternative way of doing this, please let me know. I'm not attached to my approach.

Also, out of curiosity, when I record a macro that does all of these steps, it performs even worse. My guess as to why is that the record function seems to reproduce actions as rapidly as possible and maybe doesn't account for critical loading time along the way. Is there a way to make the macro record the time it takes to do actions as well?

I played around with chrome and absolutely could not get it to work. It refuses to see the mouse moving the new window on top of the window you want to merge with. Pretty sure it's a Chrome issue and not a KM issue as I could get it to work with Safari.

My testing was super simple, to test if it could separate a tab from the window I positioned the mouse on top of the tab manually, then triggered a KM macro that did a click & drag from the current position down 50. That worked (although with a weird delay in Chrome actually doing it).

The way Chrome works manually, you should just be able to reverse that to merge the tab back in. Position mouse, tripper action to click and drag up 50. Nope. It moved the window but Chrome refused to merge it into the window below. As soon as the macro ended I could manually do a drag of a few pixels and Chrome would merge the tab fine.

Same macro on Safari worked fine (you do have to have Safari set to always show the tab bar)

BTW, not really important to this but you can replace your extension for shift W to separate tabs with a KM macro. Set the trigger hotkey to shift-W, and the action:

That'll trigger Chrome's built in menu item to break a tab into a separate window and you don't need the extension for that.

Thanks for taking the time to test it out, I really appreciate it.

If it helps anyone else figure this out, here's a gif of the tab coming in from a different screen and getting integrated into Chrome. I wonder if the fact that the tab moves horizontally along the row of tabs from left to right (rather than straight up from underneath) has anything to do with it.

2021-07-25 21.19.41

that was one of the variants i tried. Out of curiosity is your Chrome window full size on the 2nd monitor as well?

Huh, strange. Yes, the Chrome window on the second monitor is also full-sized.

I took a different approach for this. I capture the current URL, close the tab, switch to the next window and create a new tab with the saved URL. Pretty easy.
image

1 Like

@devoy, you show one subroutine. What are you doing there?

Woops, sorry @rcraighead. My actual macro relies heavily on subroutines (subroutines rock!) but I tried to eliminate those in this example. (Missed this one) Close Tab/Close Window/Close is just my utility to select menu items in that order until something works (all from the same trigger). It's handy.

But you can just use a menu action to Close Tab if that will work for you.

1 Like

@devoy Nice! That's really ingenious!

For some reason %LocalPageURL% wasn't working for me so I used %ChromeURL% instead (with the Vimium extension, I could have also used the yy keystroke):




Your approach works very well but I'll just note two limitations in case anyone wants to keep working on this.

  1. If you have any unsaved work in the current tab, this will cause it to be lost — though that's pretty rare these days with everything being autosaved.
  2. You can't specify which monitor you want to send the tab to but instead, have to ensure that the last active Chrome window exists on the monitor you want to send the tab to. If you use Command+` to jump between windows, this can sometimes be a nuisance.

On your point 2, I've got a macro that looks at all the Chrome windows and activates one on the 2nd monitor. I've posted it below.

It's a bit picky about which window it wants. It's written so if you have 3 monitors and you want a window only on monitor 2 it'll find it, that means it's looking for a window with no overlap onto other montiors. You can adjust to just looking for a window where the left coordinate is on monitor 2, or if you want to add more math a window that is mostly on window 2. Other monitor names can be dropped in if you want a window on monitor 3, etc...

If you want the last window on a monitor, instead of the first, remove the "Break From Loop"

This works even if the window name in each Chrome window is the same.

Screenshot

Download

Make Chrome Window on Monitor 2 Active.kmmacros (10.3 KB)

1 Like