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.

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


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.

Windows Keyboard How-To

  1. Windows Keyboard Software Guide
  2. AutoHotkey Tutorial
  3. AutoHotkey Syntax
  4. AutoHotkey Scripts
  5. Swap CapsLock, Alt, Control
  6. Toggle Max Window
  7. Disable CapsLock, Win Key
  8. Window Key Shortcuts
  9. Microsoft Windows Key Shortcuts
  10. cmd Console Shortcuts
  11. Swap Mouse Buttons

If you have a question, put $5 at patreon and message me.