One of my main productivity “sinks” is continually monitoring Outlook to see if any mails have arrived.
I have a rule set up that notifies me if an “important” email lands but for this to run, outlook needs to be running (minimised of course). I can’t resist the temptation to just “have a peek” outside my first thing in the morning, last thing at night email window.
To get around this I want to be “discouraged” from opening Outlook.
To implement this I have used Antonio Franca’s fantastic WinTrigger AutoHotkey script.
My amendment is to make it watch for the main Outlook window and when this becomes active, to get it to ask me to confirm if I really want to be using Outlook. If I hit No or leave it for 5 seconds then Outlook gets minimised again.
Here is my implementation of Antonio’s code:
; Template: WinTrigger (former OnOpen/OnClose)
; Description: Act upon (de)activation/(un)existance of programs/windows
; Online Ref.: http://www.autohotkey.com/forum/viewtopic.php?t=63673
; Last Update: 15/Mar/2010 17:30
; Created by: MasterFocus
; Thanks to: Lexikos, for improving it significantly
; This template contains two examples by default. You may remove them.
; * HOW TO ADD A PROGRAM to be checked upon (de)activation/(un)existance:
; 1. Add a variable named ProgWinTitle# (Configuration Section)
; containing the desired title/ahk_class/ahk_id/ahk_group
; 2. Add a variable named WinTrigger# (Configuration Section)
; containing the desired trigger (“Exist” or “Active”)
; 3. Add labels named LabelTriggerOn# and/or LabelTriggerOff#
; (Custom Labels Section) containing the desired actions
; 4. You may also change CheckPeriod value if desired
; —— —— CONFIGURATION SECTION —— ——
; Program Titles
;ProgWinTitle1 = ahk_class rctrl_renwnd32
ProgWinTitle1 = Microsoft Outlook
WinTrigger1 = Active
; SetTimer Period
CheckPeriod = 200
; —— END OF CONFIGURATION SECTION —— ——
SetTimer, LabelCheckTrigger, %CheckPeriod%
; —— —— ——
While ( ProgWinTitle%A_Index% != “” && WinTrigger := WinTrigger%A_Index% )
if ( !ProgRunning%A_Index% != !Win%WinTrigger%( ProgWinTitle := ProgWinTitle%A_Index% ) )
GoSubSafe( “LabelTriggerO” ( (ProgRunning%A_Index% := !ProgRunning%A_Index%) ? “n” : “ff” ) A_Index )
; —— —— ——
; —— —— CUSTOM LABEL SECTION —— ——
; winget isMax, MinMax, %ProgWinTitle1%
; msgbox %isMax%
msgbox 4, Stay Focussed, Are you sure you want to read your mails?, 5
; MsgBox % “A_ThisLabel:
t" A_ThisLabel "nProgWinTitle:
t" ProgWinTitle "nWinTrigger:
; ------ END OF CUSTOM LABEL SECTION ------ ------
If you are in e-mail processing mode simply pause or stop the script!
You can of course follow the instructions in the script to watch for multiple windows and take action on each of them.
I hope you find it as useful as I do.