Jump to content

Why this progress bar isn't working for to repeat


Recommended Posts

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
Link to comment
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

Link to comment
Share on other sites

  • Moderators

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

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

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 ?

Link to comment
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.

Edited by Authenticity
Link to comment
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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Developers

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

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

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

Link to comment
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

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
Link to comment
Share on other sites

  • Developers

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() !

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

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