AutoHotkey Community

It is currently May 27th, 2012, 2:47 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: November 24th, 2009, 11:41 pm 
Offline

Joined: July 22nd, 2006, 6:29 am
Posts: 5
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%
        }
    }
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject: How to reference Outlook
PostPosted: September 16th, 2010, 11:35 pm 
Offline

Joined: September 16th, 2010, 11:26 pm
Posts: 2
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 17th, 2010, 5:47 am 
Offline

Joined: July 22nd, 2006, 6:29 am
Posts: 5
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 17th, 2010, 9:09 am 
Offline

Joined: September 16th, 2010, 11:26 pm
Posts: 2
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 :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 17th, 2010, 2:07 pm 
Offline

Joined: August 18th, 2009, 12:07 pm
Posts: 375
Location: holland
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 ... ntry690059

but you will have to have AutoIt installed too.
unless some clever person can do the same with AHK?

_________________
"Choose your parents wisely"


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher, Yahoo [Bot] and 6 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group