Skip to content

Instantly share code, notes, and snippets.

@zemax
Last active April 4, 2024 14:30
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save zemax/7337507 to your computer and use it in GitHub Desktop.
Save zemax/7337507 to your computer and use it in GitHub Desktop.
An AutoHotKey script to move & resize windows screen when pressing Win + Alt + Left or Win + Alt + Right. Window moves from 33% Left > 50% Left > 66% Left > 66% Right > 50% Right > 33% Right
;********************************************************************************
; Move Windows by 1/3
;********************************************************************************
MoveCycle(Add) {
static SizeCycle = 0
SizeCycle := Mod(SizeCycle + Add, 6)
if (SizeCycle < 0) {
SizeCycle := SizeCycle + 6
}
if (SizeCycle = 0) {
MoveWindow(0, 33.3333)
}
else if (SizeCycle = 1) {
MoveWindow(0, 50)
}
else if (SizeCycle = 2) {
MoveWindow(0, 66.6666)
}
else if (SizeCycle = 3) {
MoveWindow(33.3333, 66.6666)
}
else if (SizeCycle = 4) {
MoveWindow(50, 50)
}
else if (SizeCycle = 5) {
MoveWindow(66.6666, 33.3333)
}
}
MoveWindow(XP, WP) {
;Get current Window
WinGetActiveTitle, WinTitle
WinGetPos, X, Y, WinWidth, WinHeight, %WinTitle%
;Get Taskbar height
WinGetPos,,, tbW, tbH, ahk_class Shell_TrayWnd
;Calculate new position and size
XNew := (A_ScreenWidth * XP / 100)
WNew := (A_ScreenWidth * WP / 100)
HNew := (A_ScreenHeight - tbH)
;MsgBox, %XNew% - %WNew%
WinRestore, %WinTitle%
WinMove, %WinTitle%,, %XNew%, 0, %WNew%, %HNew%
}
#!Left::
MoveCycle(-1)
return
#!Right::
MoveCycle(1)
return
@jshrek
Copy link

jshrek commented Nov 14, 2022

This is exactly what I was looking for! Thank you!!!

Since by default (without a script), the Windows Key + Arrow Key does 50/50, I think I will modify this script to skip the 50% setting and only do the 1/3 and 2/3 settings.

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