some times we need to prompt input box for a password and we need to hide a password while it is being typed.
But it is not possible with normal VBScript . we can use the AOM for IE with VBScript to do this.
Following is the code
strPw = GetPassword( “Please enter your password:” )
msgbox “Your password is: ” & strPw
Function GetPassword( myPrompt )
‘ This function uses Internet Explorer to
‘ create a dialog and prompt for a password.
Dim objIE
‘ Create an IE object
Set objIE = CreateObject( “InternetExplorer.Application” )
‘ specify the IE settings
objIE.Navigate “about:blank”
objIE.Document.Title = “Password”
objIE.ToolBar = False
objIE.Resizable = False
objIE.StatusBar = False
objIE.Width = 300
objIE.Height = 180
‘ Center the dialog window on the screen
With objIE.Document.ParentWindow.Screen
objIE.Left = (.AvailWidth - objIE.Width ) \ 2
objIE.Top = (.Availheight - objIE.Height) \ 2
End With
‘ Insert the HTML code to prompt for a password
objIE.Document.Body.InnerHTML = “<DIV align=”"center”"><P>” & myPrompt _
& “</P>” & vbCrLf _
& “<P><INPUT TYPE=”"password”" SIZE=”"20″” ” _
& “ID=”"Password”"></P>” & vbCrLf _
& “<P><INPUT TYPE=”"hidden”" ID=”"OK”" ” _
& “NAME=”"OK”" VALUE=”"0″”>” _
& “<INPUT TYPE=”"submit”" VALUE=”" OK “” ” _
& “OnClick=”"VBScript:OK.Value=1″”></P></DIV>”
‘ Make the window visible
objIE.Visible = True
‘ Wait till the OK button has been clicked
Do While objIE.Document.All.OK.Value = 0
WScript.Sleep 200
Loop
‘ Read the password from the dialog window
GetPassword = objIE.Document.All.Password.Value
‘ Close and release the object
objIE.Quit
Set objIE = Nothing
End Function
The code will create the screen like this

Reference: Robvan der Woude
February 15, 2008 -
Posted by
quicktestprofessional |
VBScript and IE Automation |
hide a password, hide a password while it is being typed, QTP, VBScript |
4 Comments
Another thing i would like to ask you that “Do you have some idea about how to use QTP on mainframes? I am a project manager here on a mainframe project and we are planing to get do automation using QTP. I will greatly appriciate your help
Pari,
You have to use TE(Terminal Emulator)Addin for that.You have to buy that seperatly.
[...] I found a very useful function at the Quick Test Professional blog. It calls upon *shudder* Internet Explorer to create a password box for the user to type in the [...]
When I am using IE.Visible = TRUE, Application displays for a sec and disapperas,Is there ay method to display the form