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: 5

PostPosted: Tue Nov 24, 2009 10: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
cellardoor



Joined: 16 Sep 2010
Posts: 2

PostPosted: Thu Sep 16, 2010 10:35 pm    Post subject: How to reference Outlook Reply with quote

Hi Jon,

Thanks very much for sharing this. Seems like I've only just caught up with the rest of the world in realising Outlook is a memory hog when left open.

I was just wondering if you could tell me where in your code it is referencing Outlook as I cannot see it and it is really puzzling me.

2 quirks. Outlook minimizes if you are drafting an email. May be if I can see how it's referencing Outlook I can make it look for all instances. I admit I am new to this.

Other quirk. It seems for me that if I put a shortcut in my Windows XP start up folder for this program passing an argument of 300 it seems to be ignored and minimizes outlook after 60 seconds of inactivity. This seems to be a problem with the shortcut however as if I run the command manually from a cmd line it works. Strange and I'm not sure how this can be worked around.
Back to top
View user's profile Send private message
JonathanAquino



Joined: 22 Jul 2006
Posts: 5

PostPosted: Fri Sep 17, 2010 4:47 am    Post subject: Reply with quote

Been a while since I wrote this, but I believe the reference to Outlook is rctrl_renwnd32.

I have since moved to a Mac and am quite happy with it. Always lots of RAM available, and it's pretty quick. No AHK though unfortunately.
Back to top
View user's profile Send private message
cellardoor



Joined: 16 Sep 2010
Posts: 2

PostPosted: Fri Sep 17, 2010 8:09 am    Post subject: Reply with quote

Much obliged for your quick response Jon. Would love a Mac myself but can't justify it to myself!

I got Apple TV. Does that count Smile
Back to top
View user's profile Send private message
Chicken Pie 4 Tea



Joined: 18 Aug 2009
Posts: 375
Location: holland

PostPosted: Fri Sep 17, 2010 1:07 pm    Post subject: Reply with quote

Dont know if this is cheating but I use an autoIt script to tame Firefox but you can choose any running program. Get it at
http://www.autoitscript.com/forum/index.php?showtopic=95986&st=0&p=690059&hl=reduce%20memory&fromsearch=1&#entry690059

but you will have to have AutoIt installed too.
unless some clever person can do the same with AHK?
_________________
"Choose your parents wisely"
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