Progress in Statusleiste aktualisieren

  • Hallo Leute,
    ich bin's mal wieder! In meinem Script soll eine Progress Bar in der Statusleiste aktualisiert werden, leider fuktioniert das nicht ?( ! Das Programm soll einen Countdown fürs Herunterfahren in Form einer Progress Bar in der Statusleiste anzeigen. Leider geht die Progress Bar nur auf ca. 20 Prozent oder auf zeigt keine Reaktion und führt dann den Code aus, der eigentlich erst nach 100 Prozent kommen sollte! Vielleicht könnt ihr euch mal den Code ansehen.

    Hier ist mein Code (Unwichtiges hab' ich weggelassen).

    Spoiler anzeigen
    [autoit]


    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiStatusBar.au3>
    #include <ProgressConstants.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <Process.au3>

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Herunterfahren", 362, 155, 236, 123, "", $WS_EX_TOOLWINDOW)
    $Radio5 = GUICtrlCreateRadio("&Countdown", 32, 74, 87, 17)
    $Button1 = GUICtrlCreateButton("&Initialisieren", 130, 10, 100, 30)
    $Button2 = GUICtrlCreateButton("&Schließen", 230, 10, 100, 30)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    $counter = 0
    $StatusBar1 = _GUICtrlStatusBar_Create($Form1)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $Button2
    Exit
    Case $msg = $Button1
    If GUICtrlRead($Radio5) = $GUI_CHECKED Then
    ;Für den Countdown zuständig
    $progress = GUICtrlCreateProgress(0, 0, -1, -1)
    $hProgress = GUICtrlGetHandle($progress)
    _GUICtrlStatusBar_EmbedControl($StatusBar1, "", $hProgress)
    GUICtrlSetData($progress, 0)
    $r = GUICtrlRead($input)
    $y = $r / 100
    For $i = 0 To 100
    $x = $y * $i
    GUICtrlSetData($progress, $x)
    Sleep($y)
    Next
    MsgBox(0, "Fertig!", "Hat geklappt!")
    Exit
    ;Ende des Countdown-Bereichs
    EndIf
    ;Buttons auf Klick abfragen start
    Case $msg = $Radio5
    $counter = $counter + 1
    $input = GUICtrlCreateInput("", 140, 74, 50, 20)
    $Updown = GUICtrlCreateUpdown($input)
    EndSelect
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit]

    Einmal editiert, zuletzt von xp_fan (23. November 2009 um 07:12)

  • schau mal in deine Zeile 35.....welchen Wert schreibst du da in die Progressbar?

    Spoiler anzeigen

    GUICtrlSetData($progress, $i) ;so gehts von 1 bis 100

  • Also der Progressbar geht nur zu der Prozentzahl die man beim Input eingibt.

    [autoit]

    $r = GUICtrlRead($input)
    $y = $r / 100
    For $i = 0 To 100
    $x = $y * $i
    GUICtrlSetData($progress, $x)
    Sleep($y)
    Next

    [/autoit]


    $r = bsp 50
    $y = 50/100 (0.5)
    $x = 0.5 * 1-100
    Also maximal 0.5*100 = 50
    Du musst für jede zahle ne eigene rechnung machen. Ich glaub da gibts ne bestimme Formel, weiß aber grad nit genau welche

  • So vllt:

    Spoiler anzeigen
    [autoit]


    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiStatusBar.au3>
    #include <ProgressConstants.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <Process.au3>

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Herunterfahren", 362, 155, 236, 123, "", $WS_EX_TOOLWINDOW)
    $Radio5 = GUICtrlCreateRadio("&Countdown", 32, 74, 87, 17)
    $Button1 = GUICtrlCreateButton("&Initialisieren", 130, 10, 100, 30)
    $Button2 = GUICtrlCreateButton("&Schließen", 230, 10, 100, 30)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    $counter = 0
    $StatusBar1 = _GUICtrlStatusBar_Create($Form1)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $Button2
    Exit
    Case $msg = $Button1
    If GUICtrlRead($Radio5) = $GUI_CHECKED Then
    ;Für den Countdown zuständig
    $progress = GUICtrlCreateProgress(0, 0, -1, -1)
    $hProgress = GUICtrlGetHandle($progress)
    _GUICtrlStatusBar_EmbedControl($StatusBar1, "", $hProgress)
    GUICtrlSetData($progress, 0)
    $r = GUICtrlRead($input)
    For $i = 1 To $r*10
    Sleep(95)
    $y = 100/$r/10*$i
    GUICtrlSetData($progress, $y)
    Next
    MsgBox(0, "Fertig!", "Hat geklappt!")
    Exit
    ;Ende des Countdown-Bereichs
    EndIf
    ;Buttons auf Klick abfragen start
    Case $msg = $Radio5
    $counter = $counter + 1
    $input = GUICtrlCreateInput("", 140, 74, 50, 20)
    $Updown = GUICtrlCreateUpdown($input)
    EndSelect
    WEnd

    [/autoit]
  • oder so:

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiStatusBar.au3>
    #include <ProgressConstants.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <Process.au3>

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Herunterfahren", 362, 155, 236, 123, "", $WS_EX_TOOLWINDOW)
    $Radio5 = GUICtrlCreateRadio("&Countdown", 32, 74, 87, 17)
    $Button1 = GUICtrlCreateButton("&Initialisieren", 130, 10, 100, 30)
    $Button2 = GUICtrlCreateButton("&Schließen", 230, 10, 100, 30)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    $counter = 0
    $input = 0
    $StatusBar1 = _GUICtrlStatusBar_Create($Form1)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $Button2
    Exit
    Case $msg = $Button1
    If GUICtrlRead($Radio5) = $GUI_CHECKED Then
    ;Für den Countdown zuständig
    $progress = GUICtrlCreateProgress(0, 0, -1, -1)
    $hProgress = GUICtrlGetHandle($progress)
    _GUICtrlStatusBar_EmbedControl($StatusBar1, "", $hProgress)
    GUICtrlSetData($progress, 0)
    $r = GUICtrlRead($input)
    For $i = 1 To 100
    GUICtrlSetData($progress, $i)
    Sleep($r*10)
    Next
    MsgBox(0, "Fertig!", "Hat geklappt!" &@CRLF& "Zeitdauer: "&$r & " Sek.")
    Exit
    ;Ende des Countdown-Bereichs
    EndIf
    ;Buttons auf Klick abfragen start
    Case $msg = $Radio5
    $counter = $counter + 1
    $input = GUICtrlCreateInput("", 140, 74, 50, 20)
    $Updown = GUICtrlCreateUpdown($input)
    EndSelect
    WEnd

    [/autoit]

    MfG Schnuffel

    "Sarkasmus ist die niedrigste Form des Witzes, aber die höchste Form der Intelligenz."
    Val McDermid

    ein paar Infos ...

    Wer mehr als "nur" Hilfe benötigt, kann sich gern im Forum "Programmieranfragen" an uns wenden. Wir helfen in allen Fällen, die die Forenregeln zulassen.

    Für schnelle Hilfe benötigen wir ein ! lauffähiges ! Script, dass wir als Demonstration des Problems testen können. Wer von uns erwartet ein Teilscript erstmal lauffähig zu bekommen, der hat
    1. keine wirkliche Not
    2. keinen Respekt vor Menschen die ihm in ihrer Freizeit Ihre Hilfe anbieten
    3. oder ist einfach nur faul und meint wir coden das für ihn

    In solchen Fällen erlaube ich mir, die Anfrage einfach zu ignorieren. ;)

    • Offizieller Beitrag

    Wenn der Countdown in Sekunden sein soll dann so:

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiStatusBar.au3>
    #include <ProgressConstants.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <Process.au3>

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Herunterfahren", 362, 155, 236, 123, "", $WS_EX_TOOLWINDOW)
    $Radio5 = GUICtrlCreateRadio("&Countdown", 32, 74, 87, 17)
    $Button1 = GUICtrlCreateButton("&Initialisieren", 130, 10, 100, 30)
    $Button2 = GUICtrlCreateButton("&Schließen", 230, 10, 100, 30)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    $counter = 0
    $StatusBar1 = _GUICtrlStatusBar_Create($Form1)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $Button2
    Exit
    Case $msg = $Button1
    If GUICtrlRead($Radio5) = $GUI_CHECKED Then
    ;Für den Countdown zuständig
    $progress = GUICtrlCreateProgress(0, 0, -1, -1)
    $hProgress = GUICtrlGetHandle($progress)
    _GUICtrlStatusBar_EmbedControl($StatusBar1, "", $hProgress)
    GUICtrlSetData($progress, 0)
    $r = GUICtrlRead($input)
    $y = $r / 100*1000
    For $i = 0 To 100
    $x = $y * $i
    GUICtrlSetData($progress, $i)
    Sleep($y)
    Next
    MsgBox(0, "Fertig!", "Hat geklappt!")
    Exit
    ;Ende des Countdown-Bereichs
    EndIf
    ;Buttons auf Klick abfragen start
    Case $msg = $Radio5
    $counter = $counter + 1
    $input = GUICtrlCreateInput("", 140, 74, 50, 20)
    $Updown = GUICtrlCreateUpdown($input)
    EndSelect
    WEnd

    [/autoit]

    Edit: Viel zu langsam. Ich sollte zwischenzeitlich mal aktualisieren. :thumbdown: