Jump to content

A different kind of progress bar


Recommended Posts

Okay, where to start... I have a program runs and takes anywhere from 5-20 minutes... I want there to be a progress bar on the screen. look at this ... Think animations...

Frame 1: loading

Frame 2: loading.

Frame 3: loading..

Frame 4: loading...

Repeat

I don't know how many things my program must process, so I can't use the Progress bar functions. I also don't want to have more than one file... I could probably do this easily with an animated GIF, but there must be a way to have the loading text running while my program does its thing. Any insight, autoit gurus?

---Sparkes.

Link to comment
Share on other sites

ok i kinda dont get u but i think ur trying to put a "loading" animation in a GUI....wat u want to do is make an animation in GIF first....then u convert that into .avi format....then u read the help file on how to put .avi animations in a GUI....if u need help on ne of these steps, ask me....im just giving u the basic info on how to do wat u want, but im not giving step by step procedure....

[font="Fixedsys"][size="3"][u][font="Franklin Gothic Medium"] [/font][/u][/size][/font]

Link to comment
Share on other sites

lol u dont need 2 files dude....avi actually plants the file INSIDE the one file...its the way "#include" works....wen u compile the script, it will include the file in there....

[font="Fixedsys"][size="3"][u][font="Franklin Gothic Medium"] [/font][/u][/size][/font]

Link to comment
Share on other sites

like this

#include <GUIConstants.au3>
Dim $timer = 300; change to the "sleep" time you want

; GUI
GUICreate("Auto Loader", 200, 150)

; LABEL
$label_1 = GUICtrlCreateLabel("Ready...", 40, 20, 150, 20)

; BUTTON
$RUN_1 = GUICtrlCreateButton("Run", 50, 50, 100, 50)

; GUI MESSAGE LOOP
GUISetState()



While 1
    $MSG = GUIGetMsg()
    Select
        Case $MSG = $GUI_EVENT_CLOSE
            Exit
        Case $MSG = $RUN_1
           run_script()
    EndSelect

WEnd


; ---------------------------------- Functions -----------------------------

Func run_script()
GUICtrlSetData( $label_1, "Loading..")
Sleep ($Timer)
GUICtrlSetData( $label_1, "Loading...")
Sleep ($Timer)
GUICtrlSetData( $label_1, "Loading....")
Sleep ($Timer)
GUICtrlSetData( $label_1, "Loading.....")
Sleep ($Timer)
GUICtrlSetData( $label_1, "Loading......")
Sleep ($Timer)
GUICtrlSetData( $label_1, "Loading.......")
Sleep ($Timer)
GUICtrlSetData( $label_1, "Loading.........")
Sleep ($Timer)
GUICtrlSetData( $label_1, "Loading..........")
Sleep ($Timer)
GUICtrlSetData( $label_1, "Loading...........")
Sleep ($Timer)
GUICtrlSetData( $label_1, "Loading............")
Sleep ($Timer)
GUICtrlSetData( $label_1, "Loading............. Finished")
Sleep ($Timer * 5)
GUICtrlSetData( $label_1, "Ready...")
EndFunc;==>run_script.

8)

NEWHeader1.png

Link to comment
Share on other sites

hope you dont mind but i shortened it

#include <GUIConstants.au3>
Dim $timer = 100; change to the "sleep" time you want

; GUI
GUICreate("Auto Loader", 200, 150)

; LABEL
$label_1 = GUICtrlCreateLabel("Ready...", 40, 20, 150, 20)
$text_1 = "Loading"
$text_2 = "."

; BUTTON
$RUN_1 = GUICtrlCreateButton("Run", 50, 50, 100, 50)

; GUI MESSAGE LOOP
GUISetState()



While 1
    $MSG = GUIGetMsg()
    Select
        Case $MSG = $GUI_EVENT_CLOSE
            Exit
        Case $MSG = $RUN_1
           run_script()
    EndSelect

WEnd


Func run_script()
    
$output = $text_1 & $text_2
for $i = 1 to 10 
GUICtrlSetData( $label_1, $output )
Sleep ($Timer)
$output = $output & $text_2
Next


GUICtrlSetData( $label_1, "Loading............. Finished")
Sleep ($Timer * 5)
GUICtrlSetData( $label_1, "Ready...")
EndFunc

---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Link to comment
Share on other sites

I did not know that avis were embedded. Interesting. Can autoit multithread? like have two functions run at the same time? Like have that run as a progress indicator and have the actual function running in background? I guess I could compile the progress bar and use a run command to load it and a process kill function to kill it, but it would be much easier if I could just have one script doing two or more things at the same time.... I will do some tinkering with it today. I know that it can be doing one function and if a hotkey is pressed, the linked function will run, but are they both at the same time? or is one paused?

---Sparkes.

Link to comment
Share on other sites

  • Moderators

I did not know that avis were embedded. Interesting. Can autoit multithread?

No... but take a look at AdlibEnable() in the help file.

like have two functions run at the same time? Like have that run as a progress indicator and have the actual function running in background? I guess I could compile the progress bar and use a run command to load it and a process kill function to kill it, but it would be much easier if I could just have one script doing two or more things at the same time.... I will do some tinkering with it today. I know that it can be doing one function and if a hotkey is pressed, the linked function will run, but are they both at the same time? or is one paused?

With using splash as I think was suggested, and adlibenable(), you may be able to accomplish what your looking for.

Granted it does interfere with the time it would take to run the actual script in the background... The other option is as you said, is running 2 at the same time.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Hmm adlib never seen that, that could be handy.

Talk about ugly code, try using varibles and a for loop please.

That is much cleaner then this wysiwyg way of coding.

(wysiwyg = what you see is what you get))

Func run_script()
GUICtrlSetData( $label_1, "Loading..")
Sleep ($Timer)
GUICtrlSetData( $label_1, "Loading...")
Sleep ($Timer)
GUICtrlSetData( $label_1, "Loading....")
Sleep ($Timer)
GUICtrlSetData( $label_1, "Loading.....")
Sleep ($Timer)
GUICtrlSetData( $label_1, "Loading......")
Sleep ($Timer)
GUICtrlSetData( $label_1, "Loading.......")
Sleep ($Timer)
GUICtrlSetData( $label_1, "Loading.........")
Sleep ($Timer)
GUICtrlSetData( $label_1, "Loading..........")
Sleep ($Timer)
GUICtrlSetData( $label_1, "Loading...........")
Sleep ($Timer)
GUICtrlSetData( $label_1, "Loading............")
Sleep ($Timer)
GUICtrlSetData( $label_1, "Loading............. Finished")
Sleep ($Timer * 5)
GUICtrlSetData( $label_1, "Ready...")
Link to comment
Share on other sites

Hmm adlib never seen that, that could be handy.

Talk about ugly code, try using varibles and a for loop please.

That is much cleaner then this wysiwyg way of coding.

(wysiwyg = what you see is what you get))

your post does not add anything of value to the conversation. If you're going to troll someone's code by saying how ugly it is, you might have the common courtesy to offer a better alternative. Something that's so good that we wouldnt question your insulting attitude.

Thanks for participating, next time try being constructive.

Edited by blademonkey

---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Link to comment
Share on other sites

your post does not add anything of value to the conversation. If you're going to troll someone's code by saying how ugly it is, you might have the common courtesy to offer a better alternative. Something that's so good that we wouldnt question your insulting attitude.

Thanks for participating, next time try being constructive.

that totally represents my attitude also

8)

NEWHeader1.png

Link to comment
Share on other sites

#Include <GUIConstants.au3>

; Create a captionless, bordered, taskbarless, topmost splash window
Local $Splash = GUICreate('My Program', 120, 90, -1, -1, BitOR($WS_POPUP, $WS_DLGFRAME), BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
; The mouse cursor within it will be the hourglass
GUISetCursor(15, 1)
; Create an etched container
GUICtrlCreateLabel('', 12, 12, 96, 66, $SS_SUNKEN)
; Display the AVI file (set the path and subfile ID appropriately)
GUICtrlCreateAVI(@SystemDir & '\Shell32.dll', 150, 20, 20, '', '', $ACS_AUTOPLAY)
; Display this window
GUISetState()

; Simulate startup work
Sleep(Random(2500, 7500, 1))

; Remove the splash window
GUIDelete($Splash)

Link to comment
Share on other sites

#Include <GUIConstants.au3>

; Create a captionless, bordered, taskbarless, topmost splash window
Local $Splash = GUICreate('My Program', 120, 90, -1, -1, BitOR($WS_POPUP, $WS_DLGFRAME), BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
; The mouse cursor within it will be the hourglass
GUISetCursor(15, 1)
; Create an etched container
GUICtrlCreateLabel('', 12, 12, 96, 66, $SS_SUNKEN)
; Display the AVI file (set the path and subfile ID appropriately)
GUICtrlCreateAVI(@SystemDir & '\Shell32.dll', 150, 20, 20, '', '', $ACS_AUTOPLAY)
; Display this window
GUISetState()

; Simulate startup work
Sleep(Random(2500, 7500, 1))

; Remove the splash window
GUIDelete($Splash)
nice LxP

8)

NEWHeader1.png

Link to comment
Share on other sites

This adds nothing usefull

your post does not add anything of value to the conversation. If you're going to troll someone's code by saying how ugly it is, you might have the common courtesy to offer a better alternative. Something that's so good that we wouldnt question your insulting attitude.

Thanks for participating, next time try being constructive.

This adds nothing either

that totally represents my attitude also

8)

Thanks for flaming me, actually your post and valuators agree post are completely off-topic.

Next time donot post something wich doesn't add anything to the post because you are aggainst that. (hypocritical)

So donot post something wich doesn't add anything.

Like I said use a for loop wich does add something.

What I also add is saying what is wrong with the code wich means I am teaching.

I will not always give code because sometimes its better to make it yourself.

I am sorry If I offended you because I have criticised one one of the posts.

Its meant as something to learn about clean efficient coding is better for a clean nice world.

A world where people neve are hungry because not much lines are used in coding.

A world where is no war because there are lots of line left for coding everyone is happy.

Ps using big avi files my look nice but the guy only wants something like Loading... with the points counting up.

Little example showing much more efficient code small fast easy.

SplashTextOn("TitleFoo", "", 90, 25, -1, -1,5 )
while 1
    $message = "Loading"
    For $x = 1 to 5
            $message = $message & "."
            ControlSetText("Title", "", "Static1", $message)
            sleep(1000)
    Next
wend
Edited by MrSpacely
Link to comment
Share on other sites

bout that embedded function thing, u can use "AdlibEnable()" function....this is an embedded function...but while it runs, it PAUSES the script...u can change the time between each adlib call...i suggest u keep the adlib function short so that the rest of the script can run too...so calling it ever 1 second should be fine and with a short function, it wouldnt pause the script for long and i think it wouldnt take much cpu load either....also, u can exit the adlib by using "AdlibDisable()" function....

[font="Fixedsys"][size="3"][u][font="Franklin Gothic Medium"] [/font][/u][/size][/font]

Link to comment
Share on other sites

  • 2 weeks later...

How do you run 2 simultaneous processes in one script?

For example,

$log = _StringEncrypt(1, GUICtrlRead($encryptinputname) & @CRLF & @IPAddress1, $InputPass,$InputLevel)
                            GUICreate("My GUI Progressbar",220,100, 100,200)
                                $progressbar1 = GUICtrlCreateProgress (10,40,200,20)
                            GUICtrlSetColor(-1,32250); not working with Windows XP Style
                            $progressbar2 = GUICtrlCreateProgress (10,70,200,20,$PBS_SMOOTH)
                            
                            GUISetState ()
                            
                            $wait = 20; wait 20ms for next progressstep
                            $s = 0; progressbar-saveposition
                            
                            do
                                $msg = GUIGetMsg()
                                For $i = $s To 100 Step 1
                                    $i2 = $i/3
                                        
                                        GUICtrlSetData ($progressbar1,$i)
                                        GUICtrlSetData ($progressbar2,($i2))
                                        Sleep($wait)
                                Next
                                    Select
                                        Case $i >100
                                            $1 = 0
                                            For $i = $s To 100 Step 1
                                            GUICtrlSetData ($progressbar1,$i)
                                            Next
                                    Case $i2 = 100 
                                        ExitLoop
                                    EndSelect
                            until $msg = $GUI_EVENT_CLOSE

Like, in this code, ive set the script to encrypt some data, and to run a progress bar at the same time as the encryption. About how the progressbar is going to run, it will be based on a variable calculated by the amount of data to be encrypted etc. But to get it to run during the encryption...i cant do it...

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