Page 1 of 1

Move all windows to primary monitor and maximize

Posted: 24 Jun 2019, 12:52
by shadowsong
When I dock/undock my laptop, I often end up with formerly maximized windows resized to be ALMOST the same size as the screen, but not quite. And sometimes when I undock, windows that were on my second monitor don't get moved to the laptop screen, and I have to futz with keyboard shortcuts for moving them until I can actually see them again.

I wrote some code that theoretically would do this, but it doesn't actually do anything when I run it. Can anyone help me with this?

Code: Select all

;move all windows to main monitor and maximize
#PgUp:: 
SysGet, Coord, monitor		;find coordinates of main monitor
WinMinimizeAllUndo		;restore all
UniqueID := WinExist("A") 	;store active window
WinActivateBottom, i)[a-z]*	;activate oldest window
while UniqueID <> WinExist("A") ;until you loop back to the stored window
	{
	WinMove, %CoordLeft%, %CoordTop%	;move to main monitor
	WinMaximize, A 				;maximize
	WinActivateBottom, i)[a-z]*		;activate next oldest
	}