" & _
"Username:" & _
"" & _
" " & _
"Password:" & _
"" & _
"" & _
"" & _
" " & _
""& _
""
Dim g_objIE
' First step, set up the dialog (InternetExplorer)
Set g_objIE = CreateObject("InternetExplorer.Application")
g_objIE.Offline = True
g_objIE.navigate "about:blank"
' This loop is required to allow the IE object to finish loading...
Do
crt.Sleep 100
Loop While g_objIE.Busy
' Make the custom dialog font to look more like standard Windows dialogs
g_objIE.Document.body.Style.FontFamily = "Sans-Serif"
' Here's where we "create" the elements of our dialog box. We basically
' throw HTML into the document, and IE loads it in real-time for us.
'
' The hidden "ButtonHandler" input is used to tie IE and
' SecureCRT together such that SecureCRT can know when a
' button is pressed, etc.
g_objIE.Document.Body.innerHTML = szHTMLBody
' Prevent the MenuBar, StatusBar, AddressBar, and Toolbar from being
' displayed as part of the IE window
g_objIE.MenuBar = False
g_objIE.StatusBar = False
g_objIE.AddressBar = False
g_objIE.Toolbar = False
' Set the initial size of the IE Window
g_objIE.height = 200
g_objIE.width = 450
g_objIE.document.Title = "Authentication Credentials Prompt"
g_objIE.Visible = True
' This loop is required to allow the IE window to fully display.
Do
crt.Sleep 100
Loop While g_objIE.Busy
' This code brings the IE window to the foreground.
Set objShell = CreateObject("WScript.Shell")
objShell.AppActivate g_objIE.document.Title
' Once the dialog is displayed and has been brought to the foreground,
' set focus on the control of our choice...
g_objIE.Document.All("Username").Focus
Do
' If the user closes the IE window by Alt+F4 or clicking on the 'X'
' button, we'll detect that here, and exit the script if necessary.
On Error Resume Next
Err.Clear
szNothing = g_objIE.Document.All("ButtonHandler").Value
if Err.Number <> 0 then exit do
On Error Goto 0
' Check to see which buttons have been clicked, and address each one
' as it's clicked.
Select Case g_objIE.Document.All("ButtonHandler").Value
Case "Cancel"
' The user clicked Cancel. Exit the dialog...
g_objIE.quit
Exit Do
Case "OK"
' The user clicked OK. Act on the information in the
' Username and Password fields
' Capture data from each field in the dialog...
szUsername = g_objIE.Document.All("Username").Value
szPassword = g_objIE.Document.All("Password").Value
g_objIE.quit
' Now that we have closed the IE dialog, we can act on our data
MsgBox "Here is the information you entered..." & vbcrlf & vbtab & _
"Username: " & szUsername & vbcrlf & vbtab & _
"Password: " & szPassword
Exit Do
End Select
' Wait for user interaction with the dialog...
crt.Sleep 200
Loop