| View previous topic :: View next topic |
| Author |
Message |
JonathanAquino
Joined: 22 Jul 2006 Posts: 5
|
Posted: Tue Nov 24, 2009 10:41 pm Post subject: Auto-minimizing Outlook 2003 windows to conserve memory |
|
|
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 |
|
 |
cellardoor
Joined: 16 Sep 2010 Posts: 2
|
Posted: Thu Sep 16, 2010 10:35 pm Post subject: How to reference Outlook |
|
|
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 |
|
 |
JonathanAquino
Joined: 22 Jul 2006 Posts: 5
|
Posted: Fri Sep 17, 2010 4:47 am Post subject: |
|
|
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 |
|
 |
cellardoor
Joined: 16 Sep 2010 Posts: 2
|
Posted: Fri Sep 17, 2010 8:09 am Post subject: |
|
|
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  |
|
| Back to top |
|
 |
Chicken Pie 4 Tea
Joined: 18 Aug 2009 Posts: 375 Location: holland
|
|
| Back to top |
|
 |
|