Here's my AHKv2 script I use, which also works in Edge. It's one of many workarounds posted in reponse to a similar question for Chrome, many of which also work for Edge. It doesn't perfectly emulate Firefox behaviour but it's a step closer than the other AHK answer here in that you can switch through more than 1 of your most recently used tabs:
#Requires AutoHotkey v2.0
#SingleInstance Force
NPreviousTabs := 0
^Tab::{
global NPreviousTabs
If (WinActive("ahk_exe msedge.exe") or WinActive("ahk_exe Chrome.exe")) {
NPreviousTabs += 1
SwitchTabs(NPreviousTabs)
}
}
SwitchTabs(NPrev) {
Send "^+a"
; might make tab switcher appear faster
Send "{BackSpace}"
; by default last tab is already selected
; so we need to press down n-1 times to get the nth most recent tab
Sleep(75)
Loop NPrev-1 {
Send "{Down}"
Sleep(25)
}
Send "{Enter}"
}
OnCtrlUp(ih, vk, sc) {
global NPreviousTabs
; we send release control in SwitchTabs, so it's necessary to check if Ctrl is physically released
If (!GetKeyState("LControl", "P")) {
NPreviousTabs := 0
}
}
ih := InputHook("L0")
ih.KeyOpt("{LControl}", "+NV")
ih.OnKeyUp := OnCtrlUp
ih.VisibleText := True
ih.Start()
There are a few limitations:
- The tab stack is rearranged as you switch through them. With Firefox, one may hold Ctrl while pressing tab to scroll through the most recently used tabs, and only the tab that you release Ctrl on is brought to the top of the stack
- If you Ctrl+Tab too far, you will start selecting recently closed tabs
- The tab stack is shared across windows, unlike Firefox