Solving #2923057 and #2786440 (cmd.exe cannot be minimized to tray)
After some short debugging I found the reason. Some windows are minimized instead of hidden because SW_MINIMIZE needs more time than SW_HIDE and therefore in some cases SW_MINIMIZE is finished after SW_HIDE in the next line.
One solution would be to check the state and do a Sleep(5) until it's minimized (or five seconds are over), but there is a much better solution:
Simply use SW_FORCEMINIMIZE instead of SW_MINIMIZE. If I'm right this also removes the minimize animation, therefore we can remove the SW_HIDE before this line, too.
Rechecked with Win7. Because of additional animations a small Sleep seems to be necessary:
// Hide before minimizing to disable animation. Hide again because
// minimizing may cause the window to show.
// ShowWindow(hwnd, SW_HIDE);
ShowWindow(hwnd, SW_FORCEMINIMIZE); // Patch by sf-mensch: SW_MINIMIZE needs more time than SW_FORCEMINIMIZE
Sleep(100); // Patch by sf-mensch: On Win7, additional time is still needed. Because of SW_FORCEMINIMIZE 100ms seems to be enough (at least on my PC).
I'll include this in the next version.