Jump to content

better GUI on progressbar


Recommended Posts

here is the code from the help file. The progres bar is good but how can i use a better GUI...have never worked with gui before and am kinda not sure how to go about it...thanks for your help..

ProgressOn("Progress Meter", "Increments every second", "0 percent")
For $i = 10 to 100 step 10
    sleep(1000)
    ProgressSet( $i, $i & " percent")
Next
ProgressSet(100 , "Done", "Complete")
sleep(500)
ProgressOff()
Link to comment
Share on other sites

here is the code from the help file. The progres bar is good but how can i use a better GUI...have never worked with gui before and am kinda not sure how to go about it...thanks for your help..

ProgressOn("Progress Meter", "Increments every second", "0 percent")
For $i = 10 to 100 step 10
    sleep(1000)
    ProgressSet( $i, $i & " percent")
Next
ProgressSet(100 , "Done", "Complete")
sleep(500)
ProgressOff()

Hmm... Today is progress day?

Sorry about that...

OK. If you want to create a GUI, what you want to do is the following:

#include <GUIConstantsEX.au3>
Opt("MustDeclareVars", 1)                                    ;This means you are required to declare ALL variables.

Local $winhandle, $progress, $percent = 0                    ;This is where the variables are declared
$winhandle = GUICreate("(Give it a title)", 300, 100)        ;This creates the actual GUI
GUICtrlCreateLabel("Example of a progress meter", 30, 30)    ;Displays text on the GUI
$progress = GUICtrlCreateProgress(30, 60, 250)               ;This creates the progress bar
GUISetState()                                                ;By default, the GUI is hidden, and you must bring it forward.

While 1                                                      ;Set a loop so the program wont close
    GUICtrlSetData($progress, $percent)                          ;This is the part that actually changes the progress bar.
                                                             ;What we are going to do is make a variable called $percent and
                                                             ;increment that so we are always adding data when we want.

    $percent += 1                                            ;This will go up by 1 percent every time it is run.

    If GUIGetMsg() = $GUI_EVENT_CLOSE Then                   ;This checks to see if the close button is pressed...
        GUIDelete($winhandle)                                ;This deletes the GUI created at the start
        ExitLoop                                             ;and breaks out of the while loop
    EndIf                                                    ;Ends the if statement
WEnd                                                         ;This ends the loop.

All this will do is make the progress bar keep loading up. NOTE: It will go past 100% :x

Anyway, I heavily commented it for your benefit so I hope this helps you understand a bit better, if you want to get into GUI programming, it is not that hard. You just need to give about a week. I was loosely programming GUI's in AutoIt (whilst referring to other GUI programs and the help file ALOT!!!) within my first day of knowing the language, and you can do the same.

If you really want to get into GUI programming, your best bet would be to make another thread asking for an outline.

Good Luck :P

shanet

Edited by shanet

[font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS:

%programfiles%/AutoIt3/autoit3.chm
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...