Sign in to follow this  
Followers 0
ReaImDown

GuiCtrlCreateProgress

19 posts in this topic

I need help with making a progress bar, I want to install a couple different files using a GUI and would like the user to know which file is being installed, and how much progress has been made... EX.

the progress bar's info would be using (out of 100%)

$a = Filegetsize("a")

$b = Filegetsize("b")

$c = Filegetsize("c")

$d = Filegetsize("d")

$TotalSize = $a + $b + $c + $d


[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]

Share this post


Link to post
Share on other sites



sorry i cant help...i tried creating a progress bar before...didnt work out all i got was errors..or a blank one...i belive you have to

$prog = GUICreateProgress

then...

GuiSetData($1+$2+$3+$4, $prog)

im pretty sure that'll work...correct me if im wrong

Share this post


Link to post
Share on other sites

No, that is wrong.

Share this post


Link to post
Share on other sites

GuiSetData($1+$2+$3+$4, $prog)

GuiSetData isn't even a function. And if it was, the syntax is wrong in so many ways.

Share this post


Link to post
Share on other sites

GUICtrlSetData?

Share this post


Link to post
Share on other sites

That is a function.

Share this post


Link to post
Share on other sites

GuiCtrlSetData($Progress, 25)

GuiCtrlSetData($Progress, 50)

GuiCtrlSetData($Progress, 75)

GuiCtrlSetData($Progress, 100)

Share this post


Link to post
Share on other sites

GuiCtrlSetData($Progress, 25)

GuiCtrlSetData($Progress, 50)

GuiCtrlSetData($Progress, 75)

GuiCtrlSetData($Progress, 100)

hmmm, that means I would have to update it after every file is uploaded, and it wouldn't run smooth


[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]

Share this post


Link to post
Share on other sites

Its impossible for it to run smooth then.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Its impossible for it to run smooth then.

wrong type of progress, and I dont know where I got this link from...but... here :)

http://www.autoitscript.com/forum/index.ph...st&id=11570

that one updates okay :P

Edited by ReaImDown

[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Use AdlibEnable to run a function in the background which updates the progressbar

Look at my first post in http://www.autoitscript.com/forum/index.php?showtopic=60232 for an example ..

thank you, thank you :)

heres a useless program I just made :P

CODE
#include <GUIConstants.au3>

$begin = TimerInit()

$a = 0

$b = 0

$c = 0

$x = 0

Global $Form1 = GUICreate("Form1", 633, 447, 193, 125)

Global $test = GUICtrlCreateProgress(128, 360, 329, 25)

Global $time = GUICtrlCreateLabel("",128, 280, 329,25)

GUICtrlSetColor(-1, 0x00FF00)

GUICtrlSetBkColor(-1, 0x000000)

Global $Label1 = GUICtrlCreateLabel("0%", 128, 320, 34, 17)

GUISetState(@SW_SHOW)

do

$x = $x +(Random(-50,50))

Sleep(100)

AdlibEnable("Mine",10)

until $x >= 1000

MsgBox(0, "Total Time", "The program took " & $totaltime & " to get to " & $percent & "%")

Func Mine()

$dif = TimerDiff($begin)

$d = Int($dif / 1000)

if $d = 60 Then

$begin = TimerInit()

$c = $c + 1

EndIf

if $c = 60 Then

$c = 0

$b = $b +1

EndIf

if $b = 24 Then

$b = 0

$a = $a +1

EndIf

Global $totaltime = $a & " Days, " & $b & " Hours, " & $c & " Minutes, " & $d & " Seconds."

GUICtrlSetData($time,$totaltime)

global $percent = Int( ($x * 100) / 1000 )

GUICtrlSetData($Label1, $percent & "%")

GUICtrlSetData($test,$percent)

EndFunc

Edited by ReaImDown

[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

hmmm, I need help figuring out $x

$x would be the % already copied to @DesktopDir & "\New Folder")

CODE
GUICreate("Tester", 400,400)

$P = GUICtrlCreateProgress(1,100,300,15)

AdlibEnable(Tracker,100)

global $f = FileGetSize("New Text document.txt")

FileCopy("New Text document.txt", @DesktopDir & "\New Folder")

Func Tracker()

global $percent = Int( ($x * 100) / $f )

GUICtrlSetData($P, $percent)

EndFunc

Edited by ReaImDown

[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]

Share this post


Link to post
Share on other sites

Hi,

Here is an example on Progress Simulation (can be used as template for copying files) ...

#include <GuiConstants.au3>

$Gui = GuiCreate("Simulation Progress Demo", 350, 120)

$ProgressLabel = GUICtrlCreateLabel("Status: Press the button! ;)", 20, 30, 330)
$Progress = GUICtrlCreateProgress(20, 50, 300, 20)

$StartButton = GUICtrlCreateButton("Start Simulation Progress", (350/2)-(140/2), 80, 140)

GUISetState()

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case -3
            Exit
        Case $StartButton
            GUICtrlSetData($ProgressLabel, "Status: Please wait...")
            
            Dim $FilesArr[1000]
            For $i = 1 To UBound($FilesArr)-1
                $FilesArr[$i] = _GetRandomName(6) & ".test"
            Next
            
            Local $FilesCount = UBound($FilesArr)-1
            Local $CurrentFName, $ProgressSet = 0
            
            GUICtrlSetData($ProgressLabel, "Status: 0% Done...")
            GUICtrlSetData($StartButton, "Abort Simulation Progress")
            
            For $i = 1 To $FilesCount
                Sleep(40)
                $CurrentFName = $FilesArr[$i]
                $ProgressSet = Round(100 / ($FilesCount / $i))
                GUICtrlSetData($ProgressLabel, "Status: " & $ProgressSet & "% Done, [" & $CurrentFName & "]")
                GUICtrlSetData($Progress, $ProgressSet)
                If GUIGetMsg() = $StartButton Then ExitLoop
            Next
            
            GUICtrlSetData($Progress, 0)
            GUICtrlSetData($ProgressLabel, "Status: Finish!")
            GUICtrlSetData($StartButton, "Start Simulation Progress")
    EndSwitch
WEnd

Func _GetRandomName($Lenght=3)
    Local $RetName = ''
    For $i = 1 To $Lenght
        $RetName &= Chr(Random(97, 122, 1))
    Next
    Return $RetName
EndFunc

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

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