Code: Select all
#SingleInstance force
#Persistent
; ****************************************************************************
; * Next App Window *
; ****************************************************************************
!`::
WinGet, currentwindow,, A
WinGet, activeprocess, ProcessName, A
WinGet, winids, List, ahk_exe %activeprocess%
arr := []
Loop, %winids%
{
id := winids%A_Index%
arr.Push(id)
}
SortArray(arr)
activeIndex := 0
for index, element in arr
{
If (element = currentwindow)
activeIndex := index
}
nextIndex := % Mod(activeIndex + 1, winids)
If (%nextIndex% = 0)
nextIndex := winids
elem := arr[nextIndex]
WinSet, AlwaysOnTop, On, ahk_id %elem%
WinSet, AlwaysOnTop, Off, ahk_id %elem%
WinActivate, ahk_id %elem%
return
!+`:: ; Previous App Window
WinGet, currentwindow,, A
WinGet, activeprocess, ProcessName, A
WinGet, winids, List, ahk_exe %activeprocess%
arr := []
Loop, %winids%
{
id := winids%A_Index%
arr.Push(id)
}
SortArray(arr)
activeIndex := 0
for index, element in arr
{
If (element = currentwindow)
activeIndex := index
}
nextIndex := % Mod(activeIndex - 1, winids)
If (%nextIndex% = 0)
nextIndex := winids
elem := arr[nextIndex]
WinSet, AlwaysOnTop, On, ahk_id %elem%
WinSet, AlwaysOnTop, Off, ahk_id %elem%
WinActivate, ahk_id %elem%
return
SortArray(Array, Order="A") {
;Order A: Ascending, D: Descending, R: Reverse
MaxIndex := ObjMaxIndex(Array)
If (Order = "R") {
count := 0
Loop, % MaxIndex
ObjInsert(Array, ObjRemove(Array, MaxIndex - count++))
Return
}
Partitions := "|" ObjMinIndex(Array) "," MaxIndex
Loop {
comma := InStr(this_partition := SubStr(Partitions, InStr(Partitions, "|", False, 0)+1), ",")
spos := pivot := SubStr(this_partition, 1, comma-1) , epos := SubStr(this_partition, comma+1)
if (Order = "A") {
Loop, % epos - spos {
if (Array[pivot] > Array[A_Index+spos])
ObjInsert(Array, pivot++, ObjRemove(Array, A_Index+spos))
}
} else {
Loop, % epos - spos {
if (Array[pivot] < Array[A_Index+spos])
ObjInsert(Array, pivot++, ObjRemove(Array, A_Index+spos))
}
}
Partitions := SubStr(Partitions, 1, InStr(Partitions, "|", False, 0)-1)
if (pivot - spos) > 1 ;if more than one elements
Partitions .= "|" spos "," pivot-1 ;the left partition
if (epos - pivot) > 1 ;if more than one elements
Partitions .= "|" pivot+1 "," epos ;the right partition
} Until !Partitions
}