Jump to content

AutoIt, "X" time progress bar on button?


Recommended Posts

  • Developers

So you feel it is reasonable to bump a post after 19 minutes?

Maybe you need to start reading our Forumrules and show a little effort first.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

you say you have a form and a script. please post it so we can help.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=form2.kxf
$form2 = GUICreate("form2", 621, 251, 204, 205)
$Pic1 = GUICtrlCreatePic("C:\Users\Jack\Desktop\PPD Files\Skin.jpg", 0, 0, 620, 124)
$Radio1 = GUICtrlCreateRadio("option 1", 20, 150, 113, 17)
$Radio2 = GUICtrlCreateRadio("option 2", 160, 150, 113, 17)
$Radio3 = GUICtrlCreateRadio("option 3", 20, 180, 113, 17)
$Radio4 = GUICtrlCreateRadio("option 4", 160, 180, 113, 17)
$Radio5 = GUICtrlCreateRadio("option 5", 20, 210, 113, 17)
$Radio6 = GUICtrlCreateRadio("option 6", 160, 210, 113, 17)
$Button1 = GUICtrlCreateButton("Generate", 360, 144, 187, 57)
$Progress1 = GUICtrlCreateProgress(360, 210, 187, 17, BitOR($PBS_SMOOTH,$WS_BORDER))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $form2
    EndSwitch
WEnd

ok that is my code, it has just basic radio buttons as options and a button, I wanted to know how to make it so when the button is pressed the progress bar I have will take an X amount of time to fill and then once done pop up with a message of my choice.

this is my first code and I made it using Koda so if you tell me the script I need to add into it please show me where :D

Link to comment
Share on other sites

  • Moderators

fisheronline,

I would do it like this: ;)

#include <GUIConstantsEx.au3>
#include <Constants.au3>
#include <WindowsConstants.au3>
#include <ProgressConstants.au3>

$form2 = GUICreate("form2", 621, 251, 204, 205)
$Radio1 = GUICtrlCreateRadio("option 1", 20, 150, 113, 17)
$Radio2 = GUICtrlCreateRadio("option 2", 160, 150, 113, 17)
$Radio3 = GUICtrlCreateRadio("option 3", 20, 180, 113, 17)
$Radio4 = GUICtrlCreateRadio("option 4", 160, 180, 113, 17)
$Radio5 = GUICtrlCreateRadio("option 5", 20, 210, 113, 17)
$Radio6 = GUICtrlCreateRadio("option 6", 160, 210, 113, 17)
$Button1 = GUICtrlCreateButton("Generate", 360, 144, 187, 57)
$Progress1 = GUICtrlCreateProgress(360, 210, 187, 17, BitOR($PBS_SMOOTH,$WS_BORDER))
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            ; Start a loop
            For $i = 1 To 100
                ; Increase the progress bar
                GUICtrlSetData($Progress1, $i + 1) ; I find this gives a better response
                GUICtrlSetData($Progress1, $i)
                ; Wait a bit
                Sleep(100)
            Next
            ; Show the MsgBox
            MsgBox($MB_SYSTEMMODAL, "Hi", "Generated whatever it is!")
            ; Reset the progress bar
            GUICtrlSetData($Progress1, 0)
    EndSwitch
WEnd

All clear? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

fisheronline,

I would suggest that you make sure you undrstand what is going on in the script I posted before just pasting it into your own version or you will be back here in no time saying it does not work. ;)

For example, you will need to add code to do whatever it is happens when the "Generate" button is pressed, determine how long you want the progress bar to take to fill, and to read the option radios (otherwise why are they there?). :)

If this is your first script, just take it slowly and make sure you know why you are using certain code elements rather then just pasting chunks of other people's code into yours and expecting it to integrate without problem. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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