Waiting Bar in HTA and CSS

后端 未结 2 1101
遇见更好的自我
遇见更好的自我 2021-01-17 01:56

I got a little code to simulate a waiting bar that uses HTML and CSS, so I had the idea to add in a HTA to generate after dynamically with a vbscript. If any of you can give

2条回答
  •  感动是毒
    2021-01-17 02:41

    I use this progress bar, which has been edited from this link

    '*******************************************************
    '*** Progress bar class
    '*******************************************************
    'The attributes of the class to create the progress bar as an internet explorer window
    'edited from **http://www.northatlantawebdesign.com/index.php/2009/07/16/simple-vbscript-progress-bar/**
    
    Dim pb
    Dim percentComplete
    
    Class ProgressBar
        Private m_PercentComplete
        Private m_CurrentStep
        Private m_ProgressBar
        Private m_Title
        Private m_Text
        Private m_StatusBarText
        Public n
    
    'Initialize defaults
    Private Sub ProgessBar_Initialize
        m_PercentComplete = 0
        n = 0
        m_CurrentStep = 0
        m_Title = "Progress"
        m_Text = ""
    End Sub
    
    Public Function SetTitle(pTitle)
        m_Title = pTitle
    End Function
    
    Public Function SetText(pText)
        m_Text = pText
    End Function
    
    Public Function Update(percentComplete)
        m_PercentComplete = percentComplete
        UpdateProgressBar()
    End Function
    
    Public Function Show()
    Set m_ProgressBar = Wscript.CreateObject("InternetExplorer.Application", "IE_")
    'the colon acts as a line feed
        m_ProgressBar.navigate2 "about:blank" : m_ProgressBar.width = 315 : m_ProgressBar.height = 200:
        m_ProgressBar.toolbar = false : m_ProgressBar.menubar = false : m_ProgressBar.statusbar = false : m_ProgressBar.visible = true ': m_ProgressBar.Resizable = false 'Resizeable not used, but kept in case needed
        m_ProgressBar.document.write "
    0
    " m_ProgressBar.document.write "
    " m_ProgressBar.document.write "
    " End Function Public Function Close() m_ProgressBar.quit End Function Private Function UpdateProgressBar() If m_PercentComplete = 0 Then m_StatusBarText = "" End If For n = m_CurrentStep to m_PercentComplete - 1 m_StatusBarText = m_StatusBarText & "|" m_ProgressBar.Document.GetElementById("statusbar").InnerHtml = m_StatusBarText m_ProgressBar.Document.title = "Progress" m_ProgressBar.Document.GetElementById("pc").InnerHtml = n & "% Complete
    " & m_Title Wscript.sleep 10 Next m_ProgressBar.Document.GetElementById("statusbar").InnerHtml = m_StatusBarText m_ProgressBar.Document.GetElementById("pc").InnerHtml = m_PercentComplete & "% Complete
    " & m_Title m_ProgressBar.Document.GetElementById("text").InnerHtml = m_Text m_CurrentStep = m_PercentComplete Wscript.sleep 10 End Function End Class

    set it with these statements

    Set pb = New ProgressBar
        percentComplete = 0
        pb.SetTitle("Step 1 of 4 - Do Not Close Window!")
        pb.SetText("Starting Program")
        pb.Show()
        pb.Update(percentComplete)
    

    and then updated it as an when necessary

    pb.SetTitle("Step 3 of 4 - Do Not Close Window!")
    pb.SetText("Copying Files")
    percentComplete = 0
    pb.Update(percentComplete)
    

    if i am incrementing through a folder, i would first get the number of files in the folder and then use a counter to increment the percentComplete value and then dynamically update the progress bar using

    percentComplete = 0
    pb.Update(percentComplete)
    

提交回复
热议问题