Sign in to follow this  
Followers 0
lafafmentvotre

Action with progessbar

14 posts in this topic

Hi everybody and as usual : sorry by advance for my bad english >_<

I want to know if it's possible to do an installation_action in a while with a progressbar.

I don't want to use a splashtexton but a GuiCreate.

When the Gui appears, i would want that the installation begin (it's a silent install) with the progressbar until the installation is finished.

Here is my code :

$AppName="My Application"
;###################################################################
;Splash
$m1="Comments"
$m2="Comments"
$m3="Comments"
$m4="Comments "&$AppName&"."
$m5="Comments"
GUICreate($AppName, 350, 240, -1, -1, $WS_POPUPWINDOW)
GUICtrlCreatePic($Temp&"\my_logo.jpg", 155, 5, 40, 40)
$label1=GUICtrlCreateLabel($m1, 40, 60, 280, 20, $SS_CENTER)
GUICtrlSetFont(-1, 9, 800)
$label2=GUICtrlCreateLabel($m2, 10, 90, 330, 20, $SS_CENTER)
$label3=GUICtrlCreateLabel($m3, 10, 120, 330, 20, $SS_CENTER)
$label4=GUICtrlCreateLabel($m4, 10, 140, 330, 20, $SS_CENTER)
$label5=GUICtrlCreateLabel($m5, 10, 170, 330, 20, $SS_CENTER)
$Progressbar=GUICtrlCreateProgress(20, 200, 305, 20)
GUICtrlSetColor($Progressbar,0xF5B732)
GUISetState()

$i = 0
While 1
$msg=GUIGetMsg()
$wait=5; wait ms for next progressstep
    $i=$i + 1
    If $i > 100 Then $i = 0
    GUICtrlSetData ($progressbar,$i)
Sleep($wait)
WEnd
GUIDelete()

Is it possible ?

Where I have to insert my command ?

Thanks

Share this post


Link to post
Share on other sites



Here you can find the progressbar udf. This should get you started.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi everybody and as usual : sorry by advance for my bad english >_<

I want to know if it's possible to do an installation_action in a while with a progressbar.

I don't want to use a splashtexton but a GuiCreate.

When the Gui appears, i would want that the installation begin (it's a silent install) with the progressbar until the installation is finished.

Here is my code :

$AppName="My Application"
;###################################################################
;Splash
$m1="Comments"
$m2="Comments"
$m3="Comments"
$m4="Comments "&$AppName&"."
$m5="Comments"
GUICreate($AppName, 350, 240, -1, -1, $WS_POPUPWINDOW)
GUICtrlCreatePic($Temp&"\my_logo.jpg", 155, 5, 40, 40)
$label1=GUICtrlCreateLabel($m1, 40, 60, 280, 20, $SS_CENTER)
GUICtrlSetFont(-1, 9, 800)
$label2=GUICtrlCreateLabel($m2, 10, 90, 330, 20, $SS_CENTER)
$label3=GUICtrlCreateLabel($m3, 10, 120, 330, 20, $SS_CENTER)
$label4=GUICtrlCreateLabel($m4, 10, 140, 330, 20, $SS_CENTER)
$label5=GUICtrlCreateLabel($m5, 10, 170, 330, 20, $SS_CENTER)
$Progressbar=GUICtrlCreateProgress(20, 200, 305, 20)
GUICtrlSetColor($Progressbar,0xF5B732)
GUISetState()

$i = 0
While 1
$msg=GUIGetMsg()
$wait=5; wait ms for next progressstep
    $i=$i + 1
    If $i > 100 Then $i = 0
    GUICtrlSetData ($progressbar,$i)
Sleep($wait)
WEnd
GUIDelete()

Is it possible ?

Where I have to insert my command ?

Thanks

Hi,

it should be possible, but......

1) I would insert your run Command just before the While loop

2) Your while loop doesn't end. It's running 4 ever.

3) You may should work with While ProcessExist ( "MyInstallProgram.exe") <> ""

4) You need an indicator for installation progress. Maybe the size of the installdir. Like:

$instdirsize = 2568 ; MB
$instdir = @ProgramFilesDir & "\MyInst"
Run ("MyInstallProgram.exe") ; maybe RunAs
While ProcessExists ("MyInstallProgram.exe") <> ""
    GUICtrlSetData ($progressbar, Round (DirGetSize ($instdir) / 1024 / 1024 / $instdirsize * 100))
    Sleep (50)
WEnd
GUIDelete ()
Edited by 99ojo

Share this post


Link to post
Share on other sites

Hi,

it should be possible, but......

1) I would insert your run Command just before the While loop

2) Your while loop doesn't end. It's running 4 ever.

3) You may should work with While ProcessExist ( "MyInstallProgram.exe") <> ""

4) You need an indicator for installation progress. Maybe the size of the installdir. Like:

$instdirsize = 2568 ; MB
$instdir = @ProgramFilesDir & "\MyInst"
Run ("MyInstallProgram.exe") ; maybe RunAs
While ProcessExists ("MyInstallProgram.exe") <> ""
    GUICtrlSetData ($progressbar, Round (DirGetSize ($instdir) / 1024 / 1024 / $instdirsize * 100))
    Sleep (50)
WEnd
GUIDelete ()

Hi 99ojo

It doesn't work because it's an msi install with msiexec.exe.

After install, the gui with progress is always on top

Share this post


Link to post
Share on other sites

Hi 99ojo

It doesn't work because it's an msi install with msiexec.exe.

After install, the gui with progress is always on top

Hi,

so this doesn't work: While ProcessExists ("msiexec.exe") <> ""

so you could try:

While (Round (DirGetSize ($instdir) / 1024 / 1024 ) < Round ($instdirsize)

;-))

Stefan

Share this post


Link to post
Share on other sites

Hello

Thanks for response but i need 2 install (i just test 1 install) and the $instdirsize change because users have different data size(lotus notes)

i test this script but he doesn't work :

;###################################################################
;AutoIT Variables
AutoItSetOption("TrayIconHide", 0); 0 = do not hide, 1 = hide tray icon
#include <GUIConstants.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
;###################################################################
;Script Variables
$AppName="Lotus Notes"
$Temp=@TempDir & "\Lotus_Upgrade"
;###################################################################
;Installation fichiers locaux
DirCreate($Temp)
FileInstall("Lotus_Upgrade.jpg", $Temp&"\Lotus_Upgrade.jpg",1)
;###################################################################
;Run with Splash
Runwait('msiexec.exe /I Lotus_Notes_7.0.4_MUI.msi TRANSFORMS="Lotus_Notes_7.0.4_MUI.mst" /quiet /norestart')
While 1
Select
Case ProcessExists("setup.exe")<>""
$m1 = "------ INFORMATIQUE ------"
$m2 = "Une mise à jour de "&$AppName&" est en cours sur votre ordinateur."
$m3 = "Merci de patienter pendant le déroulement de l'installation"
$m4="et de ne pas utiliser "&$AppName&"."
$m5 = "Le service informatique"
GUICreate($AppName, 350, 240, -1, -1, $WS_POPUPWINDOW)
GUICtrlCreatePic($Temp&"\Lotus_Upgrade.jpg", 155, 5, 40, 40)
$label1 = GUICtrlCreateLabel($m1, 40, 60, 280, 20, $SS_CENTER)
GUICtrlSetFont(-1, 9, 800)
$label2 = GUICtrlCreateLabel($m2, 10, 90, 330, 20, $SS_CENTER)
$label3 = GUICtrlCreateLabel($m3, 10, 120, 330, 20, $SS_CENTER)
$label4 = GUICtrlCreateLabel($m4, 10, 140, 330, 20, $SS_CENTER)
$label5 = GUICtrlCreateLabel($m5, 10, 170, 330, 20, $SS_CENTER)
GUISetState()
$wait = 5
$i=0
$Progressbar = GUICtrlCreateProgress(20, 200, 305, 20)
GUICtrlSetColor($Progressbar,0xF5B732)
    $i=$i + 1
    If $i > 100 Then $i = 0
    GUICtrlSetData ($progressbar,$i)
Sleep($wait)
Case ProcessExists("setup.exe")=0
GUIDelete()
EndSelect
WEnd

Help please >_<

Share this post


Link to post
Share on other sites

Hi,

this should hopefully work:

;###################################################################
;AutoIT Variables
AutoItSetOption("TrayIconHide", 0); 0 = do not hide, 1 = hide tray icon
#include <GUIConstants.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
;###################################################################
;Script Variables
$AppName="Lotus Notes"
$Temp=@TempDir & "\Lotus_Upgrade"
;###################################################################
;Installation fichiers locaux
DirCreate($Temp)
FileInstall("Lotus_Upgrade.jpg", $Temp&"\Lotus_Upgrade.jpg",1)
;###################################################################
;Run with Splash
Run('msiexec.exe /I Lotus_Notes_7.0.4_MUI.msi TRANSFORMS="Lotus_Notes_7.0.4_MUI.mst" /quiet /norestart')
While 1
    ;There are several msiexec processes started
    $aProcessCount = ProcessList ("msiexec.exe")
    If $aProcessCount [0][0] > 1 Then   
        $m1 = "------ INFORMATIQUE ------"
        $m2 = "Une mise à jour de "&$AppName&" est en cours sur votre ordinateur."
        $m3 = "Merci de patienter pendant le déroulement de l'installation"
        $m4="et de ne pas utiliser "&$AppName&"."
        $m5 = "Le service informatique"
        GUICreate($AppName, 350, 240, -1, -1, $WS_POPUPWINDOW)
        GUICtrlCreatePic($Temp&"\Lotus_Upgrade.jpg", 155, 5, 40, 40)
        $label1 = GUICtrlCreateLabel($m1, 40, 60, 280, 20, $SS_CENTER)
        GUICtrlSetFont(-1, 9, 800)
        $label2 = GUICtrlCreateLabel($m2, 10, 90, 330, 20, $SS_CENTER)
        $label3 = GUICtrlCreateLabel($m3, 10, 120, 330, 20, $SS_CENTER)
        $label4 = GUICtrlCreateLabel($m4, 10, 140, 330, 20, $SS_CENTER)
        $label5 = GUICtrlCreateLabel($m5, 10, 170, 330, 20, $SS_CENTER)
        GUISetState()
        $i=0
        $Progressbar = GUICtrlCreateProgress(20, 200, 305, 20)
        GUICtrlSetColor($Progressbar,0xF5B732)
        $i += 1
        If $i > 100 Then $i = 0 ; this is not very sensefull.........
        GUICtrlSetData ($progressbar,$i)
        Sleep(20)
    Else
        GUIDelete()
        ExitLoop
    EndIf
WEnd

;-))

Stefan

Share this post


Link to post
Share on other sites

Hello and thanks again

It doesn't work. The Gui/Progressabar wait with one indicator and it flashes :

Posted Image

when the installation is finished, the Gui/Progressabar disappear.

Any idea

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Hello and thanks again

It doesn't work. The Gui/Progressabar wait with one indicator and it flashes :

Posted Image

when the installation is finished, the Gui/Progressabar disappear.

Any idea

Hi,

yes. As you can see, i added a comment at part

$i=0

$Progressbar = GUICtrlCreateProgress(20, 200, 305, 20)

GUICtrlSetColor($Progressbar,0xF5B732)

$i += 1

If $i > 100 Then $i = 0 ; this is not very sensefull.........

GUICtrlSetData ($progressbar,$i)

1) Put the $i = 0 before the while loop

2) The problem is, that you don't know exactly the point, when the process is finished. You have to try something like this:

The Installation Time is about 5 minutes. See code $time. I also change the while loop:

;###################################################################
;AutoIT Variables
AutoItSetOption("TrayIconHide", 0); 0 = do not hide, 1 = hide tray icon
#include <GUIConstants.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
;###################################################################
;Script Variables
$AppName="Lotus Notes"
$Temp=@TempDir & "\Lotus_Upgrade"
$time = 300 ; approx. Installation time in seconds
;###################################################################
;Installation fichiers locaux
DirCreate($Temp)
FileInstall("Lotus_Upgrade.jpg", $Temp&"\Lotus_Upgrade.jpg",1)
;###################################################################
;Run with Splash
Run('msiexec.exe /I Lotus_Notes_7.0.4_MUI.msi TRANSFORMS="Lotus_Notes_7.0.4_MUI.mst" /quiet /norestart')
$m1 = "------ INFORMATIQUE ------"
$m2 = "Une mise à jour de "&$AppName&" est en cours sur votre ordinateur."
$m3 = "Merci de patienter pendant le déroulement de l'installation"
$m4="et de ne pas utiliser "&$AppName&"."
$m5 = "Le service informatique"
GUICreate($AppName, 350, 240, -1, -1, $WS_POPUPWINDOW)
GUICtrlCreatePic($Temp&"\Lotus_Upgrade.jpg", 155, 5, 40, 40)
$label1 = GUICtrlCreateLabel($m1, 40, 60, 280, 20, $SS_CENTER)
GUICtrlSetFont(-1, 9, 800)
$label2 = GUICtrlCreateLabel($m2, 10, 90, 330, 20, $SS_CENTER)
$label3 = GUICtrlCreateLabel($m3, 10, 120, 330, 20, $SS_CENTER)
$label4 = GUICtrlCreateLabel($m4, 10, 140, 330, 20, $SS_CENTER)
$label5 = GUICtrlCreateLabel($m5, 10, 170, 330, 20, $SS_CENTER)
GUISetState()
$i=0
$Progressbar = GUICtrlCreateProgress(20, 200, 305, 20)
GUICtrlSetColor($Progressbar,0xF5B732)
While 1
    ;There are several msiexec processes started
    $aProcessCount = ProcessList ("msiexec.exe")
    If $aProcessCount [0][0] > 1 Then   
        $i += 1
        GUICtrlSetData ($progressbar,Round ($i/$time))
        Sleep(1000)
    Else
        GUIDelete()
        ExitLoop
    EndIf
WEnd
Edited by 99ojo

Share this post


Link to post
Share on other sites

Re

No, doesn't work.

Now the Gui/Progressabar wait with no indicator but not flashes :

Posted Image

I modify $time by 120 but no changes.

Share this post


Link to post
Share on other sites

Re

No, doesn't work.

Now the Gui/Progressabar wait with no indicator but not flashes :

Posted Image

I modify $time by 120 but no changes.

Sry,

my mistake:

Just change the line with GUICtrlSetData to

GUICtrlSetData ($Progressbar,$i/$time*100) ; math was a long time ago. Calculation of percentage (shame on me....)

;-))

Stefan

Share this post


Link to post
Share on other sites

Sry,

my mistake:

Just change the line with GUICtrlSetData to

GUICtrlSetData ($Progressbar,$i/$time*100) ; math was a long time ago. Calculation of percentage (shame on me....)

;-))

Stefan

Hi Stefan

It's ok now. I just change the $time=300 and the sleep(1000) by $time=120 and Sleep(50).

Thank you for you help

Have a nice day

Share this post


Link to post
Share on other sites

Hi Stefan

It's ok now. I just change the $time=300 and the sleep(1000) by $time=120 and Sleep(50).

Thank you for you help

Have a nice day

Fine,

but just keep in mind, that the progressbar doesn't show the real situation. On a slower CPU you may have the 100 % reached on progressbar, but the msiexec process will have 50 % of installing duty done.

You may get a timer which depends on CPU Clock. E.g. you have a 3 Ghz CPU and the msiexec will take 120 seconds to finish. On a 2 Ghz CPU this will take longer. Just test your exe in your environment and you will see.

I just put a function for reading CPU Clock. You may put in your code for adjusting the installtime:

MsgBox (0,"", _getMaxClockSpeed ())

Func _getMaxClockSpeed ()
    $wbemFlagReturnImmediately = 0x10
    $wbemFlagForwardOnly = 0x20
    $colItems = ""
    $strComputer = "localhost"
    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", _
    $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    For $objItem In $colItems
        $clckspeed = $objItem.MaxClockSpeed
    Next
    Return $clckspeed
EndFunc

Share this post


Link to post
Share on other sites

Fine,

but just keep in mind, that the progressbar doesn't show the real situation. On a slower CPU you may have the 100 % reached on progressbar, but the msiexec process will have 50 % of installing duty done.

You may get a timer which depends on CPU Clock. E.g. you have a 3 Ghz CPU and the msiexec will take 120 seconds to finish. On a 2 Ghz CPU this will take longer. Just test your exe in your environment and you will see.

I just put a function for reading CPU Clock. You may put in your code for adjusting the installtime:

MsgBox (0,"", _getMaxClockSpeed ())

Func _getMaxClockSpeed ()
    $wbemFlagReturnImmediately = 0x10
    $wbemFlagForwardOnly = 0x20
    $colItems = ""
    $strComputer = "localhost"
    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", _
    $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    For $objItem In $colItems
        $clckspeed = $objItem.MaxClockSpeed
    Next
    Return $clckspeed
EndFunc

Nice idea, thank you

I save this script without msgbox in my include (#include <CPU_Clock.au3>) :

Global $clckspeed
Func _getMaxClockSpeed ()
    $wbemFlagReturnImmediately = 0x10
    $wbemFlagForwardOnly = 0x20
    $colItems = ""
    $strComputer = "localhost"
    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", _
    $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    For $objItem In $colItems
        $clckspeed = $objItem.MaxClockSpeed
    Next
    Return $clckspeed
EndFunc

and i add these lines in my script

_getMaxClockSpeed()
Select
    Case $clckspeed< "1300"
    $time = 300
    Case Else
    $time = 120 ; approx. Installation time in seconds
EndSelect

Thanks Stefan

Share this post


Link to post
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
Sign in to follow this  
Followers 0