Here is one method that is simple, I'm not sure how reliable it is.
It works by trying to minimize the window, if it gets minimized then it means it is available on the taskbar.
You can get the list of found/active windows in any form you need, here I use arrays.
getWindows:
activeWindowsId := []
activeWindowsExe := []
newlist := ""
WinGet, List, List ;get the list of all windows
Sendinput, #m ;mimimize all windows by using the windows shortcut win+m
sleep, 200
;Loop % List ;or use this loop to minimze the windows
;{
; WinMinimize, % "ahk_id " List%A_Index%
;}
Loop % List
{
WinGet, theExe, ProcessName, % "ahk_id " List%A_Index% ;get the name of the exe
WinGet, windowState, MinMax, % "ahk_id " List%A_Index% ;get the state of the window, -1 is minimized, 1 is maximized, 0 is neither
if (windowState == -1) ;if the window is minimized
{
activeWindowsId.push(List%A_Index%) ;add the window id (hwnd) to this array
activeWindowsExe.push(theExe) ;add the window exe to this array
WinRestore, % "ahk_id " List%A_Index% ;restore the window
}
}
;read the found active windows list from the array to a string and show it with a msgbox
For index, exe in activeWindowsExe
{
newList .= exe "`n"
}
msgbox, % newList
return