Relocating web browser windows

Get help with using AutoHotkey and its commands and hotkeys
Posts: 9
Joined: 01 Sep 2016, 15:11

Relocating web browser windows

08 Aug 2019, 21:15


This is a consultation question to see if AHK is able to do the tasks required. I'm using multiple monitor setup, three in this case.

With script binded to a hotkey on keyboard, is AHK able to locate and analyze all current web browser windows (e.g. Chrome) and send each window to its destination monitor based on domain in URL? I'm using the Chrome extension "Tab Resize" to split Chrome tabs into its own individual window and would like to run the script (activated manually) to relocate each splitted window to its respective monitor (maximized) as indicated by red arrows in screenshot attached. For example, a single Chrome window with domain would be sent to 3rd monitor. If there are multiple tabs found in a Chrome window, skip it.


screenshot.png (40.06 KiB) Viewed 186 times
Last edited by DevinC on 09 Aug 2019, 15:36, edited 2 times in total.
User avatar
Sir Teddy the First
Posts: 94
Joined: 05 Aug 2019, 12:31

Re: Relocating web browser windows

09 Aug 2019, 06:28

yes, AHK is capable of doing that.

First you would have to iterate over all Chrome-Windows via WinGet,,List.
When you have done that, use something like this (this is an example code I use for firefox, you have to adapt it to your needs)

Code: Select all

WinSet, Style, -0x1000000, ahk_class MozillaWindowClass
WinMove, ahk_class MozillaWindowClass,, 50, 50, 500, 500
WinMaximize, ahk_class MozillaWindowClass
Two comments on this code:
  • Especially important is the first line, because if your window is maximized and you want to move it to another monitor and maximize it there, it won't work, because the window stilll "thinks" it is already maximized, so you first have to remove that "Maximized-Style"
  • Second, you have to change the winmove-command: "50, 50" are the coordinates, these have to be on the monitor you want the window to get moved on; "0,0" would be the top left corner of your primary display, depending on your screen resolution you have to go negative if you want a monitor on the left or add the complete width of your primary display if you want a monitor on the right;
    The "500, 500" is width and height of the window before it will get maximized. I would recommend setting these rather low, because if the window overlaps another monitor, windows might think you want it to get maximized there.
Separating the windows based on their URL should be rather easy, because you should be able to get the Domain from the Window-Title (which you got from the "WinGet" command as a list of all window-titles).

I hope I could help, if you need assistance adapting my explanations as code, just ask.
:eh: :think:

Return to “Ask For Help”

Who is online

Users browsing this forum: Chunjee, Google [Bot], hyaray, tmplinshi and 196 guests