var modalFrame = browser.FindModalHtmlDialog();
var coreObj = new ActiveXObject("OpenTwebst.Core");
var browser = coreObj.StartBrowser("http://www.codecentrix.com/tests/htmdlg.htm");
var openBtn = browser.FindElement("input button", "text=Open Modal Box");
// Click the button that opens the modal dialog.
openBtn.Click();
var modalFrame = browser.FindModalHtmlDialog();
WScript.Sleep(2000);
// Click the button that closes the modal dialog.
var closeBtn = modalFrame.FindElement("input button", "");
closeBtn.Click();