Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Making Gmail keyboard shortcuts for Outlook 2010


  • Please log in to reply
8 replies to this topic
tymyrick
  • Members
  • 4 posts
  • Last active: May 05 2017 08:38 PM
  • Joined: 12 Jan 2012
In 2009, the How-To Geek posted an AutoHotKey script on Lifehacker that gave Outlook keyboard shortcut keys similar to Gmail (http://lifehacker.co...with-gmail-keys). I have been using it religiously ever since at work on an XP machine with Outlook 2007. Now I have updated to Outlook 2010 and the script does not work anymore.

With a little help and a lot of banging around, I figured out nothing I knew to do would fix that script, but I was able to write a simpler version that was a partial success.

#IfWinActive, Inbox
j::Send, {DOWN}    ;next message
k::Send, {Up}    ;previous message
r::Send, ^r     ;reply to email
a::Send, ^+r    ;reply to all
f::Send, ^f    ;forward email
y::Send, ^+1    ;archive message
+u::Send, ^u    ;mark message as unread
+i::Send, ^q    ;mark message as read
s::Send, ^+g    ;set flag (star)
c::Send, ^n    ;new message
/::Send, ^e    ;focus search box
.::Send, +{F10}    ;display context menu
v::Send, !hmvo    ;move message box
l::Send, !3    ;categorize message
#IfWinActive

This script works as long as I am in by own Inbox, but it will not work in any other folder. For some reason, AutoHotKey cannot recognize the main Outlook 2010 window by anything that is not the start of the window name. I even tried setting SetTitleMatchMode to 2.

If anyone can help me fix the original script, or help me figure out how to get the simpler script to work in any Outlook folder, I would greatly appreciate it. Thank you.

  • Guests
  • Last active:
  • Joined: --

For some reason, AutoHotKey cannot recognize the main Outlook 2010 window by anything that is not the start of the window name. I even tried setting SetTitleMatchMode to 2.

Do you remember the code you tried? If so post it.

tymyrick
  • Members
  • 4 posts
  • Last active: May 05 2017 08:38 PM
  • Joined: 12 Jan 2012
This is the original code that the How-to Geek posted to Lifehacker:

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
;	#NoTrayIcon
SendMode Input ; superior speed and reliability.
SetTitleMatchMode 2 ;allow partial match to window titles

   ;********************
   ;Hotkeys for Outlook
   ;********************

   ;As best I can tell, the window text 'NUIDocumentWindow' is not present 
   ;on any other items except the main window. Also, I look for the phrase
   ; ' - Microsoft Outlook' in the title, which will not appear in the title (unless 
   ;a user types this string into the subject of a message or task).
   #IfWinActive - Microsoft Outlook ahk_class rctrl_renwnd32, NUIDocumentWindow
	y::HandleOutlookKeys("!.", "y") ;calls archive macro
	f::HandleOutlookKeys("!w", "f") ;forwards message
	r::HandleOutlookKeys("!r", "r") ;replies to message
	a::HandleOutlookKeys("^+r", "a") ;reply all
	v::HandleOutlookKeys("^+v", "v") ;Move message box
	+u::HandleOutlookKeys("^u", "+u") ;marks messages as unread
	+i::HandleOutlookKeys("^q", "+i") ;marks messages as read
	j::HandleOutlookKeys("!{Down}", "j") ;move down in list
	+j::HandleOutlookKeys("+!{Down}", "+j") ;move down and select next item
	k::HandleOutlookKeys("!{Up}", "k") ;move up
	+k::HandleOutlookKeys("+!{Up}", "+k") ;move up and select next item
	o::HandleOutlookKeys("^o", "o") ;open message
	s::HandleOutlookKeys("{Insert}", "s") ;toggle flag (star)
	c::HandleOutlookKeys("^n", "c") ;new message
	/::HandleOutlookKeys("^e", "/") ;focus search box
	.::HandleOutlookKeys("+{F10}", ".") ;Display context menu
   #IfWinActive

   ;Passes Outlook a special key combination for custom keystrokes or normal key value, depending on context
   HandleOutlookKeys( specialKey, normalKey ) {
      ;Activates key only on main outlook window, not messages, tasks, contacts, etc. 
      IfWinActive, - Microsoft Outlook ahk_class rctrl_renwnd32, NUIDocumentWindow, ,
      {
      
         ;Find out which control in Outlook has focus
         ControlGetFocus, currentCtrl
         ;MsgBox, Control with focus = %currentCtrl%
            
         ;set list of controls that should respond to specialKey. Controls are the list of emails and the main (and minor) controls of the reading pane, including controls when viewing certain attachments.
         ;Currently I handle archiving when viewing attachments of Word, Excel, Powerpoint, Text, jpgs, pdfs
         ;The control 'RichEdit20WPT1' (email subject line) is used extensively for inline editing. Thus it had to be removed. If an email's subject has focus, it won't archive...
         ctrlList = Acrobat Preview Window1,AfxWndW5,AfxWndW6,EXCEL71,MsoCommandBar1,OlkPicturePreviewer1,paneClassDC1, RichEdit20WPT2,RichEdit20WPT4,RichEdit20WPT5,RICHEDIT50W1,SUPERGRID1,_WwG1
         
         if currentCtrl in %ctrlList%
         {
            Send %specialKey%
         ;Allow typing normalKey somewhere else in the main Outlook window. (Like the search field or the folder pane.)
         } else {
            Send %normalKey%
         }
         
      ;Allow typing normalKey in another window type within Outlook, like a mail message, task, appointment, etc.
      } else {
         Send %normalKey%
      }
   }


whiscolo
  • Guests
  • Last active:
  • Joined: --
I'm using this script and it works. My only problem is that I can't detect when the focus is no the search box, so I can't type there the letter reserved for the script, because this is then triggered. Is there a way to know when am I in the search box of the inbox?

Cheers,

LEo

sinkfaze
  • Moderators
  • 6367 posts
  • Last active: Nov 30 2018 08:50 PM
  • Joined: 18 Mar 2008
You can poll the control that has focus to see when it changes:

ControlGetFocus, b	[color=#00BF00]; gets the control that currently has focus[/color]
a :=	b	[color=#00BF00]; passes that same value to a comparison var[/color]
While	(a=b)	[color=#00BF00]; while those two vars are the same, will break when they are different[/color]
{
	ControlSend, ahk_parent, ^e	[color=#00BF00]; send the command to the window[/color]
	Sleep, 100	[color=#00BF00]; short delay[/color]
	ControlGetFocus, a	[color=#00BF00]; get which control now has focus[/color]
}
TrayTip, , Complete!
Sleep, 1000
TrayTip


tymyrick
  • Members
  • 4 posts
  • Last active: May 05 2017 08:38 PM
  • Joined: 12 Jan 2012
I was finally able to get GmailKeys for Outlook 2010 up and running if anyone wants to use it.

;*******************************************************************************
;				                          Information					
;*******************************************************************************
; AutoHotkey Version: 	2.x
; Language:       		English
; Platform:       		XP/Vista/7
; Updated by: 				Ty Myrick 
; Author: 					Lowell Heddings (How-To Geek)
; URL: 						http://lifehacker.com/5175724/add-gmail-shortcuts-to-outlook-with-gmail-keys
; Original script by: 	Jayp 
; Original URL: 			http://www.ocellated.com/2009/03/18/pimping-microsoft-outlook/
;
; Script Function: Gmail Keys adds Gmail Shortcut Keys to Outlook 
; Version 2.x updated for Outlook 2010 
;
;*******************************************************************************
;				                          Version History					
;*******************************************************************************
; Version 2.0 - updated by Ty Myrick to work with Outlook 2010 
; Version 1.0 - updated by Lowell Heddings 
; Version 0.1 - initial set of hotkeys by Jayp
;*******************************************************************************


#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetTitleMatchMode 2 ;allow partial match to window titles




;************************
;Hotkeys for Outlook 2010 
;************************

;As best I can tell, the window text 'NUIDocumentWindow' is not present on any other items except the main window. Also, I look for the phrase ' - Microsoft Outlook' in the title, which will not appear in the title (unless a user types this string into the subject of a message or task).

	#IfWinActive, - Microsoft Outlook ahk_class rctrl_renwnd32, NUIDocumentWindow
		y::HandleOutlookKeys("^+1", "y") 		;archive message using Quick Steps hotkey 
		f::HandleOutlookKeys("^f", "f") 			;forwards message 
		r::HandleOutlookKeys("^r", "r") 			;replies to message 
		a::HandleOutlookKeys("^+r", "a") 		;reply all 
;		v::HandleOutlookKeys("^+v", "v") 		;move message box 
		+u::HandleOutlookKeys("^u", "+u") 		;marks messages as unread 
		+i::HandleOutlookKeys("^q", "+i") 		;marks messages as read 
		j::HandleOutlookKeys("{Down}", "j") 	;move down in list 
		+j::HandleOutlookKeys("+{Down}", "+j") ;move down and select next item 
		k::HandleOutlookKeys("{Up}", "k") 		;move up 
		+k::HandleOutlookKeys("+{Up}", "+k") 	;move up and select next item 
		o::HandleOutlookKeys("^o", "o") 			;open message
;		s::HandleOutlookKeys("{Insert}", "s") ;toggle flag (star) 
		s::HandleOutlookKeys("^+g", "s") 		;set follow up options (star) 
		c::HandleOutlookKeys("^n", "c") 			;new message 
		/::HandleOutlookKeys("^e", "/") 			;focus search box 
		.::HandleOutlookKeys("+{F10}", ".") 	;Display context menu 
		l::HandleOutlookKeys("!3", "l") 			;categorize message by calling All Categories hotkey from Quick Access Toolbar 
	#IfWinActive



;Passes Outlook a special key combination for custom keystrokes or normal key value, depending on context

	HandleOutlookKeys( specialKey, normalKey ) 
	{

		;Activates key only on main outlook window, not messages, tasks, contacts, etc. 
		IfWinActive, - Microsoft Outlook ahk_class rctrl_renwnd32, NUIDocumentWindow, ,
      {

			;Find out which control in Outlook has focus
			ControlGetFocus currentCtrl, A 
;			MsgBox, Control with focus = %currentCtrl%

			;Set list of controls that should respond to specialKey. Controls are the list of emails and the main (and minor) controls of the reading pane, including controls when viewing certain attachments.
			;Currently I handle archiving when viewing attachments of Word, Excel, Powerpoint, Text, jpgs, pdfs
			;The control 'RichEdit20WPT1' (email subject line) is used extensively for inline editing. Thus it had to be removed. If an email's subject has focus, it won't archive...
			ctrlList = Acrobat Preview Window1,AfxWndW5,AfxWndW6,EXCEL71,MsoCommandBar1,OlkPicturePreviewer1,paneClassDC1, RichEdit20WPT2,RichEdit20WPT4,RichEdit20WPT5,RICHEDIT50W1,SUPERGRID2,SUPERGRID1,_WwG1

			if currentCtrl in %ctrlList%
			{
;				MsgBox, Control in list.
				Send %specialKey%

         } 
			;Allow typing normalKey somewhere else in the main Outlook window. (Like the search field or the folder pane.)
			else 
				{
;					MsgBox, Control not in list.
					Send %normalKey%
				}

      }
      ;Allow typing normalKey in another window type within Outlook, like a mail message, task, appointment, etc.
		else 
			{
				Send %normalKey%
			}
	}




dstroot
  • Members
  • 1 posts
  • Last active: Jan 23 2013 12:11 AM
  • Joined: 22 Jan 2013

For the life of me I cannot seem to get this to work!  I think its a cut/paste error and I've tried reformatting all different ways.  Arg...  Anyone have any suggestions?



tymyrick
  • Members
  • 4 posts
  • Last active: May 05 2017 08:38 PM
  • Joined: 12 Jan 2012

@dstroot,

 

I spent a lot of time trying to get this to work with no success even though other people said it worked fine for them. I think what finally made it work for me was adding "SuperGrid2" to the ctrlList. The original script listed "SuperGrid1", but not "SuperGrid2". I found the information using AutoIt3 Window Spy (included in my installation of AutoHotKey).

 

With it running, when I clicked on an email in the Inbox, AutoIt3 Window Spy lists the "ClassNN:" field as either "SuperGrid1" or "SuperGrid2". Maybe your installation of Outlook designates a different field number.

 

Also, for some reason, #IfWinActive, - Microsoft Outlook ahk_class rctrl_renwnd32, NUIDocumentWindow does not work for me without the comma after #IfWinActive. Even though it did work without the comma when I was using Outlook 2007. Try removing that comma and see if it works.



Saibot
  • Members
  • 3 posts
  • Last active: Mar 29 2016 10:29 PM
  • Joined: 20 Feb 2014

Update for Outlook 2013 can be found here.