(view source code of ieuserin.vbs as plain text)
strUserInput = GetUserInput( "Please enter your name:" )
WScript.Echo "Your name is: " & strUserInput
Function GetUserInput( myPrompt )
' This function uses Internet Explorer to' create a dialog and prompt for user input.'' Version: 2.11' Last modified: 2013-11-07'' Argument: [string] prompt text, e.g. "Please enter your name:"' Returns: [string] the user input typed in the dialog screen'' Written by Rob van der Woude' http://www.robvanderwoude.com' Error handling code written by Denis St-Pierre Dim objIE ' Create an IE objectSet objIE = CreateObject( "InternetExplorer.Application" )
' Specify some of the IE window's settingsobjIE.Navigate "about:blank"
objIE.Document.title = "Input required " & String( 100, "." )
objIE.ToolBar = False
objIE.Resizable = False
objIE.StatusBar = False
objIE.Width = 320
objIE.Height = 180
' Center the dialog window on the screenWith objIE.Document.parentWindow.screen
objIE.Left = (.availWidth - objIE.Width ) \ 2
objIE.Top = (.availheight - objIE.Height) \ 2
End With
' Wait till IE is readyDo While objIE.Busy
WScript.Sleep 200
Loop ' Insert the HTML code to prompt for user inputobjIE.Document.body.innerHTML = "<div align=""center""><p>" & myPrompt _
& "</p>" & vbCrLf _
& "<p><input type=""text"" size=""20"" " _
& "id=""UserInput""></p>" & vbCrLf _
& "<p><input type=""hidden"" id=""OK"" " _
& "name=""OK"" value=""0"">" _
& "<input type=""submit"" value="" OK "" " _
& "OnClick=""VBScript:OK.value=1""></p></div>"
' Hide the scrollbarsobjIE.Document.body.style.overflow = "auto"
' Make the window visibleobjIE.Visible = True
' Set focus on input fieldobjIE.Document.all.UserInput.focus
' Wait till the OK button has been clickedOn Error Resume Next
Do While objIE.Document.all.OK.value = 0
WScript.Sleep 200
' Error handling code by Denis St-PierreIf Err Then ' user clicked red X (or alt-F4) to close IE window
IELogin = Array( "", "" )
objIE.Quit
Set objIE = Nothing
Exit Function
End if
LoopOn Error Goto 0
' Read the user input from the dialog windowGetUserInput = objIE.Document.all.UserInput.value
' Close and release the objectobjIE.Quit
Set objIE = Nothing
End Function
page last modified: 2025-10-11; loaded in 0.0046 seconds