AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Auto-minimizing Outlook 2003 windows to conserve memory

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
JonathanAquino



Joined: 22 Jul 2006
Posts: 4

PostPosted: Tue Nov 24, 2009 11:41 pm    Post subject: Auto-minimizing Outlook 2003 windows to conserve memory Reply with quote

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%
        }
    }
}
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group