The Window property returns a reference to the Window object associated with a custom task pane. This object represents the active InfoPath window associated with a custom task pane.
The following example runs from a custom task to access the active window to show a MailEnvelope object:
var objIWindow; objIWindow = window.external.Window; objIWindow.MailEnvelope.Visible = true;