After experimenting I see that my script doesn't take account of minimized windows, which is a main reason to use AltTab in the first place.. Duh!!
So now I get the window position and if either the x or y is < 0 then it's minimized, so I wait a short number of loops with a 1/10th second sleep for the window to open, then put the mouse cursor near the origin. Here's the revised section of code:
While (x < 0 Or y < 0)
The rest of the code just does Tray menu stuff.
A compiled version is on my hotkeys