Skip to content

Instantly share code, notes, and snippets.

@ajkessel
Last active July 1, 2025 18:04
Show Gist options
  • Save ajkessel/d0ab0ba04c53aaf86c8527614344d7ef to your computer and use it in GitHub Desktop.
Save ajkessel/d0ab0ba04c53aaf86c8527614344d7ef to your computer and use it in GitHub Desktop.
#include UIA-v2\Lib\UIA.ahk
#include UIA-v2\Lib\UIA_Browser.ahk
#HotIf WinActive("ahk_exe msedge.exe")
; ctrl-shift-w: close other tabs
^+w:: {
WinWaitActive "ahk_exe msedge.exe"
edgeWindow := UIA.ElementFromHandle("ahk_exe msedge.exe")
edge := UIA_Edge("")
tab := edge.GetTab()
tab.ShowContextMenu()
closeButton := edgeWindow.FindElement([{name:"Close other tabs"}])
closeButton.Click()
}
; ctrl-shift-r: close tabs to right
^+r:: {
WinWaitActive "ahk_exe msedge.exe"
edgeWindow := UIA.ElementFromHandle("ahk_exe msedge.exe")
edge := UIA_Edge("")
tab := edge.GetTab()
tab.ShowContextMenu()
closeButton := edgeWindow.FindElement([{name:"Close tabs to the right"}])
closeButton.Click()
}
; ctrl-shift-n: move tab to new window
^+n:: {
WinWaitActive "ahk_exe msedge.exe"
edgeWindow := UIA.ElementFromHandle("ahk_exe msedge.exe")
edge := UIA_Edge("")
tab := edge.GetTab()
tab.ShowContextMenu()
closeButton := edgeWindow.FindElement([{name:"Move tab to"}])
closeButton.Click()
closeButton := edgeWindow.FindElement([{name:"New window"}])
closeButton.Click()
}
#HotIf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment