Jump to content

Progress Bar


Recommended Posts

As per the example for the Progress bar, I am trying to keep it in between a function so that when the Run command starts the Progress bar would start and when the program ends so should the progress bar window too.

My code and progress window start together but the progress bar percentage only starts when the program gets completed. Both program and progress bar do not run together.

Can anyone help ?

 

Example()

Func Example()
    ; Display a progress bar window.
    ProgressOn("Progress Meter", "Increments every second", "0%")

; Run(Program /silent)

    ; Update the progress value of the progress bar window every second.
    For $i = 10 To 100 Step 10
        Sleep(1000)
        ProgressSet($i, $i & "%")
    Next

    ; Set the "subtext" and "maintext" of the progress bar window.
    ProgressSet(100, "Done", "Complete")
    Sleep(5000)

    ; Close the progress window.
    ProgressOff()
EndFunc   ;==>Example

 

Link to comment
Share on other sites

There is no issue with the example... But my installation doesn't shows the Progress bar moving at the correct time of installation of my programs.

Say as an example I am trying to get the VLC player installation with the progress bar.

As per the below code, The progress bar displays but never moves and installation starts later on.

I would need the progress bar to start when the func starts and progress bar % should show while all the operations happening at the correct time and end up when all the operations ended.

 
#RequireAdmin

#include <File.au3>
#include <IE.au3>
#include <ProgressConstants.au3>

Global $Path

Global $VLC_Site = "http://mirror.nexcess.net/videolan/vlc/2.2.1/win32/vlc-2.2.1-win32.exe"

VLC()

Func VLC()

        ; Display a progress bar window.
        ProgressOn("VLC", "VLC Player Installing", "0%", 30, 50, 16)

        $Path = @TempDir & "\VLC"
        DirCreate($Path)
        InetGet($VLC_Site, $Path & "\vlc-2.2.1-win32.exe", "", @SW_HIDE)

        RunWait($Path & "\vlc-2.2.1-win32.exe /L=1033 /S")

        ; Update the progress value of the progress bar window every second.
        For $i = 1 To 100 Step 1
            Sleep(100)
            ProgressSet($i, $i & "%")
        Next

        ; Set the "subtext" and "maintext" of the progress bar window.
        ProgressSet(100, "", "Complete")
        Sleep(1000)

        ; Close the progress window.
        ProgressOff()
EndFunc

 

Edited by sunshinesmile84
Link to comment
Share on other sites

Well....

RunWait($Path & "\vlc-2.2.1-win32.exe /L=1033 /S")

This line pauses your scripts until the program dies, Try: 

Run($Path & "\vlc-2.2.1-win32.exe /L=1033 /S")

TD :)

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

Your ProgressSet parameters are still the same as the Example

So it will in effect start and stop just exactly like the example does in the middle of your script regardless of what your program does.

You have to set the ProgressSet with something else, inetget might give you some info back to use but I have never tried it.

 

Her is a n example of what I mean:

Example()

Func Example()

    ; Display a progress bar window.
    ProgressOn("Progress Meter", "Begin setup process", "0%")

    ; Update the progress value of the progress bar window.
    Sleep(1000)
    ProgressSet(20 & "%", "VLC Downloaded Successfully")
    Sleep(1000)
    ProgressSet(40 & "%", "VLC Installed Succesfully")
    Sleep(1000)
    ProgressSet(60 & "%", "Clean up in Progress")
    Sleep(1000)
    ProgressSet(80 & "%")
    ; Set the "subtext" and "maintext" of the progress bar window.
    ProgressSet(100, "Done", "Complete")
    Sleep(5000)

    ; Close the progress window.
    ProgressOff()
EndFunc   ;==>Example

 

Link to comment
Share on other sites

@TheDcoder

Run command works here in place of Runwait... The problem is that VLC is not such a big file so using Run here seems all good.

 

The program I am using takes around 30 minutes to install. If I use Run over there then the progress bar shows as installed within few secs and gets completed but then the installation is still running at the background. Which is a problem...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...