Last active
April 7, 2023 18:04
-
-
Save Geczy/920c06dc8b135e62e76b27cae1335b0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Define a global variable to keep track of the next window index | |
global NextWindow := 1 | |
; Hotkey: Alt + ` | |
!`:: | |
; Get the process name and ID of the active window | |
WinGet, ActiveProcessName, ProcessName, A | |
WinGet, ActiveWindowID, ID, A | |
; Get a list of all windows associated with the active process | |
WinGet, WinClassList, List, ahk_exe %ActiveProcessName% | |
; Get the total number of windows in the list | |
WinClassCount := WinClassList.Count() | |
; If there is only one window, do nothing and return | |
if (WinClassCount <= 1) { | |
return | |
} | |
; Find the next window to activate | |
while (true) { | |
; Increment the index for the next window | |
NextWindow := (NextWindow < WinClassCount) ? (NextWindow + 1) : 1 | |
; Get the HWND (unique identifier) of the next window in the list | |
NextWindowHWND := WinClassList[NextWindow] | |
; Skip the active window | |
if (NextWindowHWND != ActiveWindowID) { | |
break | |
} | |
} | |
; Bring the next window to the front and activate it | |
WinSet, Top,, ahk_id %NextWindowHWND% | |
WinActivate, ahk_id %NextWindowHWND% | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment