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

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

Windows Keyboard How-To

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