Categories
AutoHotkey Microsoft Office Productivity Technology Work

Productivity – Stay OUT of Outlook

As you will have read in various other places it is not productive to stay “in” Outlook and constantly respond to all the incoming e-mail.
It’s much better to go into your e-mail when it suits YOU – process your e-mail for a set period of time and then get back to some “real” work.
I had looked at various ways to implement this but it turns out that this is simple to implement using AutoHotkey (AHK).

I wanted a nag screen to dissuade me from going into Outlook but not so that it made it impossible or too awkward.

When “Outlook” is the foreground window – ask me to confirm if it’s “OK”, if so give me 15 minutes to process my mail and then start nagging again!

The script can be found on GitHub here.

#Persistent

; —— —— CONFIGURATION SECTION —— ——
SetTitleMatchMode 3
ProgWinTitle = ahk_class rctrl_renwnd32
CheckPeriod := 60000 * 15 ; 60000 = 1 minute

; —— END OF CONFIGURATION SECTION —— ——

WaitForOutlook:
WinWaitActive ahk_class rctrl_renwnd32 , , , ,
CurrWindow := WinExist(“A”)
WinMinimize ahk_id %CurrWindow%
msgbox 4, Stay Focussed, Are you sure you want to read your mails?, 5
ifmsgbox Yes
{
WinRestore ahk_id %CurrWindow%
;restart watching after period above
SetTimer, RestartWatching, %CheckPeriod%
}
else
{
WinMinimize ahk_id %CurrWindow%
;restart watching “immediately”
SetTimer, RestartWatching, 100
}
Return

RestartWatching:
GoSub WaitForOutlook
return

The code is quite straight forwards

I start with some basic setup – defining the window class for Outlook (you can use the bundled WindowSpy utility to identify whatever application YOU want to stay out of). I’m matching based upon the class rather than the title so that it catches both the Outlook application and all of the windows eg New Message, Appointments etc. The good thing is that Outlook notifications eg my alert to notify “important” email has arrived is not part of this window class so is not trapped. I also set a variable for 15 minutes – the default period that I want to be “in” Outlook for before the nagging starts again.

Then the magic happens – the WinWaitActive command puts the script to “sleep” until the nominated window becomes active – in this case, any Outlook class. When this occurs the script continues, I grab the unique ID for the window that triggered the script, minimise the window and put up a nag screen to confirm if I really want to be doing e-mail.

If I do want to be doing e-mail I restore the previously minimised window. The script would normally end at this point however, I then set a timer for 15 minutes at which point we jump back to the start of the script and start waiting for Outlook to rear it’s ugly head again.

If I don’t want to be doing e-mail I simply restart watching for outlook again.

Problems

Startup

I have set Outlook to start up automatically on my PC and despite my best efforts I cannot get it to start minimised. (on my locked down Windows XP work laptop). In this situation my AutoHotkey script would always start prior to outlook and start napping whilst Outlook was starting up.

To mitigate this I removed OutlookFocus.ahk from my startup folder and replaced it with DelayStartOutlookFocus.ahk. This script simply sleeps for 15 minutes and then runs OutlookFocus.ahk as normal.

#Persistent

; —— —— CONFIGURATION SECTION —— ——
DelayPeriod := 60000 * 15 ; 60000 = 1 minute

; —— END OF CONFIGURATION SECTION —— ——

SetTimer, StartWatching, %DelayPeriod%
return

StartWatching:
run C:\RGApps\AHK-RG\OutlookFocus.ahk
ExitApp
return

I NEED to do e-mail

There are some occasions when I need to stay in Outlook without the nagging – when this happens I can simply right click on the AHK icon in my task bar and “pause” the script. This turns the icon red which is enough of a reminder for me to go back and turn it back on again when I’m done.

Leave a Reply

Your email address will not be published. Required fields are marked *