This script automatically minimizes Outlook after a minute of inactivity. It's needed because unminimized Outlook 2003 windows gradually increase their memory usage, typically reaching 200 MB. When Outlook is minimized, the memory usage drops to 15 MB.
60 seconds is the default, but you can pass the number of seconds you want as a parameter, e.g., AutoMinimizeOutlook.exe 300
Code:
/**
* This script minimizes inactive Outlook 2003 windows to conserve memory.
* Unminimized Outlook windows gradually consume increasing amounts of
* memory - 200 MB is typical. Memory usage drops to 15 MB when it is minimized.
* This script checks for unminimized Outlook windows every 60 seconds, by default.
* The number of seconds can be specified explicitly, e.g., AutoMinimizeOutlook.exe 300
*
* Optional parameter: Number of seconds between checks (defaults to 60)
*
* @author Jonathan Aquino
* @license MIT
* @see Microsoft description of the problem: http://support.microsoft.com/kb/827310
* @see AutoMinimizeOutlook blog post: http://jonaquino.blogspot.com/2009/11/autominimizeoutlookexeworkaround-for.html
* @see AutoMinimizeOutlook source code: http://www.autohotkey.com/forum/viewtopic.php?p=313354
*/
ArgCount = %0%
If ArgCount = 0
{
SleepInterval := 60000
}
Else
{
SleepInterval = %1%
SleepInterval *= 1000
}
/**
* Returns whether the specified window is active or minimized.
*
* @param Id The ID of the window
*/
ActiveOrMinimized(Id)
{
IfWinActive, ahk_id %Id%
{
Return 1
}
WinGet, MinMax, MinMax, ahk_id %Id%
If MinMax = -1
{
Return 1
}
Return 0
}
Loop
{
Sleep, %SleepInterval%
WinGet, Ids, List, ahk_class rctrl_renwnd32
Loop %Ids%
{
Id := Ids%A_Index%
If ActiveOrMinimized(Id) = 0
{
/*
* 0x112 = WM_SYSCOMMAND, 0xF020 = SC_MINIMIZE
*/
PostMessage, 0x112, 0xF020,,, ahk_id %Id%
}
}
}