Skip to content

Instantly share code, notes, and snippets.

@Zebiano
Last active April 14, 2023 08:21
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zebiano/6798e00ab188c7b23413c92fbeb49c53 to your computer and use it in GitHub Desktop.
Save Zebiano/6798e00ab188c7b23413c92fbeb49c53 to your computer and use it in GitHub Desktop.
Maximize Window through monitors with Auto Hot Key on Windows.
; Credit goes to Jeff Axelrod (https://stackoverflow.com/users/403455/jeff-axelrod) https://stackoverflow.com/a/9830200/470749
+#Up::
WinGetActiveTitle, Title
WinRestore, %Title%
SysGet, X1, 76
SysGet, Y1, 77
SysGet, Width, 78
SysGet, Height, 79
WinMove, %Title%, , X1, Y1, Width, Height
return
@Zebiano
Copy link
Author

Zebiano commented May 24, 2021

Disclaimer: Works with v1 of AHK.

Auto-start script on boot

You can easily have this script run on Windows boot by creating a shortcut of the script (Right click -> Create shortcut), and putting it into the Windows Start-up folder (Windows+R -> shell:startup).

Customization

You can also customise the script! WinMove uses a starting X and Y, as well as a Width and Height to resize the window. Keep in mind that having monitors with different resolutions and/or scalings will most likely result in unwanted outcomes. You can, however, manually fix these if you have the patience for it. Here are some examples:

Horizontal monitors

This will expand a window through every monitor you have. Only works if all your monitors are horizontally set up.

WinMove, %Title%, , X1, Y1, Width, Height

Triple horizontal monitors: expand only on two monitors

In case you're running a triple horizontal monitor setup, and only want a window to resize over two monitors, run this script:

WinMove, %Title%, , X1, Y1, ((Width/3)*2), Height             ; Expands on monitor 1 and 2
WinMove, %Title%, , (X1+(Width/3)), Y1, ((Width/3)*2), Height ; Expands on monitor 2 and 3

Triple monitors: two horizontal and one vertical

If you're running a triple monitor setup, where two are horizontally aligned and the third one is either above or below, you'll want to only stretch the height of the window by the two horizontal monitors.

WinMove, %Title%, , X1, Y1, Width, (Height/2)

Please keep in mind that you might be assigning variables unnecessarily if you end up using custom values.

@liutiming
Copy link

Great thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment