Is there a way to capture when someone clicks the X on an IE window to close the window? I am using the internet explorer object to create some custom input boxes and I want to perform a subroutine if the user click on the X to close the window.
I know if I use the Sub IE_OnQuit() the script will branch to that subroutine but it also branches there if I close the window with an objexplorer.quit which I use when the user click on the OK or Cancel button.
Thanks
ddnwolff
I know if I use the Sub IE_OnQuit() the script will branch to that subroutine but it also branches there if I close the window with an objexplorer.quit which I use when the user click on the OK or Cancel button.
Code:
a=winputbox("title","messagetext",var1,var2,0)
Sub GetFormValueOK ' Ok Button
objexplorer.quit
WInputBoxData=objexplorer.document.Form1.displayname.value & "," & objexplorer.document.Form1.emailaddr.value
Finished= True
End Sub
Sub IE_OnQuit()
' code I am looking for
End Sub
Function WInputbox(prompt,title,dname,eaddr,errorcode)
Set objexplorer = WScript.CreateObject("InternetExplorer.Application", "IE_")
objexplorer.Left = 50
objexplorer.Top = 100
objexplorer.Height = 250
objexplorer.Width = 500
objexplorer.MenuBar = 0
objexplorer.ToolBar = 0
objexplorer.StatusBar = 0
objexplorer.navigate "about:blank"
objexplorer.Visible = 1
Do While (objexplorer.Busy)
WScript.Sleep 300
Loop
Set doc1 = objexplorer.Document
doc1.writeln("<html><head><title>" & title & "</title></head>")
doc1.Writeln "<body STYLE=""font:6pt arial; color:Yellow;" & " filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0," StartColorStr='#000000', EndColorStr='#0000FF')"">"
doc1.Writeln "<font size = 3 color = silver>"
doc1.writeln("<font color=yellow><center>" & Prompt & "</center></font>")
doc1.writeln("<form name=""Form1"">")
doc1.writeln("<p><input name=""displayname"" size=""50"" maxlength=""50"" value=" & Chr(34) & dname & Chr(34) & "><font color=""yellow""> Display Name</font>")
doc1.writeln("<p><input name=""emailaddr"" size=""50"" maxlength=""50"" value=" & eaddr & "><font color=""yellow"">Email Address</font>")
doc1.writeln("<p><INPUT type=""button"" align=middle value=""Ok"" name=""Ok"" >")
doc1.writeln("<INPUT type=""button"" align=middle value=""Cancel""name=""Cancel"" >")
doc1.writeln("</FORM>")
Select Case errorcode
Case 0
doc1.writeln("")
doc1.writeln("</body></html>")
doc1.form1.displayname.focus()
Case 1
doc1.writeln("<font color=red>Display Name Required</font>")
doc1.writeln("</body></html>")
doc1.form1.displayname.focus()
Case Else
doc1.writeln("<font color=red>Email Address Required</font>")
doc1.writeln("</body></html>")
doc1.form1.emailaddr.focus()
End Select
Set oButtonOK=objexplorer.document.getElementByID("Ok")
Set oButtonOK.onclick = GetRef("GetFormValueOK")
Set oButtonCancel=objexplorer.document.getElementByID("Cancel")
Set oButtonCancel.onclick = GetRef("GetFormValueCancel")
Finished=False
Do While (Not Finished) ' Wait until a button is pressed.
WScript.Sleep 100
Loop
Set objexplorer=Nothing
WinputBox=WInputBoxData
end function
Thanks
ddnwolff