warum flackern die Zahlen?

  • Der Inhalt kann nicht angezeigt werden, da er nicht mehr verfügbar ist. Guten Abend zusammen.
    War ja jetzt lang nicht mehr anwesend in diesem Forum.

    Hab also auch ne Zeitlang nciht mehr mit AutoIt gemacht.

    Ein Kumpel hat nun aber gefragt, ob ich ihm schnell so eine
    Art große DigitalUhr für den Desktop machen könnte.

    Ich natürlich: "Klar, is net so schwer."

    So, nun hab ich mal nen Test Script gemacht.
    Das Problem ist:
    Die Zahlen fangen wie Wild an zu flackern.

    Hier mal das Script. Die Bilder mit den Zahlen von 0-9 sind in der Zahlen.rar dabei.

    Spoiler anzeigen
    [autoit]

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

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 871, 221, 191, 137)
    GUISetBkColor(0xFFFFFF)
    $Pic1 = GUICtrlCreatePic("0.bmp", 0, 0, 130, 220, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic2 = GUICtrlCreatePic("0.bmp", 140, 0, 130, 220, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic3 = GUICtrlCreatePic("0.bmp", 300, 0, 130, 220, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic4 = GUICtrlCreatePic("0.bmp", 440, 0, 130, 220, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic5 = GUICtrlCreatePic("0.bmp", 600, 0, 130, 220, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic6 = GUICtrlCreatePic("0.bmp", 740, 0, 130, 220, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Label1 = GUICtrlCreateLabel(":", 272, 60, 23, 95)
    GUICtrlSetFont(-1, 72, 400, 0, "Arial")
    $Label2 = GUICtrlCreateLabel(":", 571, 60, 23, 111)
    GUICtrlSetFont(-1, 72, 400, 0, "Arial")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    ; ===
    Local $TimeH = @Hour, $TimeM = @Min, $TimeS = @Sec
    ; ===
    For $H = 0 To 23 Step 1
    If $H < 10 Then
    If $TimeH = $H Then
    GUICtrlSetImage ($Pic1, "0.bmp")
    GUICtrlSetImage ($Pic2, $H & ".bmp")
    EndIf
    Else
    $Split1 = StringSplit ($H, "")
    GUICtrlSetImage ($Pic1, $Split1[1] & ".bmp")
    GUICtrlSetImage ($Pic2, $Split1[2] & ".bmp")
    EndIf
    Next
    ; ===
    For $M = 00 To 59 Step 1
    If $M < 10 Then
    If $TimeM = $M Then
    GUICtrlSetImage ($Pic3, "0.bmp")
    GUICtrlSetImage ($Pic4, $M & ".bmp")
    EndIf
    Else
    $Split2 = StringSplit ($M, "")
    GUICtrlSetImage ($Pic3, $Split2[1] & ".bmp")
    GUICtrlSetImage ($Pic4, $Split2[2] & ".bmp")
    EndIf
    Next
    ; ===
    For $S = 00 To 59 Step 1
    If $S < 10 Then
    If $TimeS = $S Then
    GUICtrlSetImage ($Pic5, "0.bmp")
    GUICtrlSetImage ($Pic6, $S & ".bmp")
    EndIf
    Else
    $Split3 = StringSplit ($S, "")
    GUICtrlSetImage ($Pic5, $Split3[1] & ".bmp")
    GUICtrlSetImage ($Pic6, $Split3[2] & ".bmp")
    EndIf
    Next
    WEnd

    [/autoit]

    Das Prog sieht noch etwas mies aus, aber wenn alles klappt, wird die Optik noch besser...

  • na wiel du in einer schleife deine elemente setzt, das heißt die werden mehrmals sekündlich gesetzt und das macht das flackern

  • lol, bin ja eigl. blöd.
    ich hab die lange methode gemacht xDD
    So gehts doch viel einfacher und ohne flackern ^^

    Spoiler anzeigen
    [autoit]

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

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 871, 221, 191, 137)
    GUISetBkColor(0xFFFFFF)
    $Pic1 = GUICtrlCreatePic("0.bmp", 0, 0, 130, 220, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic2 = GUICtrlCreatePic("0.bmp", 140, 0, 130, 220, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic3 = GUICtrlCreatePic("0.bmp", 300, 0, 130, 220, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic4 = GUICtrlCreatePic("0.bmp", 440, 0, 130, 220, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic5 = GUICtrlCreatePic("0.bmp", 600, 0, 130, 220, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic6 = GUICtrlCreatePic("0.bmp", 740, 0, 130, 220, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Label1 = GUICtrlCreateLabel(":", 272, 60, 23, 95)
    GUICtrlSetFont(-1, 72, 400, 0, "Arial")
    $Label2 = GUICtrlCreateLabel(":", 571, 60, 23, 111)
    GUICtrlSetFont(-1, 72, 400, 0, "Arial")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    ; ===
    Local $TimeH = @Hour, $TimeM = @Min, $TimeS = @Sec
    ;~ ; ===
    $Split1 = StringSplit ($TimeH, "")
    $Split2 = StringSplit ($TimeM, "")
    $Split3 = StringSplit ($TimeS, "")
    ; ===
    GUICtrlSetImage ($Pic1, $Split1[1] & ".bmp")
    GUICtrlSetImage ($Pic2, $Split1[2] & ".bmp")

    GUICtrlSetImage ($Pic3, $Split2[1] & ".bmp")
    GUICtrlSetImage ($Pic4, $Split2[2] & ".bmp")

    GUICtrlSetImage ($Pic5, $Split3[1] & ".bmp")
    GUICtrlSetImage ($Pic6, $Split3[2] & ".bmp")
    WEnd

    [/autoit]
  • Hier das ganze mal CPU-Sparender

    Spoiler anzeigen
    [autoit]

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

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 871, 221, 191, 137)
    GUISetBkColor(0xFFFFFF)
    $Pic1 = GUICtrlCreatePic("0.bmp", 0, 0, 130, 220, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic2 = GUICtrlCreatePic("0.bmp", 140, 0, 130, 220, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic3 = GUICtrlCreatePic("0.bmp", 300, 0, 130, 220, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic4 = GUICtrlCreatePic("0.bmp", 440, 0, 130, 220, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic5 = GUICtrlCreatePic("0.bmp", 600, 0, 130, 220, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic6 = GUICtrlCreatePic("0.bmp", 740, 0, 130, 220, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Label1 = GUICtrlCreateLabel(":", 272, 60, 23, 95)
    GUICtrlSetFont(-1, 72, 400, 0, "Arial")
    $Label2 = GUICtrlCreateLabel(":", 571, 60, 23, 111)
    GUICtrlSetFont(-1, 72, 400, 0, "Arial")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    $oldSec = @SEC
    While 1 * sleep(1)
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    ; ===
    Local $TimeH = @Hour, $TimeM = @Min, $TimeS = @Sec
    ;~ ; ===
    if $oldSec <> $TimeS Then
    $Split1 = StringSplit ($TimeH, "")
    $Split2 = StringSplit ($TimeM, "")
    $Split3 = StringSplit ($TimeS, "")
    ; ===
    GUICtrlSetImage ($Pic1, $Split1[1] & ".bmp")
    GUICtrlSetImage ($Pic2, $Split1[2] & ".bmp")

    GUICtrlSetImage ($Pic3, $Split2[1] & ".bmp")
    GUICtrlSetImage ($Pic4, $Split2[2] & ".bmp")

    GUICtrlSetImage ($Pic5, $Split3[1] & ".bmp")
    GUICtrlSetImage ($Pic6, $Split3[2] & ".bmp")
    $oldSec = $TimeS
    EndIf
    WEnd

    [/autoit]
  • ich hätte es so gelöst:

    Spoiler anzeigen
    [autoit]

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

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 871, 221, 191, 137)
    GUISetBkColor(0x000000)
    $Pic1 = GUICtrlCreatePic("0.bmp", 0, 0, 130, 220, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic2 = GUICtrlCreatePic("0.bmp", 140, 0, 130, 220, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic3 = GUICtrlCreatePic("0.bmp", 300, 0, 130, 220, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic4 = GUICtrlCreatePic("0.bmp", 440, 0, 130, 220, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic5 = GUICtrlCreatePic("0.bmp", 600, 0, 130, 220, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic6 = GUICtrlCreatePic("0.bmp", 740, 0, 130, 220, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Label1 = GUICtrlCreateLabel(":", 272, 60, 23, 95)
    GUICtrlSetFont(-1, 72, 400, 0, "Arial")
    $Label2 = GUICtrlCreateLabel(":", 571, 60, 23, 111)
    GUICtrlSetFont(-1, 72, 400, 0, "Arial")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    Global $pics[10] = ["0.bmp","1.bmp","2.bmp","3.bmp","4.bmp","5.bmp","6.bmp","7.bmp","8.bmp","9.bmp"]
    Global $TimeH_old, $TimeM_old, $TimeS_old,$TimeH, $TimeM, $TimeS
    AdlibEnable("time_aktuell",1000)
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    Sleep(10)
    WEnd

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

    Func time_aktuell()
    $TimeH = @Hour
    $TimeM = @Min
    $TimeS = @Sec
    If $TimeH_old <> $TimeH Then
    GUICtrlSetImage($Pic1,$pics[StringLeft($TimeH,1)])
    GUICtrlSetImage($Pic2,$pics[StringRight($TimeH,1)])
    EndIf
    If $TimeM_old <> $TimeM Then
    GUICtrlSetImage($Pic3,$pics[StringLeft($TimeM,1)])
    GUICtrlSetImage($Pic4,$pics[StringRight($TimeM,1)])
    EndIf
    If $TimeS_old <> $TimeS Then
    GUICtrlSetImage($Pic5,$pics[StringLeft($TimeS,1)])
    GUICtrlSetImage($Pic6,$pics[StringRight($TimeS,1)])
    EndIf
    $TimeH_old = $TimeH
    $TimeM_old = $TimeM
    $TimeS_old = $TimeS
    EndFunc

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