AutoHotkey: Script to Toggle Maximize Window

By Xah Lee. Date: . Last updated: .

Here's AutoHotkey script to toggle maximize window.

〔►see AutoHotkey Tutorial

; 2011-04-30
; A toggle. maximize current window, or restore size if already maximized.
; http://xahlee.info/mswin/autohotkey_toggle_maximize_window.html

#NoTrayIcon
WinGetPos, winWidth, winHeight, , , A  ; "A" to get the active window's pos.
if ( winWidth == -8 and winHeight == -8) {
WinRestore, A
} else
{
WinMaximize, A
}

ExitApp

Save the above in a file, name it 〔toggle window maximize restore.ahk〕.

Then, in your main AutoHotkey file, you can assign a key to it, like this:

$ScrollLock::Run "toggle window maximize restore.ahk"

Or, you can use your Microsoft or Logitech software keyboard driver software to assign a key to launch the script.

AutoHotkey

  1. AutoHotkey Tutorial
  2. AutoHotkey Key Syntax
  3. Useful AutoHotkey Scripts
  4. Swap Caps Lock, Alt, Control Keys
  5. Toggle Maximize Window