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

    über mich...

    ich habe meine Erfahrungen hauptsächlich gesammelt in (grobe Übersicht):

    - RibbonBar Automation
    - MySQL Nutzung
    - GUIs in vielerlei Ausprägung
    - Nutzung von Powershell / Batch in AutoIt
    - Windows Automatisierung

    außerhalb von AutoIt:

    - Sprachen: PS, Batch, php, html(5), javascript, (perl eingeschränkt), vbs
    - Powershell (AD, WPF inkl. Multi-Threading, ...)
    - Deployment-Automatisierung ohne SCCM
    - Office-Nutzung mit COM-Object (AutoIt, PowerShell)
    - ActiveDirectory und alles was damit zusammenhängt
    - Hyper-V Clustering (Converged / Hyper Converged)
    - Serverhardware (Konfiguration, Aufbau, Architektur, Betrieb)

    Lieblingsthema:

    günstige Automatisierung von Vorgängen, für die andere Firmen viel Geld nehmen

    more to come ...

    • 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: