Programatically Minimize and Maximize main Terminal Window. How?

 

I have played around for hours now and got nowhere. I need to be able to automatically minimize and then maximize the main MetaTrader window (not a chart window).

This is because when you run an EA on MetaTrader it slowly uses up the ram. Open the task manager and watch it do this. But when you minimize MetaTrader and then Maximize it again it releases all the ram it used up back to the system. It's very strange and I figure it's a memory leak with MetaTrader.

So I guess, any suggestions on the memory leak or programatically minimizing and maximizing the window would be greatly appreciated

Reason: