Skip to content

Instantly share code, notes, and snippets.

@Satal
Created March 26, 2025 10:10
Show Gist options
  • Select an option

  • Save Satal/4912d5aa00638d4c31e38f7d088fc595 to your computer and use it in GitHub Desktop.

Select an option

Save Satal/4912d5aa00638d4c31e38f7d088fc595 to your computer and use it in GitHub Desktop.
This script allows you to easily resize any window on your screen using a AHK v2 keyboard shortcut.
^+w:: { ; Ctrl + Shift + W
MsgBox("Hover your mouse over the window you want to resize, then press OK.")
; Get the window under the mouse
MouseGetPos(, , &winID)
WinGetPos(&x, &y, &width, &height, "ahk_id " winID)
MsgBox("Current Size:`nWidth: " width "`nHeight: " height)
; Get new width
resultWidth := InputBox("Enter the new width:", "New Width")
if resultWidth.Result != "OK" || resultWidth.Value = ""
return
newWidth := Number(resultWidth.Value)
; Get new height
resultHeight := InputBox("Enter the new height:", "New Height")
if resultHeight.Result != "OK" || resultHeight.Value = ""
return
newHeight := Number(resultHeight.Value)
; Resize window
WinMove(x, y, newWidth, newHeight, "ahk_id " winID)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment