
The general idea of the function is that you can assign a specific hotkey to a specific window—when you press the shortcut key once, the window will come to the foreground, and if you press it again, the window will minimize. This way you can toggle between the windows you use most often, without having to bother with Alt-Tab.
To make your own AutoHotkey script for restoring a specific window, create a new *.ahk script and paste in the following code:
ToggleWinMinimize(TheWindowTitle)
{
SetTitleMatchMode,2
DetectHiddenWindows, Off
IfWinActive, %TheWindowTitle%
{
WinMinimize, %TheWindowTitle%
}
Else
{
IfWinExist, %TheWindowTitle%
{
WinGet, winid, ID, %TheWindowTitle%
DllCall("SwitchToThisWindow", "UInt", winid, "UInt", 1)
}
}
Return
}
!x::ToggleWinMinimize("Mozilla Firefox")
If all this AutoHotkey is a little more than you can understand, be sure to check out our beginner's guide to AutoHotkey, where we explain how you can use this simple scripting language to turn any action into a keyboard shortcut.
This script is courtesy of the Lifehacker Coders group over on Productive Geek forums, and reader bobbo33 is the AutoHotkey wizard that figured out how to make it work for any window, and solved a long-standing problem I've personally had with the WinRestore function. Thanks, bobbo33!
Use AutoHotkey to Assign a Hotkey to a Specific Window [Productive Geek]
