Hier mein erster Versuch mit GDI
Soll mal eine Digi-Uhr fürn Desktop werden
Zur Zeit besteht mein Problem darin,daß sich das laufende (noch nicht fertige) Programm weder durch ESC noch X-Fensterbutton abbrechen lässt.Es hängt auf alle Fälle mit der Sleep time in der While-Schleife zusammen,doch wenn ich sie runtersetze,flackert es.
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <Date.au3>
#include <GDIPlus.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("", 300, 400, 392, 124)
GUICtrlSetFont(-1, 20, 400, 0, "Comic Sans MS")
GUICtrlSetColor(-1, 0x000000)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
#region Declaration
Global $x=100
Global $y=100
Global $x1=170
$x2=200
$x3=170
$x4=300
dim $ziffer[10]
$ziffer[1]="0.0.1.1.0.0.0.0.0.0.0.1.1.1.1.0.0.0.0.0.0"
$ziffer[2]="1.0.0.1.1.1.1.0.0.1.1.1.1.0.0.1.1.1.1.1.1"
$ziffer[3]="0.0.1.1.1.1.1.0.0.0.0.1.1.1.1.1.1.1.1.1.1"
$ziffer[4]="0.1.1.1.0.1.0.1.1.0.0.1.1.1.1.0.0.1.1.0.0"
$ziffer[5]="0.1.1.0.1.1.1.1.1.0.0.0.0.1.1.1.1.1.1.1.1"
$ziffer[6]="1.1.1.0.0.1.1.1.1.1.1.0.0.1.1.0.0.1.1.1.1"
$ziffer[7]="0.0.1.1.1.0.0.0.0.0.0.1.1.1.1.1.1.0.0.0.0"
$ziffer[8]="1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1"
$ziffer[9]="0.1.1.1.1.1.0.1.1.0.0.1.1.1.1.1.1.1.1.0.0"
$ziffer[0]="1.1.1.1.1.0.1.1.1.1.1.1.1.1.1.1.1.0.0.1.1"
dim $dreieck[4][2]
dim $dreieck1[4][2]
dim $dreieck2[4][2]
dim $dreieck3[4][2]
dim $dreieck4[4][2]
dim $dreieck5[4][2]
dim $dreieck6[4][2]
dim $dreieck7[4][2]
dim $dreieck8[4][2]
dim $dreieck9[4][2]
dim $dreieck10[4][2]
dim $dreieck11[4][2]
dim $dreieck12[4][2]
dim $dreieck13[4][2]
$d =$x &": "&$x &":"&$x+10 &":"&$x &":" &$x+5 &":"&$x-5
$d1=$x &":" &$x2&":"&$x+10 &":"&$x2&":" &$x+5 &":"&$x2+5
$d2=$x &":" &$x2+10 &":"&$x+10 &":"&$x2+10 &":" &$x+5 &":"&$x2+5
$d3=$x &":" &$x4+10 &":"&$x+10 &":"&$x4+10 &":" &$x+5 &":"&$x4+15
$d4=$x3&":" &$x &":"&$x3+10 &":"&$x &":" &$x3+5 &":"&$x-5
$d5=$x3&":" &$x2&":"&$x3+10 &":"&$x2&":" &$x3+5 &":"&$x2+5
$d6=$x3&":" &$x2+10 &":"&$x3+10 &":"&$x2+10 &":" &$x3+5 &":"&$x2+5
$d7=$x3&":" &$x4+10 &":"&$x3+10 &":"&$x4+10 &":" &$x3+5 &":"&$x4+15
$d8=$x+10 &": "&$x-5 &":"&$x+20 &":"&$x-10 &":" &$x+20 &":"&$x
$d9=$x+70 &": "&$x-5 &":"&$x+60 &":"&$x-10 &":" &$x+60 &":"&$x
$d10=$x+10 &": "&$x2+5 &":"&$x+20 &":"&$x2&":" &$x+20 &":"&$x2+10
$d11=$x+70 &": "&$x2+5 &":"&$x+60 &":"&$x2&":" &$x+60 &":"&$x2+10
$d12=$x+10 &": "&$x4+15 &":"&$x+20 &":"&$x4+10 &":" &$x+20 &":"&$x4+20
$d13=$x+70 &": "&$x4+15 &":"&$x+60 &":"&$x4+10 &":" &$x+60 &":"&$x4+20
arrayfill($dreieck,$d)
arrayfill($dreieck1,$d1)
arrayfill($dreieck2,$d2)
arrayfill($dreieck3,$d3)
arrayfill($dreieck4,$d4)
arrayfill($dreieck5,$d5)
arrayfill($dreieck6,$d6)
arrayfill($dreieck7,$d7)
arrayfill($dreieck8,$d8)
arrayfill($dreieck9,$d9)
arrayfill($dreieck10,$d10)
arrayfill($dreieck11,$d11)
arrayfill($dreieck12,$d12)
arrayfill($dreieck13,$d13)
#endregion
_GDIPlus_Startup()
Global $grafik=_GDIPlus_GraphicsCreateFromHWND($Form1)
Global $Brush = _GDIPlus_BrushCreateSolid(0xFF1234FF)
Global $Brush1 = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
_GDIPlus_GraphicsClear($grafik,0xFFffffff)
While 1
$uhr=_NowTime(5)
$zeit=StringSplit($uhr,":")
$b=stringright($zeit[3],1)
Select
case $b="0"
_1($ziffer[0])
case $b="1"
_1($ziffer[1])
case $b="2"
_1($ziffer[2])
case $b="3"
_1($ziffer[3])
case $b="4"
_1($ziffer[4])
case $b="5"
_1($ziffer[5])
case $b="6"
_1($ziffer[6])
case $b="7"
_1($ziffer[7])
case $b="8"
_1($ziffer[8])
case $b="9"
_1($ziffer[9])
EndSelect
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
Sleep(1000)
_GDIPlus_GraphicsClear($grafik,0xFFffffff)
WEnd
_GDIPlus_GraphicsDispose($grafik)
_GDIPlus_Shutdown()
func _1(ByRef $ziffer)
$teil=StringSplit($ziffer,".")
if $teil[1]=1 then $strichsenkrecht1=_GDIPlus_GraphicsfillRect($grafik,$x,$y+110,10,$x,$Brush)
if $teil[2]=1 then $strichsenkrecht2=_GDIPlus_GraphicsfillRect($grafik,$x,$y,10,$x,$Brush)
if $teil[3]=1 then $strichsenkrecht3=_GDIPlus_GraphicsfillRect($grafik,$x1,$y+110,10,$x,$Brush)
if $teil[4]=1 then $strichsenkrecht4=_GDIPlus_GraphicsfillRect($grafik,$x1,$y,10,$x,$Brush)
if $teil[5]=1 then $strichwaagerecht1=_GDIPlus_GraphicsfillRect($grafik,$x+20,$y-10,40,10,$Brush)
if $teil[6]=1 then $strichwaagerecht2=_GDIPlus_GraphicsfillRect($grafik,$x+20,$y+100,40,10,$Brush)
if $teil[7]=1 then $strichwaagerecht3=_GDIPlus_GraphicsfillRect($grafik,$x+20,$y+210,40,10,$Brush)
if $teil[8]=1 then $dreiecksenkrecht1=_GDIPlus_GraphicsFillPolygon($grafik,$dreieck,$Brush)
if $teil[9]=1 then $dreiecksenkrecht2=_GDIPlus_GraphicsFillPolygon($grafik,$dreieck1,$Brush)
if $teil[10]=1 then $dreiecksenkrecht3=_GDIPlus_GraphicsFillPolygon($grafik,$dreieck2,$Brush)
if $teil[11]=1 then $dreiecksenkrecht4=_GDIPlus_GraphicsFillPolygon($grafik,$dreieck3,$Brush)
if $teil[12]=1 then $dreiecksenkrecht5=_GDIPlus_GraphicsFillPolygon($grafik,$dreieck4,$Brush)
if $teil[13]=1 then $dreiecksenkrecht6=_GDIPlus_GraphicsFillPolygon($grafik,$dreieck5,$Brush)
if $teil[14]=1 then $dreiecksenkrecht7=_GDIPlus_GraphicsFillPolygon($grafik,$dreieck6,$Brush)
if $teil[15]=1 then $dreiecksenkrecht8=_GDIPlus_GraphicsFillPolygon($grafik,$dreieck7,$Brush)
if $teil[16]=1 then $dreieckwaagerecht1=_GDIPlus_GraphicsFillPolygon($grafik,$dreieck8,$Brush)
if $teil[17]=1 then $dreieckwaagerecht2=_GDIPlus_GraphicsFillPolygon($grafik,$dreieck9,$Brush)
if $teil[18]=1 then $dreieckwaagerecht3=_GDIPlus_GraphicsFillPolygon($grafik,$dreieck10,$Brush)
if $teil[19]=1 then $dreieckwaagerecht4=_GDIPlus_GraphicsFillPolygon($grafik,$dreieck11,$Brush)
if $teil[20]=1 then $dreieckwaagerecht5=_GDIPlus_GraphicsFillPolygon($grafik,$dreieck12,$Brush)
if $teil[21]=1 then $dreieckwaagerecht6=_GDIPlus_GraphicsFillPolygon($grafik,$dreieck13,$Brush)
EndFunc
func arrayfill(byref $dreieck,$coords)
$a2=StringSplit($coords,":")
$1=1
$2=0
for $q=1 to 6
$dreieck[0][0]=3
$dreieck[$1][$2]=$a2[$q]
if $2=0 then
$2=1
else
$2=0
$1+=1
EndIf
Next
return $dreieck
EndFunc
OK,fürs erste mit Hotkey gelöst
So jetzt isses erst mal lauffähig
hoffe auf verbesserungsvorschläge ( versucht mal rechtsklick auf die Uhr-->> ist zur zeit meine baustelle---<<< Anregungen unbedingt erwünscht
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <Array.au3>
#include <GDIPlus.au3>
#Include <Date.au3>
#Include <String.au3>
#region
HotKeySet("{ESC}", "ende")
Local $offset1=0,$offset2=0,$neu="",$senkrecht="50,10,55,15,55,95,50,100,45,95,45,15",$waagerecht="55,10,60,5,100,5,105,10,100,15,60,15"
Global $array[43],$wo[7],$wo2[7][8],$segmentort1[7][8],$array2[7][2],$array3[7][2],$ziffer[7],$trans=255
$ziffer[1]="1,2,13,14,25,31,37"
$ziffer[2]="3,4,15,16,26,32,38"
$ziffer[3]="5,6,17,18,27,33,39"
$ziffer[4]="7,8,19,20,28,34,40"
$ziffer[5]="9,10,21,22,29,35,41"
$ziffer[6]="11,12,23,24,30,36,42"
for $a=1 to 24
$teil=StringSplit($senkrecht,",")
for $teil1=1 to 11 step 2
$teil[$teil1]=$teil[$teil1]+$offset1
next
for $teil1=2 to 12 step 2
$teil[$teil1]=$teil[$teil1]+$offset2
next
for $teil1=1 to 12
$neu=$neu&$teil[$teil1]&","
Next
$neu=StringTrimRight($neu,1)
$array[$a]=$neu
$offset1+=60
$neu=""
if $a=12 then
$offset1=0
$offset2=90
EndIf
Next
Local $offset1=0,$offset2=0
for $a=25 to 42
$teil=StringSplit($waagerecht,",")
for $teil1=1 to 11 step 2
$teil[$teil1]=$teil[$teil1]+$offset1
next
for $teil1=2 to 12 step 2
$teil[$teil1]=$teil[$teil1]+$offset2
next
for $teil1=1 to 12
$neu=$neu&$teil[$teil1]&","
Next
$neu=StringTrimRight($neu,1)
$array[$a]=$neu
$offset1+=120
$neu=""
if $a=30 then
$offset1=0
$offset2=90
EndIf
if $a=36 then
$offset1=0
$offset2=180
EndIf
Next
#endregion
#region
$Form1 = GUICreate("1", 800,200, 100, 205,$WS_POPUP)
GUISetBkColor(0x000000)
GUISetState()
_GDIPlus_Startup()
Global $grafik=_GDIPlus_GraphicsCreateFromHWND($Form1)
Global $Brush = _GDIPlus_BrushCreateSolid(0xff00bb00)
Global $Brush1 = _GDIPlus_BrushCreateSolid(0xFF000000)
#endregion
While 1
[/autoit] [autoit][/autoit] [autoit]$nMsg = GUIGetMsg()
$maus=GUIGetCursorInfo ($Form1)
Switch $nMsg
Case $GUI_EVENT_CLOSE
_GDIPlus_GraphicsDispose($grafik)
_GDIPlus_Shutdown()
Exit
EndSwitch
Select
case $maus[3]=1
if not WinExists("2","") then optionen()
EndSelect
uhrzeit()
WEnd
func optionen()
$Form2 = GUICreate("2", 800,50, 100, 405,$WS_POPUP)
GUISetBkColor(0xFFFFFF)
$exitbutton=GUICtrlCreateButton("Fertig",750,10,40,30)
$transslider=GUICtrlCreateSlider(10,10,150,30)
GUICtrlSetBkColor(-1,0xFFFFFF)
GUICtrlSetLimit(-1, 250,0)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $exitbutton
GUIDelete($Form2)
ExitLoop
case $transslider
$trans=GUICtrlRead($transslider)
GUISetBkColor(RGB2BGR($trans),$Form1)
_GDIPlus_BrushSetSolidColor($Brush1,_StringInsert(RGB2BGR($trans),"FF",2))
EndSwitch
WEnd
EndFunc
Func uhrzeit()
$uhr=_NowTime(5)
$zeit=StringSplit($uhr,":")
$St1 =StringLeft ($zeit[1],1)
$St2 =StringRight($zeit[1],1)
$Min1=StringLeft ($zeit[2],1)
$Min2=StringRight($zeit[2],1)
$Sek1=StringLeft ($zeit[3],1)
$Sek2=StringRight($zeit[3],1)
ziffer($St1 ,1)
ziffer($St2 ,2)
ziffer($Min1,3)
ziffer($Min2,4)
ziffer($Sek1,5)
ziffer($Sek2,6)
$Stunde1 =StringSplit($ziffer[1],",")
$Stunde2 =StringSplit($ziffer[2],",")
$Minute1 =StringSplit($ziffer[3],",")
$Minute2 =StringSplit($ziffer[4],",")
$Sekunde1=StringSplit($ziffer[5],",")
$Sekunde2=StringSplit($ziffer[6],",")
$wo[0]=$uhr
for $a = 1 to 6
for $b=1 to 7
$segmentort=StringSplit($ziffer[$a],",")
$wo1=StringSplit($wo[$a],",")
$wo2[$a][$b]=$wo1[$b]
if $wo2[$a][$b]=1 then
$segmentort1[$a][$b]="1|"&$segmentort[$b]
Else
$segmentort1[$a][$b]="0|"&$segmentort[$b]
EndIf
Next
Next
segment()
EndFunc
func ziffer(ByRef $zeit,$segment)
Select
case $zeit="0"
$wo[$segment]="1,1,1,1,1,0,1"
case $zeit="1"
$wo[$segment]="0,1,0,1,0,0,0"
case $zeit="2"
$wo[$segment]="0,1,1,0,1,1,1"
case $zeit="3"
$wo[$segment]="0,1,0,1,1,1,1"
case $zeit="4"
$wo[$segment]="1,1,0,1,0,1,0"
case $zeit="5"
$wo[$segment]="1,0,0,1,1,1,1"
case $zeit="6"
$wo[$segment]="1,0,1,1,1,1,1"
case $zeit="7"
$wo[$segment]="0,1,0,1,1,0,0"
case $zeit="8"
$wo[$segment]="1,1,1,1,1,1,1"
case $zeit="9"
$wo[$segment]="1,1,0,1,1,1,0"
EndSelect
return $wo
EndFunc
Func segment()
Local $px1=250, $px2=495,$ww=""
_GDIPlus_GraphicsFillEllipse($grafik,$px1,60, 15, 15,$Brush1)
_GDIPlus_GraphicsFillEllipse($grafik,$px1,120, 15, 15,$Brush1)
_GDIPlus_GraphicsFillEllipse($grafik,$px2,60, 15, 15,$Brush1)
_GDIPlus_GraphicsFillEllipse($grafik,$px2,120, 15, 15,$Brush1)
Sleep(500)
for $a = 1 to 6
For $b=1 to 7
$ww=$ww&$segmentort1[$a][$b]&","
Next
Next
$ww1=StringSplit($ww,",")
for $a=1 to 42
if StringLeft($ww1[$a],1)="1" then
$senkrecht1=StringSplit($array[StringTrimLeft($ww1[$a],2)],",")
$array2[0][0]=6
$array2[1][0]=$senkrecht1[1]
$array2[1][1]=$senkrecht1[2]
$array2[2][0]=$senkrecht1[3]
$array2[2][1]=$senkrecht1[4]
$array2[3][0]=$senkrecht1[5]
$array2[3][1]=$senkrecht1[6]
$array2[4][0]=$senkrecht1[7]
$array2[4][1]=$senkrecht1[8]
$array2[5][0]=$senkrecht1[9]
$array2[5][1]=$senkrecht1[10]
$array2[6][0]=$senkrecht1[11]
$array2[6][1]=$senkrecht1[12]
_GDIPlus_GraphicsFillPolygon($grafik,$array2,$Brush)
Else
$senkrecht1=StringSplit($array[StringTrimLeft($ww1[$a],2)],",")
$array2[0][0]=6
$array2[1][0]=$senkrecht1[1]
$array2[1][1]=$senkrecht1[2]
$array2[2][0]=$senkrecht1[3]
$array2[2][1]=$senkrecht1[4]
$array2[3][0]=$senkrecht1[5]
$array2[3][1]=$senkrecht1[6]
$array2[4][0]=$senkrecht1[7]
$array2[4][1]=$senkrecht1[8]
$array2[5][0]=$senkrecht1[9]
$array2[5][1]=$senkrecht1[10]
$array2[6][0]=$senkrecht1[11]
$array2[6][1]=$senkrecht1[12]
_GDIPlus_GraphicsFillPolygon($grafik,$array2,$Brush1)
EndIf
Next
_GDIPlus_GraphicsFillEllipse($grafik,$px1,60, 15, 15,$Brush)
_GDIPlus_GraphicsFillEllipse($grafik,$px1,120, 15, 15,$Brush)
_GDIPlus_GraphicsFillEllipse($grafik,$px2,60, 15, 15,$Brush)
_GDIPlus_GraphicsFillEllipse($grafik,$px2,120, 15, 15,$Brush)
sleep(500)
EndFunc
func ende()
_GDIPlus_GraphicsDispose($grafik)
_GDIPlus_Shutdown()
Exit
EndFunc
Func RGB2BGR($iColor)
Local $sH = Hex($iColor,6)
Return '0x' & StringRight($sH, 2) & StringMid($sH,3,2) & StringLeft($sH, 2)
EndFunc
wenn ich euch damit nerve,sagt bescheid,dann schließe ich dasThema