🧰 AutoHotkey v2

Cycle Windows of the Same App

Alt+` cycles through all open windows belonging to the same application as the active window, like Alt+Tab but scoped to one app.

By WindowsScripting.com · 846 B
CycleWindowsSameApp.ahk
; ============================================================
; CycleWindowsSameApp.ahk
;
; Alt+` cycles through open windows of the SAME application as the
; currently active window (similar to macOS Cmd+`).
;
; Requirements: AutoHotkey v2 (https://www.autohotkey.com/)
; ============================================================

#Requires AutoHotkey v2.0

!`::{
    activeExe := WinGetProcessName("A")
    activeId := WinGetID("A")

    windows := WinGetList("ahk_exe " activeExe)
    if (windows.Length <= 1)
        return

    foundCurrent := false
    for id in windows {
        if (foundCurrent) {
            WinActivate("ahk_id " id)
            return
        }
        if (id = activeId)
            foundCurrent := true
    }
    ; wrapped around — activate the first window in the list
    WinActivate("ahk_id " windows[1])
}