Microsoft Outlook Incoming Mail

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ktwitten
Posts: 2
Joined: 18 Dec 2018, 12:04

Microsoft Outlook Incoming Mail

18 Dec 2018, 12:14

I'd like to setup an AutoHotKey script to automatically maximize Outlook upon the receipt of an unread email. I've got one for Outlook calendar notifications, but I've not been able to figure out how to do one for email though.

Thanks!
User avatar
FanaticGuru
Posts: 1906
Joined: 30 Sep 2013, 22:25

Re: Microsoft Outlook Incoming Mail

18 Dec 2018, 13:52

ktwitten wrote:
18 Dec 2018, 12:14
I'd like to setup an AutoHotKey script to automatically maximize Outlook upon the receipt of an unread email. I've got one for Outlook calendar notifications, but I've not been able to figure out how to do one for email though.

This might do what you want.

Code: Select all

#Persistent	; Script must continue to run to work

global olApp
olApp := ComObjActive("Outlook.Application")
ComObjConnect(olApp, "EventApp_")

EventApp_NewMail()
{
	olApp.ActiveWindow.WindowState := 0 ; olMaximized
}
Tested very little but this sets up an event to Maximize the Outlook ActiveWindow when a new email is received. I am not 100% sure the main Outlook window will always be the ActiveWindow but worked in my short testing.

This should at least get you your event then you can toy around with doing the action you want. Could just maximize Outlook with AHK window commands.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
ktwitten
Posts: 2
Joined: 18 Dec 2018, 12:04

Re: Microsoft Outlook Incoming Mail

18 Dec 2018, 14:17

Thanks!

WinActivate/WinMaximize did work better for that portion of the script, but without the first part of your script I would have never gotten it to work.

Here is the script I ended up using if someone else has the same problem...

Code: Select all

#Persistent	; Script must continue to run to work

global olApp
olApp := ComObjActive("Outlook.Application")
ComObjConnect(olApp, "EventApp_")

EventApp_NewMail()
{
	SetTitleMatchMode, 2
	IfWinExist, Unread Mail  ; The first mailbox I read
		{
		WinActivate
		Sleep 100
		WinMaximize
		}
		else
		{
		IfWinExist, Inbox-xxxxxxxx ; The 2nd mail box I read (replace xxxxxxx as needed so it matches your screen)
			{
			WinActivate
			Sleep 100
			WinMaximize
			}
			else
			{
			}
		}
		
}
Moderator Note: Added code tags. ~ sinkfaze

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 313 guests