]> Tony Duckles's Git Repositories (git.nynim.org) - autohotkey-scripts.git/blob - GmailKeys.ahk
Init AutoHotKey
[autohotkey-scripts.git] / GmailKeys.ahk
1 ;*******************************************************************************
2 ; Information
3 ;*******************************************************************************
4 ; AutoHotkey Version: 1.x
5 ; Language: English
6 ; Platform: XP/Vista/7
7 ; Author: Lowell Heddings (How-To Geek)
8 ; URL: http://lifehacker.com/5175724/add-gmail-shortcuts-to-outlook-with-gmail-keys
9 ; Real Author: Original script by Jayp: http://www.ocellated.com/2009/03/18/pimping-microsoft-outlook/
10 ;
11 ; Script Function: Gmail Keys adds Gmail Shortcut Keys to Outlook
12 ;
13 ;*******************************************************************************
14 ; Version History
15 ;*******************************************************************************
16 ; 0.1 release - initial set of hotkeys
17 ;*******************************************************************************
18
19
20 #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
21 SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
22 ;#NoTrayIcon
23 SendMode Input ; superior speed and reliability.
24 SetTitleMatchMode 2 ;allow partial match to window titles
25
26 ;********************
27 ;Hotkeys for Outlook
28 ;********************
29
30 ;As best I can tell, the window text 'NUIDocumentWindow' is not present
31 ;on any other items except the main window. Also, I look for the phrase
32 ; ' - Microsoft Outlook' in the title, which will not appear in the title (unless
33 ;a user types this string into the subject of a message or task).
34 #IfWinActive - Microsoft Outlook ahk_class rctrl_renwnd32, NUIDocumentWindow
35 e::HandleOutlookKeys("!.", "e") ;calls archive macro
36 f::HandleOutlookKeys("!w", "f") ;forwards message
37 r::HandleOutlookKeys("!r", "r") ;replies to message
38 ; a::HandleOutlookKeys("^+r", "a") ;reply all
39 v::HandleOutlookKeys("^+v", "v") ;Move message box
40 +u::HandleOutlookKeys("^u", "+u") ;marks messages as unread
41 +i::HandleOutlookKeys("^q", "+i") ;marks messages as read
42 j::HandleOutlookKeys("!{Down}", "j") ;move down in list
43 +j::HandleOutlookKeys("+!{Down}", "+j") ;move down and select next item
44 k::HandleOutlookKeys("!{Up}", "k") ;move up
45 +k::HandleOutlookKeys("+!{Up}", "+k") ;move up and select next item
46 o::HandleOutlookKeys("^o", "o") ;open message
47 ;s::HandleOutlookKeys("{Insert}", "s") ;toggle flag (star)
48 c::HandleOutlookKeys("^n", "c") ;new message
49 /::HandleOutlookKeys("^e", "/") ;focus search box
50 .::HandleOutlookKeys("+{F10}", ".") ;Display context menu
51 #::HandleOutlookKeys("{Delete}", "#") ;delete message
52 ^g::HandleOutlookKeys("^y", "^g") ;goto folder
53 #IfWinActive
54
55 ;Passes Outlook a special key combination for custom keystrokes or normal key value, depending on context
56 HandleOutlookKeys( specialKey, normalKey ) {
57 ;Activates key only on main outlook window, not messages, tasks, contacts, etc.
58 IfWinActive, - Microsoft Outlook ahk_class rctrl_renwnd32, NUIDocumentWindow, ,
59 {
60
61 ;Find out which control in Outlook has focus
62 ControlGetFocus, currentCtrl
63 ;MsgBox, Control with focus = %currentCtrl%
64
65 ;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.
66 ;Currently I handle archiving when viewing attachments of Word, Excel, Powerpoint, Text, jpgs, pdfs
67 ;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...
68 ctrlList = Acrobat Preview Window1,AfxWndW5,AfxWndW6,EXCEL71,MsoCommandBar1,OlkPicturePreviewer1,paneClassDC1, RichEdit20WPT2,RichEdit20WPT4,RichEdit20WPT5,RICHEDIT50W1,SUPERGRID1,_WwG1
69
70 if currentCtrl in %ctrlList%
71 {
72 Send %specialKey%
73 ;Allow typing normalKey somewhere else in the main Outlook window. (Like the search field or the folder pane.)
74 } else {
75 Send %normalKey%
76 }
77
78 ;Allow typing normalKey in another window type within Outlook, like a mail message, task, appointment, etc.
79 } else {
80 Send %normalKey%
81 }
82 }