Skip to content

Instantly share code, notes, and snippets.

@Navidda
Created February 20, 2025 08:53
Show Gist options
  • Save Navidda/4a613e17bb376188b74ef6f5e3e7a218 to your computer and use it in GitHub Desktop.
Save Navidda/4a613e17bb376188b74ef6f5e3e7a218 to your computer and use it in GitHub Desktop.
AHK (v1) script to switch between windows of the same application in Windows 11
!`::
WinGet, ActiveProcessName, ProcessName, A
WinGetClass, OldClass, A
WinGet, WindowList, List, ahk_exe %ActiveProcessName%
if (WindowList > 1) {
Loop, %WindowList% {
this_id := WindowList%A_Index%
WinGetClass, NewClass, ahk_id %this_id%
; Skip if it's the same as the currently active window
if (WinActive("ahk_id " this_id))
continue
; Focus on the new window if it matches the criteria
if (OldClass <> "CabinetWClass" or NewClass = "CabinetWClass") {
WinActivate, ahk_id %this_id%
break
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment