How to open 6 Chrome Windows side-by-side equally?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
reverberation
Posts: 314
Joined: 13 Dec 2015, 20:48

How to open 6 Chrome Windows side-by-side equally?

17 Jun 2020, 19:34

The scenario is to conduct a search on 6 different websites with the same keyword, and open them side-by-side in a new window each for quick comparison.

Will anyone know how to open them "equally"?
User avatar
boiler
Posts: 16956
Joined: 21 Dec 2014, 02:44

Re: How to open 6 Chrome Windows side-by-side equally?

17 Jun 2020, 20:57

Here's an example script. You might have to change the path to your chrome.exe file. And of course change the keywords and the URL to your site. It appears that it won't let me resize Chrome to less than 500 in width, so you might get overlapping windows depending on your monitor resolution.

Code: Select all

Keywords := ["Click", "FileRead", "Gui", "MsgBox", "Loop", "Send"]

Gui, +ToolWindow -Caption
Gui, Color, Yellow
Gui, Font, s16
Gui, Add, Text, w300 Center, Loading Chrome windows...
SysGet, Mon, MonitorWorkArea, 1
W := (MonRight - MonLeft) / 6
T := MonTop
B := MonBottom

for i, Keyword in Keywords
{
	Gui, Show ; allows us to wait for Chrome to be the new active window
	Sleep, 200
	Run, C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --new-window https://www.autohotkey.com/docs/commands/%Keyword%.htm
	WinWaitActive, ahk_exe chrome.exe
	WinMove, ahk_exe chrome.exe,, (i - 1) * W, T, W, B - T
}
ExitApp
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: How to open 6 Chrome Windows side-by-side equally?

18 Jun 2020, 03:04

https://www.howtogeek.com/181681/4-hidden-window-management-tricks-on-the-windows-desktop/
(I'd guess the OP is going for that view ...??)
concept

Image

Btw, I seem to remember that I've seen the foto of that article's author somewhere here at this forum :mrgreen:
reverberation
Posts: 314
Joined: 13 Dec 2015, 20:48

Re: How to open 6 Chrome Windows side-by-side equally?

18 Jun 2020, 23:59

Yes Bobo - you're right. Looking to tile them neatly without overlapping and maximizing all available screen estate on my 1440p monitor.
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: How to open 6 Chrome Windows side-by-side equally?

19 Jun 2020, 04:20

So, if Windows isn't providing that option already (but I think so, check out the linked article) you can mix up the code I've provided above with boilers'.
Good luck.
User avatar
boiler
Posts: 16956
Joined: 21 Dec 2014, 02:44

Re: How to open 6 Chrome Windows side-by-side equally?

19 Jun 2020, 04:46

This mod to my code does it:

Code: Select all

Keywords := ["Click", "FileRead", "Gui", "MsgBox", "Loop", "Send"]

Gui, +ToolWindow -Caption
Gui, Color, Yellow
Gui, Font, s16
Gui, Add, Text, w300 Center, Loading Chrome windows...
SysGet, Mon, MonitorWorkArea, 1
W := (MonRight - MonLeft) / 3
H := (MonBottom - MonTop) / 2
T := MonTop

for i, Keyword in Keywords
{
	Gui, Show ; allows us to wait for Chrome to be the new active window
	Sleep, 200
	Run, C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --new-window https://www.autohotkey.com/docs/commands/%Keyword%.htm
	WinWaitActive, ahk_exe chrome.exe
	WinMove, ahk_exe chrome.exe,, (i < 4 ? W * (i - 1) : W * (i - 4)), (i < 4 ? T : T + H), W, H
}
ExitApp
reverberation
Posts: 314
Joined: 13 Dec 2015, 20:48

Re: How to open 6 Chrome Windows side-by-side equally?

04 Jul 2020, 23:51

Hello boiler,

Thanks for the attempt. There's a bit of misunderstanding here. What I meant was I wanted to loop 6 different websites with the same keyword, aka

www.abc.com/%keyword%.html
www.def.com/%keyword%.html

etc

and tile them eventually. How do I reverse the logic in your code? On my side, the code also doesn't tile the 6 windows, nor does it ask for input on the keyword.
User avatar
boiler
Posts: 16956
Joined: 21 Dec 2014, 02:44

Re: How to open 6 Chrome Windows side-by-side equally?

05 Jul 2020, 05:47

Sorry. You explained it correctly, and I read it wrong. It could easily be changed to put the websites in the array. However, the format for searching for keywords on various websites isn’t usually (ever?) just www.abc.com/%keyword%.html, so you will need the array to have the proper format with some stand_in for the keyword so it can be replaced (the word keyword itself would work). Do you have the search format for various websites?

It’s very simple to add an InputBox to ask for the keyword. It doesn’t ask for the keyword because it was coded to search for an array of keywords. Once it’s coded for an array of websites, having it ask for the keyword is trivial.

I’m not sure why it’s not opening the windows tiled. Are you using multiple monitors? What does it display when you run the following?

Code: Select all

SysGet, Mon, MonitorWorkArea, 1
MsgBox, % "L: " MonLeft "`nR:" MonRight "`nT: " MonTop "`nB:" MonBottom
reverberation
Posts: 314
Joined: 13 Dec 2015, 20:48

Re: How to open 6 Chrome Windows side-by-side equally?

05 Jul 2020, 20:35

Code: Select all

R:2482
8:1440
Yes I have the format for all the websites. As long as I have the flexibility to insert %keyword% anywhere I want within the specified URLs, it will be fine.
User avatar
boiler
Posts: 16956
Joined: 21 Dec 2014, 02:44

Re: How to open 6 Chrome Windows side-by-side equally?

05 Jul 2020, 20:48

So the other two values you didn’t report were both 0, right?

When you say it didn’t tile them, did it open 6 chrome windows? Did it resize or move them at all? You might try running the script as administrator to see if it helps.
reverberation
Posts: 314
Joined: 13 Dec 2015, 20:48

Re: How to open 6 Chrome Windows side-by-side equally?

06 Jul 2020, 05:26

boiler wrote:
05 Jul 2020, 20:48
So the other two values you didn’t report were both 0, right?

When you say it didn’t tile them, did it open 6 chrome windows? Did it resize or move them at all? You might try running the script as administrator to see if it helps.
Hmm I only show what popped up, that's all I got.

Yes it opened 6 chrome windows, but no resizing/moving was done. Run as admin gave same results.
User avatar
boiler
Posts: 16956
Joined: 21 Dec 2014, 02:44

Re: How to open 6 Chrome Windows side-by-side equally?

06 Jul 2020, 06:49

It should have at least shown the other letters. Can you copy and paste the actual MsgBox results? When the MsgBox is active, press Ctrl+C, and it will copy the text of the MsgBox which you can paste here.

It’s weird that nothing is showing for those other variables. That’s why it’s messing up the WinMove. We can fix that, but I still would like to see the actual output to try to figure out why it’s acting different for you.
User avatar
boiler
Posts: 16956
Joined: 21 Dec 2014, 02:44

Re: How to open 6 Chrome Windows side-by-side equally?

07 Jul 2020, 20:24

Why did you not report the other stuff, even after I said it looked like the parts with the zeros was missing? When I asked “So the other two values you didn’t report were both 0, right? ”, you replied, “Hmm I only show what popped up, that's all I got.” Please put at least as much effort into answering my questions as I am in trying to help you.

Given those results, it should have worked. Are you using the full script that opens the 6 windows as I posted it without modifications? For example, the GUI it shows is important for how it operates. It’s not just for show. Or have you modified it in some way?
reverberation
Posts: 314
Joined: 13 Dec 2015, 20:48

Re: How to open 6 Chrome Windows side-by-side equally?

13 Jul 2020, 01:18

boiler wrote:
07 Jul 2020, 20:24
Why did you not report the other stuff, even after I said it looked like the parts with the zeros was missing? When I asked “So the other two values you didn’t report were both 0, right? ”, you replied, “Hmm I only show what popped up, that's all I got.” Please put at least as much effort into answering my questions as I am in trying to help you.

Given those results, it should have worked. Are you using the full script that opens the 6 windows as I posted it without modifications? For example, the GUI it shows is important for how it operates. It’s not just for show. Or have you modified it in some way?
Just to clarify, there are times when the 0 values show and when it doesn't show. The first time I reported, it was as-is. Hope you understand.

Yes I pasted it verbatim to test.
User avatar
boiler
Posts: 16956
Joined: 21 Dec 2014, 02:44

Re: How to open 6 Chrome Windows side-by-side equally?

13 Jul 2020, 15:30

I don't know why those variables from SysGet wouldn't always be populated. You could try this version of the script that doesn't rely on those two variables being 0. If this produces 6 tiled windows, then I can show how to change it for 6 different search windows using one user-defined keyword.

Code: Select all

Keywords := ["Click", "FileRead", "Gui", "MsgBox", "Loop", "Send"]

Gui, +ToolWindow -Caption
Gui, Color, Yellow
Gui, Font, s16
Gui, Add, Text, w300 Center, Loading Chrome windows...
SysGet, Mon, MonitorWorkArea, 1
W := MonRight / 3
H := MonBottom / 2
T := 0

for i, Keyword in Keywords
{
	Gui, Show ; allows us to wait for Chrome to be the new active window
	Sleep, 200
	Run, C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --new-window https://www.autohotkey.com/docs/commands/%Keyword%.htm
	WinWaitActive, ahk_exe chrome.exe
	WinMove, ahk_exe chrome.exe,, (i < 4 ? W * (i - 1) : W * (i - 4)), (i < 4 ? T : T + H), W, H
}
ExitApp
reverberation
Posts: 314
Joined: 13 Dec 2015, 20:48

Re: How to open 6 Chrome Windows side-by-side equally?

13 Jul 2020, 20:07

yup, now it works. just 1 small issue - there are blank margins around every windows. Is it possible to eliminate the margins?

Also, I tested it a few times and occasionally, the 5th window will be missed out.

Lastly, as it is tiled into 6 windows, is it possible to set a custom zoom level (E.g. 70%) for each window based on the URL?

https://i.imgur.com/rlPospO.png
User avatar
boiler
Posts: 16956
Joined: 21 Dec 2014, 02:44

Re: How to open 6 Chrome Windows side-by-side equally?

13 Jul 2020, 21:17

reverberation wrote: there are blank margins around every windows. Is it possible to eliminate the margins?
For some reason, when they introduced Windows 10 they really messed up the difference between the visible edges of windows and the virtual edges. So try this version which adds some extra size to the width and height of each window:

Code: Select all

Keywords := ["Click", "FileRead", "Gui", "MsgBox", "Loop", "Send"]

Gui, +ToolWindow -Caption
Gui, Color, Yellow
Gui, Font, s16
Gui, Add, Text, w300 Center, Loading Chrome windows...
SysGet, Mon, MonitorWorkArea, 1
W := MonRight / 3
H := MonBottom / 2
T := 0

for i, Keyword in Keywords
{
	Gui, Show ; allows us to wait for Chrome to be the new active window
	Sleep, 200
	Run, C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --new-window https://www.autohotkey.com/docs/commands/%Keyword%.htm
	WinWaitActive, ahk_exe chrome.exe
	WinMove, ahk_exe chrome.exe,, (i < 4 ? W * (i - 1) : W * (i - 4)), (i < 4 ? T : T + H), W + 18, H + 9
}
ExitApp


reverberation wrote: Also, I tested it a few times and occasionally, the 5th window will be missed out.
Hmm...When that happens, does it not open the 5th window at all, or does it open it but not resize it?


reverberation wrote: Lastly, as it is tiled into 6 windows, is it possible to set a custom zoom level (E.g. 70%) for each window based on the URL?
We could put something in the array of URLs to indicate the zoom factor to use and then adjust it by sending Ctrl+- the appropriate number of times. It looks like factors are 90%, 80%, 75%, 67% (and smaller), so you could choose how many steps smaller (or larger) than 100% you want each one to be.
reverberation
Posts: 314
Joined: 13 Dec 2015, 20:48

Re: How to open 6 Chrome Windows side-by-side equally?

13 Jul 2020, 21:34

hmm there's some overlapping of windows in the new script.

the 5th window is not opened at all.

is there a way to set a specific zoom % instead of using Control + / - ?
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: How to open 6 Chrome Windows side-by-side equally?

13 Jul 2020, 21:49

Seeing the margin to the right of the screen (while missing to the left, https://i.imgur.com/rlPospO.png) gives me the idea that you should have a look if your (hardware) visible screen adjustments are in a leveled position? JFTR. :)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Joey5 and 257 guests