Sign in to follow this  
Followers 0
maxrealqnx

Why this progress bar isn't working for to repeat

16 posts in this topic

#1 ·  Posted (edited)

CODE
#include <GUIConstantsEx.au3>

#include <ProgressConstants.au3>

#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Form1", 633, 454, 192, 114)

$Progress1 = GUICtrlCreateProgress(152, 192, 150, 16)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

If you can help me very happy about it :P

Edited by maxrealqnx

Share this post


Link to post
Share on other sites



You're not setting or changing any state or data related to the ProgressBar control.

Read the GUICtrlSetData function in the help file.

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
GUICreate("Test",220,100);, -1,-1, $WS_CAPTION, $WS_EX_TOPMOST)
$progressbar = GUICtrlCreateProgress (10,15,200,20,$PBS_SMOOTH)
$procent = GUICtrlCreateLabel ('0 %', 10,40,200,20,$SS_CENTER)
$start = GUICtrlCreateButton ("Start",35,68,70,22)
$stop = GUICtrlCreateButton ("Stop",115,68,70,22)
GUICtrlSetState($stop,$GUI_DISABLE)
GUISetState()

$run = 0
$i = 0

While 1
  $msg = GUIGetMsg()

  If $msg = $GUI_EVENT_CLOSE Then ExitLoop
  If $msg = $start Then 
    $run = 1 
    GUICtrlSetState($start,$GUI_DISABLE)
    GUICtrlSetState($stop,$GUI_ENABLE)
  EndIf
  If $msg = $stop Then 
    $run = 0
    GUICtrlSetState($start,$GUI_ENABLE)
    GUICtrlSetState($stop,$GUI_DISABLE)
  EndIf
    If $run Then
    $i = $i + 1
    If $i > 100 Then $i = 0

    GUICtrlSetData ($progressbar,$i)
    GUICtrlSetData ($procent,$i & ' %')
    Sleep(100)
  EndIf
Wend

Share this post


Link to post
Share on other sites

maxrealqnx,

What do you want the progress bar to measure? There is nothing in your script to tell the progress bar to do anything.

Look at this:

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

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 454, 192, 114)
$Progress1 = GUICtrlCreateProgress(152, 192, 150, 16)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$inc = 0

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    
    $inc += .1
    GUICtrlSetData($Progress1, $inc)
    
WEnd

You need to tell the progress bar what to display - it cannot read your mind!

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

You're not setting or changing any state or data related to the ProgressBar control.

Read the GUICtrlSetData function in the help file.

Okey, but I am very beginner :P

Please, you give me an example.

Regards.

Share this post


Link to post
Share on other sites

maxrealqnx,

What do you want the progress bar to measure? There is nothing in your script to tell the progress bar to do anything.

Look at this:

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

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 454, 192, 114)
$Progress1 = GUICtrlCreateProgress(152, 192, 150, 16)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$inc = 0

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    
    $inc += .1
    GUICtrlSetData($Progress1, $inc)
    
WEnd

You need to tell the progress bar what to display - it cannot read your mind!

M23

I'm thank you very much for nice codes.

how we can provide the progress bar to continuous repeat ?

Share this post


Link to post
Share on other sites

Like Vista's?

Anyway, use AVI control instead and play the control while there is a progress and stop it when processing is done.

Share this post


Link to post
Share on other sites

Like Vista's?

Anyway, use AVI control instead and play the control while there is a progress and stop it when processing is done.

I'd do it but I want to learn this method :P

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

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

$hGUI = GUICreate('', 180, 100, 300, 400, $WS_POPUP, $WS_EX_TOOLWINDOW)
$PrgBar = GUICtrlCreateProgress(0, 35, 180, 25, $PBS_MARQUEE)
GUISetState()

$Init = TimerInit()
Do
    GUICtrlSetData($PrgBar, 0)
    Sleep(50)
Until TimerDiff($Init) > 5000

GUIDelete($hGUI)
Exit

Well, my poor computer show it like a truncated blue snake, also because of the optimization for performance so visualization looks quite ugly to me but maybe it'll look green and shiny like Vista's on yours.

Edited by Authenticity

Share this post


Link to post
Share on other sites

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

$hGUI = GUICreate('', 180, 100, 300, 400, $WS_POPUP, $WS_EX_TOOLWINDOW)
$PrgBar = GUICtrlCreateProgress(0, 35, 180, 25, $PBS_MARQUEE)
GUISetState()

$Init = TimerInit()
Do
    GUICtrlSetData($PrgBar, 0)
    Sleep(50)
Until TimerDiff($Init) > 5000

GUIDelete($hGUI)
Exit

Well, my poor computer show it like a truncated blue snake, also because of the optimization for performance so visualization looks quite ugly to me but maybe it'll look green and shiny like Vista's on yours.

Hmmm

Like this

CODE
#include <GUIConstantsEx.au3>

#include <ProgressConstants.au3>

#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Form1", 633, 454, 192, 114)

$Progressbar = GUICtrlCreateProgress(152, 192, 150, 16)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

$run = 0

$i = 0

While 1

$nMsg = GUIGetMsg()

$run = 1

If $run Then

$i = $i + 1

If $i > 100 Then $i = 0

GUICtrlSetData ($progressbar,$i)

Sleep(100)

EndIf

Wend

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Why the progress bar isn't working at same time with the RunWait("mspaint.exe") command ?

CODE
#include <GUIConstantsEx.au3>

#include <ProgressConstants.au3>

#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Form1", 633, 454, 192, 114)

$Progressbar = GUICtrlCreateProgress(152, 192, 150, 16)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

$run = 0

$i = 0

While 1

$nMsg = GUIGetMsg()

If $nMsg = $GUI_EVENT_CLOSE Then ExitLoop

If $i = 0 Then

$run = 1

EndIf

If $run Then

$i = $i + 1

If $i > 100 Then $i = 0

EndIf

GUICtrlSetData ($progressbar,$i)

Sleep(100)

RunWait("mspaint.exe")

;Exit

Wend

Edited by maxrealqnx

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Why the progress bar isn't working at same time with the RunWait("mspaint.exe") command ?

No need to bold your text like this.

RunWait() is a blocking function. When you want to do other things during the execution of a program you need to use Run().

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

No need for that text... Try something like this where the run is:

$iPid = Run ("somefile.exe")
While ProcessExists ($iPid)
    $i = $i + 1
    If $i > 100 Then $i = 0
    GUICtrlSetData ($progressbar,$i)
WEnd

*Untested*

Cheers,

Brett

Share this post


Link to post
Share on other sites

because : RunWait("mspaint.exe")

Runs an external program and pauses script execution until the program finishes.

then a will repeat loop

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

because : RunWait("mspaint.exe")

Runs an external program and pauses script execution until the program finishes.

then a will repeat loop

Namely, do not run at the same time ? :P

CODE
#include <GUIConstantsEx.au3>

#include <ProgressConstants.au3>

#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Form1", 633, 454, 192, 114)

$Progressbar = GUICtrlCreateProgress(152, 192, 150, 16)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

$run = 0

$i = 0

RunWait("mspaint.exe")

While 1

$nMsg = GUIGetMsg()

If $nMsg = $GUI_EVENT_CLOSE Then ExitLoop

If $i = 0 Then

$run = 1

EndIf

If $run Then

$i = $i + 1

If $i > 100 Then $i = 0 RunWait("Notepad.exe")

EndIf

GUICtrlSetData ($progressbar,$i)

Sleep(100)

;Exit

WEnd

Edited by maxrealqnx

Share this post


Link to post
Share on other sites

Namely, do not run at the same time ? :P

I assume that English isn't your native language (like for me), but the 3 answers to your question all state that RunWait() stops the script.

Use Run() !


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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