Tab & 1-9: Sends Ctrl+n (generally activates the nth tab).
Tab & q: Previous tab.
Tab & w: Sends Alt+D (generally focuses address bar).
Tab & e/Space: Next tab.
Applies to: Chrome 51 (and some older versions), Firefox (not tested recently)
Back-story:
I recently replaced my keyboard and I'm finding it harder to push Ctrl+Shift+Tab reliably, so I started to look in my hotkey script for the section specific to browsers, to add an easier hotkey for "previous tab". It turns out I already had a bunch of hotkeys for this purpose, written years ago and forgotten about. So I'm posting about them to aid my memory.
Code: Select all
; In the auto-execute section:
GroupAdd, WebBrowser, Google Chrome ahk_class Chrome_WidgetWin_0
GroupAdd, WebBrowser, Google Chrome ahk_class Chrome_WidgetWin_1
GroupAdd, WebBrowser, Mozilla Firefox ahk_class MozillaUIWindowClass
GroupAdd, WebBrowser, Mozilla Firefox ahk_class MozillaWindowClass
; Add browsers as needed.
; End auto-execute code.
#IfWinActive ahk_group WebBrowser
Tab::
; Temporarily enable Tab-combination hotkeys:
Hotkey IfWinActive, ahk_group WebBrowser
Loop 9
Hotkey %A_Index%, Tab_n, On
Hotkey Space, Tab_sp, On
Hotkey q, Tab_q, On
Hotkey w, Tab_w, On
Hotkey e, Tab_e, On
; Use KeyWait rather than Tab up:: because the latter will execute
; even if Tab:: didn't execute - e.g. sometimes when Alt-Tabbing to
; the browser. It also avoids the risk of the Tab-up being missed
; and these hotkeys not being turned off.
KeyWait Tab
; Activate normal Tab function on key-release:
if A_PriorKey = Tab
Send {Tab}
; Turn off Tab-combination hotkeys:
Loop 9
Hotkey %A_Index%, Off
Hotkey Space, Off
Hotkey q, Off
Hotkey w, Off
Hotkey e, Off
return
Tab_n:
Send % "^" A_ThisHotkey
return
Tab_q:
Send ^+{Tab}
return
Tab_w:
Send !d{End}
return
Tab_e:
Tab_sp:
Send ^{Tab}
return