Trying to configure key combination Alt+Tab to behave as tab switcher in Firefox with the help of AutoHotKey:
#IfWinActive Showcase
LAlt & Tab::Send {tab}
GetKeyState, state, LAlt
if state = U
Send {enter}
Basically this prevents Alt+Tab from bringing up the ordinary window switcher of Windows and cycles through open tabs as Tab is being pushed. However, as i’m trying to simulate the behaviour of Windows’ window switcher, i also want this to bring up – Send {enter}
– the last selected tab when Left Alt is released. And this i can’t seem to accomplish, as GetKeyState
just won’t respond, even though state
becomes U
. How can key release be detected in this case?
ADD:
So i ended up with the following code, which for the dominant part does what i wanted:
#IfWinActive ahk_exe firefox.exe ; Alt+Tab to Windows
LAlt & tab::
Send {F10} ; F10 brings up Showcase in my FF installation
WinWaitActive Showcase
GetKeyState, state, LAlt, P
if state = U
WinClose Showcase
IfWinNotActive Showcase
Send {LWin}
#IfWinActive Showcase ; Alt+Tab over Firefox’s tabs
LAlt & tab::
Send {tab}
SetTimer, choice, -50
return
choice: ; Thanks, @user3419297!
KeyWait, LAlt, P
IfWinActive Showcase
Send {LAlt up} {space}
return
#IfWinActive ahk_exe firefox.exe ; Win+Tab over Firefox’s tabs
LWin::F10
#IfWinActive Showcase ; Win+Tab to Windows
tab::return
LWin & tab::
WinClose Showcase
WinWaitClose Showcase
WinMinimize ahk_exe firefox.exe
Send {LWin down} {tab} {LWin up}
return
ExitApp
This in fact simulates both Alt+ & Win+Tab behaviour in Firefox, which i usually use in fullscreen mode:
- pushing Tab while holding down Alt will cycle through open tabs the same way Alt+Tab cycles windows
- to get out of FF to Windows, Alt+Tab are quickly pushed and released; this will bring up the Start Menu from where one can use Alt+Tab the normal way
- Win+Tab work a bit differently in Windows, in the way that one don’t need to hold down Win for it to stay up, and (at least in Windows 10) one can’t cycle through windows with Tab; this is also simulated the same way here by pushing Win+Tab (actually just Win is enough, but for consistency i press both); Tab is also blocked so it can’t cycle, to simulate the way real Win+Tab works in Windows
- to get out of Firefox’s Win+Tab to Windows, the said combo is pushed once more – this will bring up the normal Win+Tab of Windows 10; the taskbar can also be easily accessed this way
Since i didn’t know any AutoHotKey before, looking back this was probably a bit of an overkill task to start with. However, this did force me to actually learn how to programme in AHK, while dusting off my overall programming skill. And for that this has been great. I often found myself instinctively pushing Alt+Tab inside Firefox to cycle through tabs as one would do with windows, only to be reminded that this in fact only works with windows in Windows. Until recently, that is :)
Ctrl
+Tab
has been around for quite some time. Thank you very much for your answer; i have expanded the code and will be sharing it soon in the original question. – Россарх