Jump to content

100% progressbar


Recommended Posts

well... i have a function in a script of mine.. it calls it like this

#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
_PROGRESS_ (50) ;Can be ANYTHING that the user specifies 
Func _PROGRESS_($a)
    Local $Progress_GUI = GUICreate('CONNECTING...' & $a, 300, 100, -1, -1, -2138570616)
    GUISetBkColor(0x0, $Progress_GUI)
    Local $Progress = GUICtrlCreateProgress( 0, 0, 300, 50)
    Local $Connecting = GUICtrlCreateLabel('CONNECTING...', 0, 70, 300, 30, $SS_CENTER)
    GUICtrlSetFont(-1, 10, '', '', 'Fixedsys')
    GUICtrlSetColor(-1, 0xFFFFA2)
    WinSetOnTop($Progress_GUI, '', 1)
    GUISetState()
    For $i = 0 To $a
        GUICtrlSetData ($Progress , $i)
        Sleep (50)
        GUICtrlSetData ($Connecting, 'CONNECTING...' & $i & '/' & $a)
    Next
    GUIDelete($Progress_GUI)
EndFunc

well.. the "50" is just an example... and EVERYTHING else in this func works perfectly... but the Progress loading... if i have it to 50 and the For loop SHOULD make that 50 = %100 right? or am i wrong and the 50 is %50 WHICH the computer seems to think... any idea how i can make anything number that is called = %100 instead of #/100.... i rarely use Prgress bars and the helpfile doesn't seem to show what i need... but its possible that i missed something does anyone know of anything that could help?

Link to comment
Share on other sites

Here's a stab at it!!

#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
_PROGRESS_ (50) ;Can be ANYTHING that the user specifies

Func _PROGRESS_($a)
    Local $Progress_GUI = GUICreate('CONNECTING...' & $a, 300, 100, -1, -1, -2138570616)
    GUISetBkColor(0x0, $Progress_GUI)
    Local $Progress = GUICtrlCreateProgress( 0, 0, 300, 50)
    ; GUICtrlSetLimit( $Progress, $a) ; doesn't seem to work here
    Local $Connecting = GUICtrlCreateLabel('CONNECTING...', 0, 70, 300, 30, $SS_CENTER)
    GUICtrlSetFont(-1, 10, '', '', 'Fixedsys')
    GUICtrlSetColor(-1, 0xFFFFA2)
    WinSetOnTop($Progress_GUI, '', 1)
    GUISetState()
    Local $Step = $a/100, $data
    For $i = 0 To 100 Step $Step
        GUICtrlSetData ($Progress , $i)
        Sleep (50)
        $data = Int($i * $Step)
        GUICtrlSetData ($Connecting, 'CONNECTING...' & $data & '/' & $a)
    Next
    GUIDelete($Progress_GUI)
EndFunc

8)

NEWHeader1.png

Link to comment
Share on other sites

The value for a progress bar is stated in % so 50% is only half-way across the bar.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Thanks valuater!

lol that helps.. but now when its a small number its slow as hell.... but oh well it works :D

EDIT

Having the number set at 1..... 5 mins.. NOT LITERALY but its VERY SLOW... and having the number set at.. oh 100 takes a hundredth of the time to do it.... isn't there an easyer way that makes it the same speed of progress but but % is changed like the above example..?

EDIT #2 alright i worked at it and.. then... thought suddenly... why don't i just calculate the percent of competed out of total then divide by 100 like i usually do in school

STUPID why didn't i think of this before! and it works perfectly! lol

Func _PROGRESS_($a)
    Local $Progress_GUI = GUICreate('CONNECTING...' & $a, 300, 100, -1, -1, -2138570616)
    GUISetBkColor(0x0, $Progress_GUI)
    Local $Progress = GUICtrlCreateProgress( 0, 0, 300, 50)
    Local $Connecting = GUICtrlCreateLabel('CONNECTING...', 0, 70, 300, 30, $SS_CENTER)
    GUICtrlSetFont(-1, 10, '', '', 'Fixedsys')
    GUICtrlSetColor(-1, 0xFFFFA2)
    WinSetOnTop($Progress_GUI, '', 1)
    GUISetState()
    For $i = 0 To $a
        GUICtrlSetData ($Progress , $i / $a * 100)
        Sleep (50)
        GUICtrlSetData ($Connecting, 'CONNECTING...' & $i & '/' & $a)
    Next
    GUIDelete($Progress_GUI)
EndFunc   ;==>_PROGRESS_
Edited by CodyBarrett
Link to comment
Share on other sites

Here's how I would do it (so it's always /100)

Func _PROGRESS_($a)
    Local $Progress_GUI = GUICreate('CONNECTING...' & $a, 300, 100, -1, -1, -2138570616)
    GUISetBkColor(0x0, $Progress_GUI)
    Local $Progress = GUICtrlCreateProgress( 0, 0, 300, 50)
    ; GUICtrlSetLimit( $Progress, $a) ; doesn't seem to work here
    Local $Connecting = GUICtrlCreateLabel('CONNECTING...', 0, 70, 300, 30, $SS_CENTER)
    GUICtrlSetFont(-1, 10, '', '', 'Fixedsys')
    GUICtrlSetColor(-1, 0xFFFFA2)
    WinSetOnTop($Progress_GUI, '', 1)
    GUISetState()
    Local $Step = 100/$a, $data
    For $i = 0 To $a Step $Step
        GUICtrlSetData ($Progress , $i)
        Sleep (50)
        $data = Int($i * $Step)
        GUICtrlSetData ($Connecting, 'CONNECTING...' & $data & '/' & 100)
    Next
    GUIDelete($Progress_GUI)
EndFunc
Edited by Roman9
Link to comment
Share on other sites

... that wasn't my problem though... as i stated above.. having the STEP wasn't the problem.. that makes it slower.. or faster... i was having troubles with the setting of the progress... which i fixed up there... the step makes it slower but still keeps the max 100.. so if the inpupt variable is over 100 say... 200 then it would appear to be sitting at 100%.... my solution.. was to get the % of the completed/total amount and then set the progress bar to that

a simple gr4 equation fixed it :D

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...