Sign in to follow this  
Followers 0
lafafmentvotre

Progressbar with pourcent

14 posts in this topic

#1 ·  Posted (edited)

Hi

I want to create a progressbar in my gui with pourcent who run during my script.

How can do it ?

Sorry for my bad english.

Thanks

Edited by lafafmentvotre

Share this post


Link to post
Share on other sites



Hi

I want to create a progressbar in my gui with pourcent who run during my script.

How can do it ?

Sorry for my bad english.

Thanks

You'll want to look at GUICtrlCreateProgress/GUICtrlSetData (or maybe ProgressOn/ProgressOff/ProgressSet) in the help file.

Share this post


Link to post
Share on other sites

Hi

I dont find my answers with autoit help. This my script :

CODE
Break(1)

#include <GuiConstants.au3>

$aboutitemtext1 = "Sauvegarde de Profil V1.1"

$aboutitemtext2 = @LF & @LF & "Créé par : " & @LF & "D'après une idée de : "

$aboutitemtext3 = @LF & @LF & "Cet utilitaire permet d'exporter/importer les informations utilisateurs suivantes sur le Private :" & @LF & @LF & "- Bureau" & @lf & "- Favoris IE" & @lf & "- Fonts Windows" & @lf & "- Imprimantes"& @lf & "- Connexions ISeries"& @lf & "- Sources ODBC User" & @lf & "- Sources ODBC System"

; GUI

$gui = GuiCreate("Sauvegarde de Profil", 400, 200, -1, -1)

GuiSetIcon(@SystemDir & "\sndvol32.exe", 0)

; MENU Fichier

$filemenu = GUICtrlCreateMenu ("&Fichier")

$exititem = GUICtrlCreateMenuitem ("Quitter",$filemenu)

; MENU Aide

$helpmenu = GUICtrlCreateMenu ("&?")

$aboutitem = GUICtrlCreateMenuitem ("A propos",$helpmenu)

$ctrlbutton1 = GuiCtrlCreateButton("Exporter les données", 60, 80, 115, 40,$BS_DEFPUSHBUTTON)

$ctrlbutton2 = GuiCtrlCreateButton("Importer les données", 220, 80, 115, 40,)

$bureau = GUICtrlCreateCheckbox("Bureau", 20, 8, 100, 20)

$favoris = GUICtrlCreateCheckbox("Favoris", 20, 28, 100, 20)

$fonts = GUICtrlCreateCheckbox("Fonts", 20, 48, 100, 20)

$imprimantes = GUICtrlCreateCheckbox("Imprimantes", 160, 8, 100, 20)

$iseries = GUICtrlCreateCheckbox("ISeries", 160, 28, 100, 20)

$odbcuser = GUICtrlCreateCheckbox("ODBC User", 160, 48, 100, 20)

$odbcsystem = GUICtrlCreateCheckbox("ODBC System", 280, 8, 100, 20)

GUICtrlCreateProgress(20, 135, 360, 20)

GUISetState()

While 1

$listener = GUIGetMsg()

If $listener = $GUI_EVENT_CLOSE Or $listener = $exititem Then ExitLoop

If $listener = $aboutitem Then

MsgBox(0, "A propos de...", $aboutitemtext1 & $aboutitemtext2 & $aboutitemtext3, 10)

EndIf

If $listener = $ctrlbutton1 Then

If GUICtrlRead($bureau) = 4 And GUICtrlRead($favoris) = 4 And GUICtrlRead($fonts) = 4 And GUICtrlRead($imprimantes) = 4 And GUICtrlRead($iseries) = 4 And GUICtrlRead($odbcuser) = 4 And GUICtrlRead($odbcsystem) = 4 Then

MsgBox(48, "Informations", "Vous n'avez coché aucune option !" & @LF & "Choisissez une ou plusieurs options à sauvegarder SVP.",)

EndIf

EndIf

If $listener = $ctrlbutton2 Then

If GUICtrlRead($bureau) = 4 And GUICtrlRead($favoris) = 4 And GUICtrlRead($fonts) = 4 And GUICtrlRead($imprimantes) = 4 And GUICtrlRead($iseries) = 4 And GUICtrlRead($odbcuser) = 4 And GUICtrlRead($odbcsystem) = 4 Then

MsgBox(48, "Informations", "Vous n'avez coché aucune option !" & @LF & "Choisissez une ou plusieurs options à restaurer SVP.",)

EndIf

EndIf

$Favorisuser = @UserProfileDir & "\Favoris"

$Desktopuser = @UserProfileDir & "\Bureau"

$Iseriesuser = @UserProfileDir & "\Iseries"

$FontsUser = @WindowsDir & "\Fonts"

$ExportPrintercmd = "regedit.exe /e p:\Restauration\Imprimantes\Imprimantes.reg HKEY_CURRENT_USER\Printers"

$ImportPrintercmd = "regedit.exe /s p:\Restauration\Imprimantes\Imprimantes.reg"

$ExportOdbcUsercmd = "regedit.exe /e p:\Restauration\ODBC-User\OdbcUser.reg HKEY_CURRENT_USER\Software\ODBC"

$ImportOdbcUsercmd = "regedit.exe /s p:\Restauration\ODBC-User\OdbcUser.reg"

$ExportOdbcComputercmd = "regedit.exe /e p:\Restauration\ODBC-Computer\OdbcComputer.reg HKEY_LOCAL_MACHINE\SOFTWARE\ODBC"

$ImportOdbcComputercmd = "regedit.exe /s p:\Restauration\ODBC-Computer\OdbcComputer.reg"

If $listener = $ctrlbutton1 Then

If GUICtrlRead($bureau) = 1 Then

DirCreate("p:\Restauration\Bureau")

DirCopy($Desktopuser, "p:\Restauration\Bureau", 9)

EndIf

If GUICtrlRead($favoris) = 1 Then

DirCreate("p:\Restauration\Favoris")

DirCopy($Favorisuser, "p:\Restauration\Favoris", 9)

EndIf

If GUICtrlRead($fonts) = 1 Then

DirCreate("p:\Restauration\Fonts")

DirCopy($Fontsuser, "p:\Restauration\Fonts", 9)

EndIf

If GUICtrlRead($imprimantes) = 1 Then

DirCreate("p:\Restauration\Imprimantes")

Run($ExportPrintercmd)

EndIf

If GUICtrlRead($iseries) = 1 Then

DirCreate("p:\Restauration\Iseries")

DirCopy($Iseriesuser, "p:\Restauration\Iseries", 9)

EndIf

If GUICtrlRead($odbcuser) = 1 Then

DirCreate("p:\Restauration\ODBC-User")

Run($ExportOdbcUsercmd)

EndIf

If GUICtrlRead($odbcsystem) = 1 Then

DirCreate("p:\Restauration\ODBC-Computer")

Run($ExportOdbcComputercmd)

EndIf

If GUICtrlRead($bureau) = 1 Or GUICtrlRead($favoris) = 1 Or GUICtrlRead($fonts) = 1 Or GUICtrlRead($imprimantes) = 1 Or GUICtrlRead($iseries) = 1 Or GUICtrlRead($odbcuser) = 1 Or GUICtrlRead($odbcsystem) = 1 Then

MsgBox(0, "Résultat", "Données exportées dans le Private")

EndIf

EndIf

If $listener = $ctrlbutton2 Then

If GUICtrlRead($bureau) = 1 Then

DirCopy("p:\Restauration\Bureau", $Desktopuser, 9)

DirRemove("p:\Restauration\Bureau", 1)

EndIf

If GUICtrlRead($favoris) = 1 Then

DirCopy("p:\Restauration\Favoris", $Favorisuser, 9)

DirRemove("p:\Restauration\Favoris", 9)

EndIf

If GUICtrlRead($fonts) = 1 Then

DirCopy("p:\Restauration\Fonts", $FontsUser, 9)

DirRemove("p:\Restauration\Fonts", 9)

EndIf

If GUICtrlRead($imprimantes) = 1 Then

Run($ImportPrintercmd)

DirRemove("p:\Restauration\Imprimantes")

EndIf

If GUICtrlRead($iseries) = 1 Then

DirCopy("p:\Restauration\Iseries", $Iseriesuser, 9)

DirRemove("p:\Restauration\Iseries", 9)

EndIf

If GUICtrlRead($odbcuser) = 1 Then

Run($ImportOdbcUsercmd)

DirRemove("p:\Restauration\ODBC-User")

EndIf

If GUICtrlRead($odbcsystem) = 1 Then

Run($ImportOdbcComputercmd)

DirRemove("p:\Restauration\ODBC-Computer")

EndIf

If GUICtrlRead($bureau) = 1 Or GUICtrlRead($favoris) = 1 Or GUICtrlRead($fonts) = 1 Or GUICtrlRead($imprimantes) = 1 Or GUICtrlRead($iseries) = 1 Or GUICtrlRead($odbcuser) = 1 Or GUICtrlRead($odbcsystem) = 1 Then

MsgBox(0, "Résultat", "Données exportées dans le Private")

EndIf

EndIf

WEnd

I want a bar progress who start when my job begin and stop when my job finish.

I'm sorry for my bad english.

Thanksd for help

Share this post


Link to post
Share on other sites

Nobody can help me please ?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Here is an example progress bar script I just made, simply put "GuiCtrlSetData($Variable you used for progress bar, amount to set progress bar out of 100)" throughout your script where you want to change the progress bar amount. Good Luck let me know if you need help.

CODE
#include<GuiConstants.au3>
GUICreate("Example", 600, 140)

$ProgressBar = GUICtrlCreateProgress( 50, 50, 500, 20)
$Label = GUICtrlCreateLabel("Click to Begin", 270, 5, 80, 20)
$Begin = GUICtrlCreateButton("Begin", 250, 80, 100, 30)
$ProgressBarLoaded = 0

GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $Begin
            If $ProgressBarLoaded = 0 Then
                GUICtrlSetData($Label, "Loading...")
                GUICtrlSetState($Begin, $GUI_DISABLE)
                GUICtrlSetData($Begin, "Loading...")
                GUICtrlSetData($ProgressBar, 10)
                Sleep(100)
                GUICtrlSetData($ProgressBar, 20)
                Sleep(100)
                GUICtrlSetData($ProgressBar, 30)
                Sleep(100)
                GUICtrlSetData($ProgressBar, 40)
                Sleep(100)
                GUICtrlSetData($ProgressBar, 50)
                Sleep(100)
                GUICtrlSetData($ProgressBar, 60)
                Sleep(100)
                GUICtrlSetData($ProgressBar, 70)
                Sleep(100)
                GUICtrlSetData($ProgressBar, 80)
                Sleep(100)
                GUICtrlSetData($ProgressBar, 90)
                Sleep(100)
                GUICtrlSetData($ProgressBar, 100)
                GUICtrlSetData($Label, "Finished!")
                GUICtrlSetData($Begin, "Exit")
                GUICtrlSetState($Begin, $GUI_ENABLE)
                $ProgressBarLoaded = 1
            Else
                Exit
            EndIf
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd
Edited by dandymcgee

- Dan [Website]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

#include <GUIConstants.au3>

GUICreate(StringTrimRight(@ScriptName,4),220,100, -1,-1, $WS_CAPTION, $WS_EX_TOPMOST)
;GUISetBkColor (0xE0FFFF)

$progressbar = GUICtrlCreateProgress (10,15,200,20,$PBS_SMOOTH)
$procent = GUICtrlCreateLabel ('0 %', 10,40,200,20,$SS_CENTER)
$stop = GUICtrlCreateButton ("Stop",75,68,70,22,$BS_DEFPUSHBUTTON)

GUISetState()

$i = 0
While 1
  $msg = GUIGetMsg()

  If $msg = $stop OR $msg = $GUI_EVENT_CLOSE Then ExitLoop

  $i = $i + 1
  If $i > 100 Then $i = 0

  GUICtrlSetData ($progressbar,$i)
  GUICtrlSetData ($procent,$i & ' %')

  Sleep(100)
Wend

Edited by Zedna

Share this post


Link to post
Share on other sites

Thanks for your help dandymcgee but i don't choose how to implement your script in my script to run my progressbar during the job.

:):D:D

heeelllllllllllppppppppppppppppppppppppppppppppppppppppp

thanks

Share this post


Link to post
Share on other sites

Have you looked at ProgressOn/Off in the help file??

Regards,

eltorro

Share this post


Link to post
Share on other sites

I have almoust same question

I need to make 2 progress bar.

One must show total process (for example copy 5 files from one directory to other)

Second - progress of coping file

They must work at same time.

Thanks for any help.

Share this post


Link to post
Share on other sites

As for total progress you could copy like 5 files at a time then set the progress bar up five, copy five more, set progress bar up 5 again...


- Dan [Website]

Share this post


Link to post
Share on other sites

Hi

I choose a response to my answer. Here it's my final script.

Thanks a lot for all members who help me for this script :):D

Bye

Lafafmentvotre

CODE
Break(1)

#include <GuiConstants.au3>

$aboutitemtext1 = "Sauvegarde de Profil V1.1"

$aboutitemtext2 = @LF & @LF & "Créé par : " & @LF & "D'après une idée de : "

$aboutitemtext3 = @LF & @LF & "Cet utilitaire permet d'exporter/importer les informations utilisateurs suivantes sur le Private :" & @LF & @LF & " - Bureau - Favoris IE - Sources ODBC System" & @lf & " - Imprimantes - Connexions ISeries - Sources ODBC User" & @lf & " - Fonts Windows"

; GUI

FileInstall("Z:\Délevoppement AutoIt\Sauvegarde Profil\UserLogon.ico", @WindowsDir & "\system32\UserLogon.ico")

$gui = GuiCreate("Sauvegarde de Profil", 400, 200, -1, -1)

$ico = @WindowsDir & "\system32\UserLogon.ico"

GuiSetIcon($ico, 0)

; MENU Fichier

$filemenu = GUICtrlCreateMenu ("&Fichier")

$exititem = GUICtrlCreateMenuitem ("Quitter",$filemenu)

; MENU Aide

$helpmenu = GUICtrlCreateMenu ("&?")

$aboutitem = GUICtrlCreateMenuitem ("A propos",$helpmenu)

$ctrlbutton1 = GuiCtrlCreateButton("Exporter les données", 60, 80, 115, 40,$BS_DEFPUSHBUTTON)

$ctrlbutton2 = GuiCtrlCreateButton("Importer les données", 220, 80, 115, 40,)

$bureau = GUICtrlCreateCheckbox("Bureau", 20, 8, 100, 20)

$favoris = GUICtrlCreateCheckbox("Favoris", 20, 28, 100, 20)

$fonts = GUICtrlCreateCheckbox("Fonts", 20, 48, 100, 20)

$imprimantes = GUICtrlCreateCheckbox("Imprimantes", 160, 8, 100, 20)

$iseries = GUICtrlCreateCheckbox("ISeries", 160, 28, 100, 20)

$odbcuser = GUICtrlCreateCheckbox("ODBC User", 160, 48, 100, 20)

$odbcsystem = GUICtrlCreateCheckbox("ODBC System", 280, 8, 100, 20)

$0 = 0

$1 = 14.28

$2 = 28.56

$3 = 42.84

$4 = 57.12

$5 = 74

$6 = 85.68

$7 = 100

$Progressbar = GUICtrlCreateProgress(20, 135, 360, 20)

$ProgressBarLoaded = 0

$pourcent = GUICtrlCreateLabel ('0 %', 20, 158,360, 20,$SS_CENTER)

$Favorisuser = @UserProfileDir & "\Favoris"

$Desktopuser = @UserProfileDir & "\Bureau"

$Iseriesuser = @UserProfileDir & "\Iseries"

$FontsUser = @WindowsDir & "\Fonts"

$ExportPrintercmd = "regedit.exe /e p:\Restauration\Imprimantes\Imprimantes.reg HKEY_CURRENT_USER\Printers"

$ImportPrintercmd = "regedit.exe /s p:\Restauration\Imprimantes\Imprimantes.reg"

$ExportOdbcUsercmd = "regedit.exe /e p:\Restauration\ODBC-User\OdbcUser.reg HKEY_CURRENT_USER\Software\ODBC"

$ImportOdbcUsercmd = "regedit.exe /s p:\Restauration\ODBC-User\OdbcUser.reg"

$ExportOdbcComputercmd = "regedit.exe /e p:\Restauration\ODBC-Computer\OdbcComputer.reg HKEY_LOCAL_MACHINE\SOFTWARE\ODBC"

$ImportOdbcComputercmd = "regedit.exe /s p:\Restauration\ODBC-Computer\OdbcComputer.reg"

GUISetState()

While 1

$listener = GUIGetMsg()

If $listener = $GUI_EVENT_CLOSE Or $listener = $exititem Then ExitLoop

If $listener = $aboutitem Then

MsgBox(0, "A propos de...", $aboutitemtext1 & $aboutitemtext2 & $aboutitemtext3, 10)

EndIf

If $listener = $ctrlbutton1 Then

If GUICtrlRead($bureau) = 4 And GUICtrlRead($favoris) = 4 And GUICtrlRead($fonts) = 4 And GUICtrlRead($imprimantes) = 4 And GUICtrlRead($iseries) = 4 And GUICtrlRead($odbcuser) = 4 And GUICtrlRead($odbcsystem) = 4 Then

MsgBox(48, "Informations", "Vous n'avez coché aucune option !" & @LF & "Choisissez une ou plusieurs options à sauvegarder SVP.",)

EndIf

EndIf

If $listener = $ctrlbutton2 Then

If GUICtrlRead($bureau) = 4 And GUICtrlRead($favoris) = 4 And GUICtrlRead($fonts) = 4 And GUICtrlRead($imprimantes) = 4 And GUICtrlRead($iseries) = 4 And GUICtrlRead($odbcuser) = 4 And GUICtrlRead($odbcsystem) = 4 Then

MsgBox(48, "Informations", "Vous n'avez coché aucune option !" & @LF & "Choisissez une ou plusieurs options à restaurer SVP.",)

EndIf

EndIf

If $listener = $ctrlbutton1 Then

GUICtrlSetData ($progressbar,$0)

If GUICtrlRead($bureau) = 1 Then

DirCreate("p:\Restauration\Bureau")

DirCopy($Desktopuser, "p:\Restauration\Bureau", 9)

EndIf

GUICtrlSetData ($progressbar,$1)

GUICtrlSetData ($pourcent,$1 & ' %')

If GUICtrlRead($favoris) = 1 Then

DirCreate("p:\Restauration\Favoris")

DirCopy($Favorisuser, "p:\Restauration\Favoris", 9)

EndIf

GUICtrlSetData ($progressbar,$2)

GUICtrlSetData ($pourcent,$2 & ' %')

If GUICtrlRead($fonts) = 1 Then

DirCreate("p:\Restauration\Fonts")

DirCopy($Fontsuser, "p:\Restauration\Fonts", 9)

EndIf

GUICtrlSetData ($progressbar,$3)

GUICtrlSetData ($pourcent,$3 & ' %')

If GUICtrlRead($imprimantes) = 1 Then

DirCreate("p:\Restauration\Imprimantes")

Run($ExportPrintercmd)

EndIf

GUICtrlSetData ($progressbar,$4)

GUICtrlSetData ($pourcent,$4 & ' %')

If GUICtrlRead($iseries) = 1 Then

DirCreate("p:\Restauration\Iseries")

DirCopy($Iseriesuser, "p:\Restauration\Iseries", 9)

EndIf

GUICtrlSetData ($progressbar,$5)

GUICtrlSetData ($pourcent,$5 & ' %')

If GUICtrlRead($odbcuser) = 1 Then

DirCreate("p:\Restauration\ODBC-User")

Run($ExportOdbcUsercmd)

EndIf

GUICtrlSetData ($progressbar,$6)

GUICtrlSetData ($pourcent,$6 & ' %')

If GUICtrlRead($odbcsystem) = 1 Then

DirCreate("p:\Restauration\ODBC-Computer")

Run($ExportOdbcComputercmd)

EndIf

GUICtrlSetData ($progressbar,$7)

GUICtrlSetData ($pourcent,$7 & ' %')

If GUICtrlRead($bureau) = 1 Or GUICtrlRead($favoris) = 1 Or GUICtrlRead($fonts) = 1 Or GUICtrlRead($imprimantes) = 1 Or GUICtrlRead($iseries) = 1 Or GUICtrlRead($odbcuser) = 1 Or GUICtrlRead($odbcsystem) = 1 Then

MsgBox(0, "Résultat", "Données exportées dans le Private")

EndIf

EndIf

If $listener = $ctrlbutton2 Then

If GUICtrlRead($bureau) = 1 Then

DirCopy("p:\Restauration\Bureau", $Desktopuser, 9)

DirRemove("p:\Restauration\Bureau", 1)

EndIf

GUICtrlSetData ($progressbar,$1)

GUICtrlSetData ($pourcent,$1 & ' %')

If GUICtrlRead($favoris) = 1 Then

DirCopy("p:\Restauration\Favoris", $Favorisuser, 9)

DirRemove("p:\Restauration\Favoris", 9)

EndIf

GUICtrlSetData ($progressbar,$2)

GUICtrlSetData ($pourcent,$2 & ' %')

If GUICtrlRead($fonts) = 1 Then

DirCopy("p:\Restauration\Fonts", $FontsUser, 9)

DirRemove("p:\Restauration\Fonts", 9)

EndIf

GUICtrlSetData ($progressbar,$3)

GUICtrlSetData ($pourcent,$3 & ' %')

If GUICtrlRead($imprimantes) = 1 Then

Run($ImportPrintercmd)

DirRemove("p:\Restauration\Imprimantes")

EndIf

GUICtrlSetData ($progressbar,$4)

GUICtrlSetData ($pourcent,$4 & ' %')

If GUICtrlRead($iseries) = 1 Then

DirCopy("p:\Restauration\Iseries", $Iseriesuser, 9)

DirRemove("p:\Restauration\Iseries", 9)

EndIf

GUICtrlSetData ($progressbar,$5)

GUICtrlSetData ($pourcent,$5 & ' %')

If GUICtrlRead($odbcuser) = 1 Then

Run($ImportOdbcUsercmd)

DirRemove("p:\Restauration\ODBC-User")

EndIf

GUICtrlSetData ($progressbar,$6)

GUICtrlSetData ($pourcent,$6 & ' %')

If GUICtrlRead($odbcsystem) = 1 Then

Run($ImportOdbcComputercmd)

DirRemove("p:\Restauration\ODBC-Computer")

EndIf

GUICtrlSetData ($progressbar,$7)

GUICtrlSetData ($pourcent,$7 & ' %')

If GUICtrlRead($bureau) = 1 Or GUICtrlRead($favoris) = 1 Or GUICtrlRead($fonts) = 1 Or GUICtrlRead($imprimantes) = 1 Or GUICtrlRead($iseries) = 1 Or GUICtrlRead($odbcuser) = 1 Or GUICtrlRead($odbcsystem) = 1 Then

MsgBox(0, "Résultat", "Données exportées dans le Private")

EndIf

EndIf

WEnd

Share this post


Link to post
Share on other sites

How do you make one that truly shows how much it has done so far, not just shows what you tell it to show?


[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Share this post


Link to post
Share on other sites

Well you hava to tell it how far you reached... It cant know itself :whistle:


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

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