Thank you very much, now it works like a charm, though yes it seems close to be a bug.
This is the current version of the script I am using with a hotkey to unhide the previously hidden window.
I've included minimize and restore events in the script, to make it faster for the user to hide/unhide multiple windows repeatedly (without having to activate each window).
Code:
Menu, Tray, UseErrorLevel, On
; UnHide previously Hidden Window
#u::
if(HiddenWins <= 0)
return
temp := All%HiddenWins%
DetectHiddenWindows, On
WinGetTitle, WinTitle, ahk_id %temp%
DetectHiddenWindows, Off
WinShow, ahk_id %temp%
PostMessage, 0x112, 0xF120,,, ahk_id %temp% ; restore
MenuTitle := WinTitle " - " temp
HiddenWins--
if(HiddenWins = 0)
{
Menu, ShowMenu, DeleteAll
Menu, Tray, Delete, UnHide All
Menu, Tray, Delete, UnHide Windows
}
else
Menu, ShowMenu, Delete, %MenuTitle%
return
; Hide Active Window
#h::
WinGet, WinID, ID, A
WinGetClass, WinClass, A
WinGetTitle, WinTitle, A
; Don't make Transparent those special Windows
if(WinID = "" || WinClass = "Progman" || WinClass = "Shell_TrayWnd" || WinClass = "WorkerW")
return
HiddenWins++
All%HiddenWins% := WinID
if(HiddenWins = 1)
Menu, Tray, Add, UnHide All, UnHideAll
Menu, ShowMenu, Add, % WinTitle " - " WinID, ShowWin
Menu, Tray, Add, UnHide Windows, :ShowMenu
PostMessage, 0x112, 0xF020,,, A ; minimize to get focus on the other window
WinHide, ahk_id %WinID%
return
; Menu for Showing Hidden windows
ShowWin:
StringRight, temp, A_ThisMenuItem, 8
WinShow, ahk_id %temp%
PostMessage, 0x112, 0xF120,,, ahk_id %temp% ; restore
HiddenWins--
if(HiddenWins = 0)
{
Menu, ShowMenu, DeleteAll
Menu, Tray, Delete, UnHide All
Menu, Tray, Delete, UnHide Windows
}
else
Menu, ShowMenu, Delete, %A_ThisMenuItem%
return
; UnHide all Hidden Windows
UnHideAll:
Loop, %HiddenWins%
{
temp := All%A_Index%
WinShow, ahk_id %temp%
PostMessage, 0x112, 0xF120,,, ahk_id %temp% ; restore
}
HiddenWins := 0
Menu, ShowMenu, DeleteAll
Menu, Tray, Delete, UnHide All
Menu, Tray, Delete, UnHide Windows
return