#SingleInstance force
; show desktop
Send "#d"
Sleep 1000
; get window handles
hwnd1 := WinGetList()
; time out 60s.
Loop 60
{
Sleep 1000
; window handles monitoring
hwnd2 := WinGetList()
if getString(hwnd1) != getString(hwnd2)
break
if GetKeyState("Esc")
break
}
; window restore
for index, value in hwnd2
{
hwnd := hwnd2[hwnd2.Length - index + 1]
if WinExist(hwnd)
WinActivate(hwnd)
}
; helper function
getString(array)
{
ret := ""
for index, value in array
ret .= "|" . value
ret := LTrim(ret, "|")
return ret
}