action.Window.Minimize();
// Store the window that was just minimized
sp.StoreObject("LastMinimized", action.Window);
// In a try/catch in case there is none stored, it fails silently
try {
// Restore the last minimized window
sp.GetStoredObject("LastMinimized").Restore();
} catch {}