Last active
February 20, 2024 23:45
-
-
Save jcheng31/7169828 to your computer and use it in GitHub Desktop.
An AutoHotkey script for widescreen, high-resolution monitors. Resizes the active window to be 75% of the screen's width (and 100% of its height, taskbar excluded) and centres it. Triggered by pressing Win+Shift+Up. Great for websites that don't nicely centre their content. Win+Shift+C now centres the active window without resizing it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; When Win+Shift+Up is pressed, resize the active window to be 75% of the screen width | |
; and centre it. Useful for widescreen resolutions >= 1080p, but uses the resolution | |
; of the primary monitor. | |
#+Up:: | |
SysGet, BoundingCoordinates, MonitorWorkArea | |
ResolutionWidth := BoundingCoordinatesRight - BoundingCoordinatesLeft | |
ResolutionHeight := BoundingCoordinatesBottom - BoundingCoordinatesTop | |
AdjustedWidth := 0.75 * ResolutionWidth | |
LeftMargin := 0.125 * ResolutionWidth | |
WinMove A, , LeftMargin, 0, AdjustedWidth, ResolutionHeight | |
return | |
; When Win+Shift+C is pressed, move the active window to the centre of the screen. | |
#+c:: | |
SysGet, BoundingCoordinates, MonitorWorkArea | |
ResolutionWidth := BoundingCoordinatesRight - BoundingCoordinatesLeft | |
ResolutionHeight := BoundingCoordinatesBottom - BoundingCoordinatesTop | |
WinGetPos, , , ActiveWidth, ActiveHeight, A | |
HorizontalMargin := (ResolutionWidth - ActiveWidth) / 2 | |
VerticalMargin := (ResolutionHeight - ActiveHeight) / 2 | |
WinMove A, , HorizontalMargin, VerticalMargin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a brilliant little script! It's the exactly the starting point that I was looking for.
Thank you!