I think I see the intent of using WinSetState. I tried it but still had the problem that the task bar item was unresponsive.
I added a Function so I could monitor the window state. It seemed to follow what one would expect when Win+D activated, WinGetState was 23 so it was being seen as minimized, enabled etc.
I resolved the problem by adding the WinGetState line:
Case $GUI_EVENT_MINIMIZE
GUISetState(@SW_MINIMIZE)
GUISetState(@SW_HIDE)
TraySetState(1) ; show
TraySetToolTip("AutoIt Scripts")
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
If BitAND(WinGetState("AutoIt Scripts"), 16) Then TraySetState(1) ; show
WEnd
Func SpecialEvent() ; restore from tray
GUISetState(@SW_RESTORE)
GUISetState(@SW_SHOW)
TraySetState(2) ; hide
EndFunc ;==>SpecialEvent
That ensures the tray icon is visible when the GUI is minimized by whatever means. If externally minimized, the task bar item appeared as well as the tray icon but I can live with that (not a normal situation). I tried Melba23's lines on top of that addition - it did not immediately improve things so I called it a day. It's now usable.
Thanks all.
Edited by JohnSAutoIt, 13 May 2012 - 01:19 AM.