- Offizieller Beitrag
Ich habe die Anzeige der Uhr auf Graphic-Controls umgestellt, allerdings tritt dabei ein seltsames Verhalten auf. Anfangs läuft die Uhr normal, aber so nach ca. 1 Minute fangen die Sekunden an zu flackern. Nach 2 Minuten flackern sie noch häufiger und teilweise flackert die gesamte Anzeige. Ich kann mir nicht erklären, woran das liegt. Die einzelnen Segmente der 7-Segment-Anzeigen werden nur gezeichnet/überschrieben wenn sie gebraucht werden und wie schon gesagt läuft die Anzeige anfangs auch ganz normal.
Hat jemand eine Erklärung/Abhilfe dafür?
Hier mal das Script:
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
Opt('MustDeclareVars', 1)
Opt('GUIOnEventMode', 1)
Global $gui_digit[6], $dColor = 0xff2222, $eColor = 0x000000, $bgColor = 0xc0c0c0
Global $s = -1, $m = -1, $h = -1, $ls, $rs
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
$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)
GUICtrlCreatePic(@ScriptDir & '\nicht loeschen.gif', 0, 0, 1, 1) ; wird für die Transparenz benötigt (nicht löschen)
GUISetState()
While 1
If @HOUR <> $h Then
$ls = StringLeft(@HOUR, 1)
$rs = StringRight(@HOUR, 1)
_DigitShow($gui_digit[0], $ls)
_DigitShow($gui_digit[1], $rs)
$h = @HOUR
EndIf
If @MIN <> $m Then
$ls = StringLeft(@MIN, 1)
$rs = StringRight(@MIN, 1)
_DigitShow($gui_digit[2], $ls)
_DigitShow($gui_digit[3], $rs)
$m = @MIN
EndIf
If @SEC <> $s Then
$ls = StringLeft(@SEC, 1)
$rs = StringRight(@SEC, 1)
_DigitShow($gui_digit[4], $ls)
_DigitShow($gui_digit[5], $rs)
$s = @SEC
EndIf
Sleep(980)
WEnd
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
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,
GUICtrlSetGraphic($digit, $GUI_GR_LINE, 24,
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,
GUICtrlSetGraphic($digit, $GUI_GR_LINE, 23,
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,
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,
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
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
Func _End()
Exit
EndFunc
Im ZIP-Achiv (Anhang) befindet sich auch die GIF-Datei.