4
4
4upik2019-06-12 16:02:00
VBScript
4upik, 2019-06-12 16:02:00

How to open URL and close browser after 1 minute in VBscript?

How to open a URL and close it after 1 minute in VBscript?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
Zar747, 2019-10-15
@Zar747

Function GetUserInput( myPrompt )
' This code uses Internet Explorer to
' create a dialog and prompt for user input cabinet number 
' for write to computer department discription
'

    Dim objIE

    ' Create an IE object
    Set objIE = CreateObject( "InternetExplorer.Application" )

    ' Specify some of the IE window's settings
    objIE.Navigate "about:blank"
    objIE.Document.title = "Input required " & String( 100, "." )
    objIE.ToolBar        = False
    objIE.Resizable      = False
    objIE.StatusBar      = False
    objIE.Width          = 400
    objIE.Height         = 330

    ' 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

    ' Wait till IE is ready
    Do While objIE.Busy
        WScript.Sleep 200
    Loop
    ' Insert the HTML code to prompt for user input
    objIE.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>" _ 
          & "<p> блабла</div>"
    ' Hide the scrollbars
    objIE.Document.body.style.overflow = "auto"
    ' Make the window visible
    objIE.Visible = True
    ' Set focus on input field
    objIE.Document.all.UserInput.focus

    ' Wait till the OK button has been clicked
    On Error Resume Next
    Do While objIE.Document.all.OK.value = 0
        WScript.Sleep 200
        ' Error handling code by Denis St-Pierre
        If Err Then ' user clicked red X (or alt-F4) to close IE window
            IELogin = Array( "", "" )
            objIE.Quit
            Set objIE = Nothing
            Exit Function
        End if
    Loop
    On Error Goto 0


    ' Read the user input from the dialog window
    GetUserInput = objIE.Document.all.UserInput.value

    ' Close and release the object
    objIE.Quit
    Set objIE = Nothing
End Function

take this function as a basis, everything seems to be clear here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question