Digitaluhr mit Graphic-Controls (Anzeige flackert)

  • ...es scheint hier zu eine Art Puffer- oder Speicherüberlauf zu kommen ?

    Durch setzen von AdlibEnable - Neuaufruf der Funktion kann dieser nicht mehr entstehen.
    Auch die CPU-Last bei ca. 5% finde ich vertretbar ! ;)

    Spoiler anzeigen
    [autoit]


    ; Graphic-Uhr by Oscar
    ; mit Anpassungen von Bernd670
    ; mit Anpassungen von Ritzelrocker04

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

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

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

    Opt('MustDeclareVars', 1)
    Opt('GUIOnEventMode', 1)

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

    Global $gui_digit[6], $dColor = 0xff2222, $eColor = 0x000000, $bgColor = 0xc0c0c0
    Global $s = -1, $m = -1, $h = -1, $hh, $hm, $hs, $ls, $rs

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

    Global $number, $digit ;by RR04

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

    GUICreate('test', 800, 480, -1, -1, $WS_POPUP, BitOr($WS_EX_TOOLWINDOW, $WS_EX_LAYERED))
    GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, '_MoveWindow')
    GUISetOnEvent($GUI_EVENT_CLOSE,'_End')
    GUISetBKColor($bgColor) ; Hintergrundfarbe setzen

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

    $gui_digit[0] = GUICtrlCreateGraphic(20, 20, 32, 56)
    GUICtrlSetBkColor(-1, $bgColor)
    $gui_digit[1] = GUICtrlCreateGraphic(60, 20, 32, 56)
    GUICtrlSetBkColor(-1, $bgColor)
    _Colon(103, 20)
    $gui_digit[2] = GUICtrlCreateGraphic(120, 20, 32, 56)
    GUICtrlSetBkColor(-1, $bgColor)
    $gui_digit[3] = GUICtrlCreateGraphic(160, 20, 32, 56)
    GUICtrlSetBkColor(-1, $bgColor)
    _Colon(203, 20)
    $gui_digit[4] = GUICtrlCreateGraphic(220, 20, 32, 56)
    GUICtrlSetBkColor(-1, $bgColor)
    $gui_digit[5] = GUICtrlCreateGraphic(260, 20, 32, 56)
    GUICtrlSetBkColor(-1, $bgColor)

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

    GUICtrlCreatePic(@ScriptDir & '\nicht loeschen.gif', 0, 0, 1, 1) ; wird für die Transparenz benötigt (nicht löschen)
    GUISetState()

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

    AdlibEnable("_DigitShow", 400) ;by RR04

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

    While 1
    $hh = @HOUR
    If $hh <> $h Then
    GUISetState(@SW_LOCK)
    If $hh = "00" Then
    GUICtrlDelete($gui_digit[0])
    GUICtrlDelete($gui_digit[1])
    $gui_digit[0] = GUICtrlCreateGraphic(20, 20, 32, 56)
    GUICtrlSetBkColor(-1, $bgColor)
    $gui_digit[1] = GUICtrlCreateGraphic(60, 20, 32, 56)
    GUICtrlSetBkColor(-1, $bgColor)
    EndIf
    $ls = StringLeft($hh, 1)
    $rs = StringRight($hh, 1)
    _DigitShow($gui_digit[0], $ls)
    _DigitShow($gui_digit[1], $rs)
    $h = $hh
    GUISetState(@SW_UNLOCK)
    EndIf

    $hm = @MIN
    If $hm <> $m Then
    GUISetState(@SW_LOCK)
    If $hm = "00" Then
    GUICtrlDelete($gui_digit[2])
    GUICtrlDelete($gui_digit[3])
    $gui_digit[2] = GUICtrlCreateGraphic(120, 20, 32, 56)
    GUICtrlSetBkColor(-1, $bgColor)
    $gui_digit[3] = GUICtrlCreateGraphic(160, 20, 32, 56)
    GUICtrlSetBkColor(-1, $bgColor)
    EndIf
    $ls = StringLeft($hm, 1)
    $rs = StringRight($hm, 1)
    _DigitShow($gui_digit[2], $ls)
    _DigitShow($gui_digit[3], $rs)
    $m = $hm
    $h = -1
    GUISetState(@SW_UNLOCK)
    EndIf

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

    $hs = @SEC
    If $hs <> $s Then
    GUISetState(@SW_LOCK)
    If $hs = "00" Then
    GUICtrlDelete($gui_digit[4])
    GUICtrlDelete($gui_digit[5])
    $gui_digit[4] = GUICtrlCreateGraphic(220, 20, 32, 56)
    GUICtrlSetBkColor(-1, $bgColor)
    $gui_digit[5] = GUICtrlCreateGraphic(260, 20, 32, 56)
    GUICtrlSetBkColor(-1, $bgColor)
    EndIf
    $ls = StringLeft($hs, 1)
    $rs = StringRight($hs, 1)
    _DigitShow($gui_digit[4], $ls)
    _DigitShow($gui_digit[5], $rs)
    $s = $hs
    GUISetState(@SW_UNLOCK)
    EndIf
    Sleep(10)
    WEnd

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

    Func _Colon($PosX, $PosY)
    GUICtrlCreateGraphic($PosX, $PosY, 10, 56)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $eColor, $dColor)
    GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, 12, 10, 10)
    GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, 36, 10, 10)
    EndFunc

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

    Func _DigitShow($digit, $number)
    Switch $number ; g
    Case 2, 3, 4, 5, 6, 8, 9
    GUICtrlSetGraphic($digit, $GUI_GR_COLOR, $eColor, $dColor)
    GUICtrlSetGraphic($digit, $GUI_GR_MOVE, 0, 28)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 8, 24)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 24, 24)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 32, 28)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 24, 32)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 8, 32)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 0, 28)
    Case 0, 1, 7
    GUICtrlSetGraphic($digit, $GUI_GR_COLOR, $bgColor, $bgColor)
    GUICtrlSetGraphic($digit, $GUI_GR_MOVE, 2, 28)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 9, 24)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 23, 24)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 30, 28)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 23, 32)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 9, 32)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 2, 28)
    EndSwitch
    Switch $number ; a
    Case 0, 2, 3, 5, 6, 7, 8, 9
    GUICtrlSetGraphic($digit, $GUI_GR_COLOR, $eColor, $dColor)
    GUICtrlSetGraphic($digit, $GUI_GR_MOVE, 0, 0)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 8, 8)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 24, 8)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 32, 0)
    Case 1, 4
    GUICtrlSetGraphic($digit, $GUI_GR_COLOR, $bgColor, $bgColor)
    GUICtrlSetGraphic($digit, $GUI_GR_MOVE, 1, 0)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 9, 8)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 23, 8)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 31, 0)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 1, 0)
    EndSwitch
    Switch $number ; b
    Case 0, 1, 2, 3, 4, 7, 8, 9
    GUICtrlSetGraphic($digit, $GUI_GR_COLOR, $eColor, $dColor)
    GUICtrlSetGraphic($digit, $GUI_GR_MOVE, 32, 0)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 24, 8)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 24, 24)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 32, 28)
    Case 5, 6
    GUICtrlSetGraphic($digit, $GUI_GR_COLOR, $bgColor, $bgColor)
    GUICtrlSetGraphic($digit, $GUI_GR_MOVE, 32, 1)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 24, 9)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 24, 23)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 32, 27)
    EndSwitch
    Switch $number ; c
    Case 0, 1, 3, 4, 5, 6, 7, 8, 9
    GUICtrlSetGraphic($digit, $GUI_GR_COLOR, $eColor, $dColor)
    GUICtrlSetGraphic($digit, $GUI_GR_MOVE, 32, 28)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 24, 32)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 24, 48)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 32, 56)
    Case 2
    GUICtrlSetGraphic($digit, $GUI_GR_COLOR, $bgColor, $bgColor)
    GUICtrlSetGraphic($digit, $GUI_GR_MOVE, 32, 29)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 24, 33)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 24, 48)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 32, 55)
    EndSwitch
    Switch $number ; d
    Case 0, 2, 3, 5, 6, 8, 9
    GUICtrlSetGraphic($digit, $GUI_GR_COLOR, $eColor, $dColor)
    GUICtrlSetGraphic($digit, $GUI_GR_MOVE, 0, 56)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 8, 48)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 24, 48)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 32, 56)
    Case 1, 4, 7
    GUICtrlSetGraphic($digit, $GUI_GR_COLOR, $bgColor, $bgColor)
    GUICtrlSetGraphic($digit, $GUI_GR_MOVE, 1, 56)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 9, 48)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 23, 48)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 31, 56)
    EndSwitch
    Switch $number ; e
    Case 0, 2, 6, 8
    GUICtrlSetGraphic($digit, $GUI_GR_COLOR, $eColor, $dColor)
    GUICtrlSetGraphic($digit, $GUI_GR_MOVE, 0, 28)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 8, 32)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 8, 48)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 0, 56)
    Case 1, 3, 4, 5, 7, 9
    GUICtrlSetGraphic($digit, $GUI_GR_COLOR, $bgColor, $bgColor)
    GUICtrlSetGraphic($digit, $GUI_GR_MOVE, 0, 29)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 8, 33)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 8, 47)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 0, 55)
    EndSwitch
    Switch $number ; f
    Case 0, 4, 5, 6, 8, 9
    GUICtrlSetGraphic($digit, $GUI_GR_COLOR, $eColor, $dColor)
    GUICtrlSetGraphic($digit, $GUI_GR_MOVE, 0, 0)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 8, 8)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 8, 24)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 0, 28)
    Case 1, 2, 3, 7
    GUICtrlSetGraphic($digit, $GUI_GR_COLOR, $bgColor, $bgColor)
    GUICtrlSetGraphic($digit, $GUI_GR_MOVE, 0, 1)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 8, 9)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 8, 23)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 0, 27)
    EndSwitch
    Switch $Number
    Case 1
    GUICtrlSetGraphic($digit, $GUI_GR_COLOR, $bgColor, $bgColor)
    GUICtrlSetGraphic($digit, $GUI_GR_MOVE, 0, 0)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 8, 0)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 8, 56)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 0, 56)
    Case 4
    GUICtrlSetGraphic($digit, $GUI_GR_COLOR, $bgColor, $bgColor)
    GUICtrlSetGraphic($digit, $GUI_GR_MOVE, 0, 33)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 8, 33)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 8, 56)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 0, 56)
    Case 7
    GUICtrlSetGraphic($digit, $GUI_GR_COLOR, $bgColor, $bgColor)
    GUICtrlSetGraphic($digit, $GUI_GR_MOVE, 0, 9)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 8, 9)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 8, 56)
    GUICtrlSetGraphic($digit, $GUI_GR_LINE, 0, 56)
    EndSwitch
    GUICtrlSetGraphic($digit, $GUI_GR_REFRESH)
    EndFunc

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

    Func _MoveWindow()
    Local $DifX, $DifY, $MouseData = GUIGetCursorInfo(@GUI_WinHandle)
    Local $WinPos = WinGetPos(@GUI_WinHandle)
    Local $MPos = MouseGetPos()
    $DifX = $MPos[0] - $WinPos[0]
    $DifY = $MPos[1] - $WinPos[1]
    Do
    Sleep(15)
    $MPos = MouseGetPos()
    $MouseData = GUIGetCursorInfo(@GUI_WinHandle)
    Until ($WinPos[0] <> ($MPos[0] - $DifX)) Or ($WinPos[1] <> ($MPos[1] - $DifY)) Or (Not $MouseData[2])
    While $MouseData[2]
    $MPos = MouseGetPos()
    $WinPos = WinGetPos(@GUI_WinHandle)
    If ($WinPos[0] <> ($MPos[0] - $DifX)) Or ($WinPos[1] <> ($MPos[1] - $DifY)) Then
    WinMove(@GUI_WinHandle, '', $MPos[0] - $DifX, $MPos[1] - $DifY)
    EndIf
    Sleep(15)
    $MouseData = GUIGetCursorInfo(@GUI_WinHandle)
    WEnd
    EndFunc

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

    Func _End()
    Exit
    EndFunc

    [/autoit]


    Weiterhin viel Erfolg!

    • Offizieller Beitrag

    Ich führe gerade einen Langzeittest mit dem Script von Bernd durch.

    Hier mal einige Werte (mit einem AMD x2 6000+ und 2 GB RAM) :

    02.06.08 16:49 = Speicherauslastung 5484 KB und ca. 0...1 % Rechenzeit (Start des Test, Anzeige flackert nicht bzw. selten = 1x pro Minute)

    02.06.08 21:20 = Speicherauslastung 5912 KB und ca. 6...7 % Rechenzeit (Anzeige flackert über alle Stellen und das bereits rel. oft = ca. alle 2 sek.)

    02.06.08 22:34 = Speicherauslastung 6080 KB und ca. 8...9 % Rechenzeit (Anzeige flackert weiter über alle Stellen und noch öfter = jede Sekunde, manchmal mehrmals hintereinander)

    03.06.08 04:22 = Speicherauslastung 6008 KB und ca. 5...6 % Rechenzeit (Anzeige flackert immer noch über alle Stellen und genauso oft wie beim Eintrag vorher)

    Etwas verwirrt bin ich bei der Speicherauslastung und der Rechenzeit. Dort scheint sich eine Stabilisierung eingestellt zu haben. ?(

    03.06.08 08:11 = Speicherauslastung 6184 KB und ca. 9...10 % Rechenzeit. (Anzeige flackert wie beim vorherigen Eintrag)

    Das war's dann mit der Stabilisierung! Die Werte steigen wieder. ?(

    03.06.08 09:05 = Speicherauslastung 6252 KB und ca. 11...12 % Rechenzeit. (Anzeige flackert weiter. Schreibe ich jetzt nicht mehr extra dazu)

    03.06.07 10:03 = Speicherauslastung 6336 KB und ca. 11...12 % Rechenzeit.

    03.06.08 11:02 = Speicherauslastung 6384 KB und ca. 12...13 % Rechenzeit.

    03.06.08 12:06 = Speicherauslastung 6432 KB und ca. 13...14 % Rechenzeit.

    Ich habe den Test jetzt abgebrochen. Das hat keinen Sinn mehr. Ich habe keine Erklärung dafür, wie es zu diesem Aufschaukeln kommt. Das Script mit der Uhr lief die ganze Zeit im Hintergrund und wurde nicht verändert (geht ja bei dem kurzen Script auch gar nicht). Trotzdem stiegen die CPU- und die Speicherauslastung unaufhörlich an.

  • Möglicherweise hilft es, $GUI_GR_CLOSE zu verwenden am Ende von _DigitShow :)

    Zitat

    $GUI_GR_CLOSE to close the current drawing. It has to be added to $GUI_GR_LINE or $GUI_GR_BEZIER to close current drawing. Use alone will be ignored.

  • hab ich in einem meiner Versuche schon getestet.
    Brachte weder bei flackern noch bei Speicher eine Verbesserung.

    Habe auch festgestellt, dass GuiCtrlCreateGraphic sich auch auf andere offene Fenster auswirkt
    und diese zum flackern bringt. z.B. die AutoIt Hilfe, UltraVNC-Fenster...
    ?(?(?(?(?( :wacko: :wacko: :wacko:

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