Here is the code:
Code: Select all
Unique_Alt_Tab_Windows()
{
alt_tab_list := Array()
class_list := ""
WinGet, window_list, List
Loop % window_list
{
this_hwnd := window_list%A_Index%
WinGet, this_style, Style, ahk_id %this_hwnd%
if (this_style & 0x10000000) && (this_style & 0x10000) ; 0x10000000 is WS_VISIBLE. 0x10000 is WS_MAXIMIZEBOX
{
WinGetTitle, this_title, ahk_id %this_hwnd%
if((this_title = "") || (this_title = "Start"))
continue
else
{
WinGetClass, this_class, ahk_id %this_hwnd%
if !InStr(class_list, this_class)
{
alt_tab_list.Insert(this_hwnd)
class_list .= this_class . "|"
}
}
}
}
return alt_tab_list
}
Code: Select all
#IfWinActive
!Tab::
alt_tab_list := Unique_Alt_Tab_Windows()
initial_window := alt_tab_list[2]
WinActivate, ahk_id %initial_window%
active_index := 2
Loop
{
KeyWait, Tab, DT0.5
if !ErrorLevel
{
active_index++
this_window := alt_tab_list[active_index]
WinActivate, ahk_id %this_window%
}
if(active_index >= alt_tab_list.MaxIndex())
{
alt_tab_list := Unique_Alt_Tab_Windows()
active_index := 1
}
} until (!GetKeyState("Alt", "P"))
return