Hallo,
vor kurzem wollte ich aus langeweile mal ne Binäruhr basteln.
Nachdem die Uhr dann (mehr oder weniger schön) gescriptet war, habe ich mir überlegt, man könnte ja noch die Uhrzeit als Dezimal anzeigen lassen (z.B. um den Vergleich zu sehen). Dann kamen immer mehr Inforamtionen in die gui bis es jetzt schließlich ein kleines Infofenster ist
Dann habe ich zusätzlich das Programm umgecodet auf GDI+
Da ich eig. nur was kleines aus langeweile bauen wollte, ist der Code leider sehr unleserlich. Das tut mir leid. ich werde evtl nochmal versuchen den Code zu verbessern!
Evtl werde ich noch ein "Einstellungsfenster" reinscripten, mit welchem man z.B. das Hintergrundbild, die Schriftart... beliebig anpassen kann.
Hier mal mein (unübersichtlicher) Code:
Spoiler anzeigen
#cs ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]AutoIt Version: 3.3.6.1
Author: t4ggno
Script Function:
Creates a infoGui
#ce ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
$HIDETASKLEISTE = regread("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2","Settings")
if StringMid($HIDETASKLEISTE,19,2) = "03" or StringMid($HIDETASKLEISTE,18,2) = "01" or StringMid($HIDETASKLEISTE,18,2) = "0D" Then
$VISIBLETASKLEISTE = 0
Else
$VISIBLETASKLEISTE = 40
EndIf
Global $Binaer[8] = [128,64,32,16,8,4,2,1]
Global $STATE = "SHOW"
if @OSArch = "X64" then
$REG = "HKLM64"
ElseIf @OSArch = "X86" then
$REG = "HKLM"
Else
Exit
EndIf
$CPUS = RegRead($REG & "\HARDWARE\DESCRIPTION\System\CentralProcessor\0","ProcessorNameString")
if StringLen($CPUS) > 30 Then $CPUS = StringLeft($CPUS,27) & "..."
$GPUS = RegRead($REG & "\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winsat","PrimaryAdapterString")
if StringLen($GPUS) > 30 Then $GPUS = StringLeft($GPUS,27) & "..."
$CPUBS = RegRead($REG & "\HARDWARE\DESCRIPTION\System\FloatingPointProcessor\0","Identifier")
if StringInStr($CPUBS,"64") Then
$CPUBS = 64
Else
$CPUBS = 32
EndIf
$Gui = GUICreate("Binary-Clock",@DesktopWidth-2,60,0,@DesktopHeight-60-$VISIBLETASKLEISTE,BitOR($WS_BORDER,$WS_POPUP),$WS_EX_TOOLWINDOW)
$Sekunden = GUICtrlCreateLabel("",20,20,200,20)
$BSekunden = GUICtrlCreateLabel("",20,20,200,20)
if @DesktopWidth >= 1920 Then
$TIMEDEZIMALBIN = 1500
$TIMEDEZIMALBINH = 5
$TIMEDEZIMAL = 1500
$TIMEDEZIMALH = 35
$ANGEMELDET = 450
$ANGEMELDETH = 5
$AKTIVEW = 450
$AKTIVEWH = 35
$RAMFREE = 230
$RAMFREEH = 5
$RAMFREEPRO = 230
$RAMFREEPROH = 35
$CPU = 920
$CPUH = 5
$GPU = 920
$GPUH = 35
$IP = 720
$IPH = 5
$CPUB = 1300
$CPUBH = 5
$OS = 1300
$OSH = 35
ElseIf @DesktopWidth >= 1600 Then
$TIMEDEZIMALBIN = 1200
$TIMEDEZIMALBINH = 5
$TIMEDEZIMAL = 1200
$TIMEDEZIMALH = 35
$ANGEMELDET = 450
$ANGEMELDETH = 5
$AKTIVEW = 450
$AKTIVEWH = 35
$RAMFREE = 230
$RAMFREEH = 5
$RAMFREEPRO = 230
$RAMFREEPROH = 35
$CPU = 820
$CPUH = 5
$GPU = 820
$GPUH = 35
ElseIf @DesktopWidth >= 1280 Then
$TIMEDEZIMAL = 600
$TIMEDEZIMALH = 5
$ANGEMELDET = 950
$ANGEMELDETH = 5
$AKTIVEW = 600
$AKTIVEWH = 35
$RAMFREE = 300
$RAMFREEH = 5
$RAMFREEPRO = 300
$RAMFREEPROH = 35
ElseIf @DesktopWidth >= 1024 Then
$TIMEDEZIMAL = 500
$TIMEDEZIMALH = 5
$ANGEMELDET = 750
$ANGEMELDETH = 5
$AKTIVEW = 500
$AKTIVEWH = 35
$RAMFREE = 250
$RAMFREEH = 5
$RAMFREEPRO = 250
$RAMFREEPROH = 35
ElseIf @DesktopWidth >= 800 Then
$TIMEDEZIMAL = 250
$TIMEDEZIMALH = 5
$ANGEMELDET = 550
$ANGEMELDETH = 5
$AKTIVEW = 250
$AKTIVEWH = 35
EndIf
_GDIPlus_Startup ()
$Graphics = _GDIPlus_GraphicsCreateFromHWND($Gui) ;Grafische Oberfläche wird erzeugt
$Bitmap = _GDIPlus_BitmapCreateFromGraphics(@DesktopWidth, 100, $Graphics)
$Backbuffer = _GDIPlus_ImageGetGraphicsContext($Bitmap)
$Brush = _GDIPlus_BrushCreateSolid(0xFF000000)
$hBrush = _GDIPlus_BrushCreateSolid (0xFFFFFFFF)
$hFormat = _GDIPlus_StringFormatCreate ()
$hFamily = _GDIPlus_FontFamilyCreate ("Arial")
$hFont = _GDIPlus_FontCreate ($hFamily, 15, 2)
$BK = _GDIPlus_BitmapCreateFromFile("Bild.bmp")
$BILD_BREITE = _GDIPlus_ImageGetWidth($BK)
$BILD_HOEHE = _GDIPlus_ImageGetHeight($BK)
WinSetOnTop("Binary-Clock","",1)
GUISetState(@SW_SHOW)
AdlibRegister("AKTUA",1000)
AdlibRegister("WINC",200)
AdlibRegister("WINMOV",10)
AKTUA()
While 1
if GUIGetMsg() = $GUI_EVENT_CLOSE then Exit
Sleep(2000)
WEnd
[/autoit] [autoit][/autoit] [autoit]Func WINMOV()
if MouseGetPos(1) > @DesktopHeight-60 - $VISIBLETASKLEISTE Then
if $STATE <> "HIDE" Then
WinMove("Binary-Clock","",0,@DesktopHeight+10,@DesktopWidth,100,2)
$STATE = "HIDE"
EndIf
Else
if $STATE <> "SHOW" Then
WinMove("Binary-Clock","",0,@DesktopHeight-60 - $VISIBLETASKLEISTE,@DesktopWidth,60,2)
AKTUA()
$STATE = "SHOW"
EndIf
EndIf
EndFunc
Func WINC()
$size = WinGetPos("[active]")
if WinGetTitle("[active]") <> WinGetTitle($Gui) and WinGetTitle("[active]") <> WinGetTitle("[CLASS:DV2ControlHost]","") And WinGetTitle("[active]") <> WinGetTitle("[CLASS:Progman]","") Then
if $size[1] + $size[3] > @DesktopHeight-60 - $VISIBLETASKLEISTE Then
WinMove(WinGetTitle("[active]") ,"",$size[0],$size[1],$size[2],(@DesktopHeight-60 - $VISIBLETASKLEISTE)-$size[1])
EndIf
sleep(50)
EndIf
EndFunc
Func AKTUA()
if @DesktopWidth >= 800 Then
$Time = "Zeit (Binär): "
$Wert = @HOUR
For $i = 0 to 7 Step 1
if $Wert - $Binaer[$i] < 0 Then
$Time = $Time & "0"
Else
$Time = $Time & "1"
$Wert = $Wert - $Binaer[$i]
EndIf
Next
if $Wert <> 0 Then
MsgBox(0,"Error","This Easy Code make a Error. Sry!")
EndIf
$Time = $Time & "."
$Wert = @MIN
For $i = 0 to 7 Step 1
if $Wert - $Binaer[$i] < 0 Then
$Time = $Time & "0"
Else
$Time = $Time & "1"
$Wert = $Wert - $Binaer[$i]
EndIf
Next
if $Wert <> 0 Then
MsgBox(0,"Error","This Easy Code make a Error. Sry!")
EndIf
$Time = $Time & ":"
$Wert = @SEC
For $i = 0 to 7 Step 1
if $Wert - $Binaer[$i] < 0 Then
$Time = $Time & "0"
Else
$Time = $Time & "1"
$Wert = $Wert - $Binaer[$i]
EndIf
Next
if $Wert <> 0 Then
MsgBox(0,"Error","This Easy Code make a Error. Sry!")
EndIf
EndIf
$Mem = MemGetStats ( )
$TITLE = WinGetTitle("[active]")
if StringLen($TITLE) > 20 Then $TITLE = StringLeft($TITLE,17) & "..."
_GDIPlus_GraphicsFillRect($Backbuffer, 0, 0, @DesktopWidth,100,$Brush)
_GDIPlus_GraphicsDrawImageRectRect($Backbuffer, $BK,0,0,$BILD_BREITE,$BILD_HOEHE,0,0,@DesktopWidth,100)
if @DesktopWidth >= 1600 Then
;~ _GDIPlus_GraphicsDrawString($Backbuffer, $Time, $TIMEDEZIMALBIN, $TIMEDEZIMALBINH,"Arial",15,0x0400)
$tLayout = _GDIPlus_RectFCreate ($TIMEDEZIMALBIN, $TIMEDEZIMALBINH, 0, 0)
$aInfo = _GDIPlus_GraphicsMeasureString ($Backbuffer, $Time, $hFont, $tLayout, $hFormat)
_GDIPlus_GraphicsDrawStringEx ($Backbuffer, $Time, $hFont, $aInfo[0], $hFormat, $hBrush)
EndIf
if @DesktopWidth >= 800 Then
;~ _GDIPlus_GraphicsDrawString($Backbuffer,"Zeit (Dezimal): " & @HOUR & "." & @MIN & ":" & @SEC, $TIMEDEZIMAL, $TIMEDEZIMALH,"Arial",15,0x0400)
$tLayout = _GDIPlus_RectFCreate ($TIMEDEZIMAL, $TIMEDEZIMALH, 0, 0)
$aInfo = _GDIPlus_GraphicsMeasureString ($Backbuffer, "Zeit (Dezimal): " & @HOUR & "." & @MIN & ":" & @SEC, $hFont, $tLayout, $hFormat)
_GDIPlus_GraphicsDrawStringEx ($Backbuffer, "Zeit (Dezimal): " & @HOUR & "." & @MIN & ":" & @SEC, $hFont, $aInfo[0], $hFormat, $hBrush)
EndIf
if @DesktopWidth >= 800 Then
;~ _GDIPlus_GraphicsDrawString($Backbuffer,"Ram: " & Round($Mem[1] / 1000,0) & "MB", 0, 5,"Arial",15,0x0400)
$tLayout = _GDIPlus_RectFCreate (0, 5, 0, 0)
$aInfo = _GDIPlus_GraphicsMeasureString ($Backbuffer, "Ram: " & Round($Mem[1] / 1000,0) & "MB", $hFont, $tLayout, $hFormat)
_GDIPlus_GraphicsDrawStringEx ($Backbuffer, "Ram: " & Round($Mem[1] / 1000,0) & "MB", $hFont, $aInfo[0], $hFormat, $hBrush)
EndIf
if @DesktopWidth >= 1024 Then
;~ _GDIPlus_GraphicsDrawString($Backbuffer,"Ram (Free): " & Round($Mem[2] / 1000,0) & "MB", $RAMFREE, $RAMFREEH,"Arial",15,0x0400)
$tLayout = _GDIPlus_RectFCreate ($RAMFREE, $RAMFREEH, 0, 0)
$aInfo = _GDIPlus_GraphicsMeasureString ($Backbuffer, "Ram (Free): " & Round($Mem[2] / 1000,0) & "MB", $hFont, $tLayout, $hFormat)
_GDIPlus_GraphicsDrawStringEx ($Backbuffer, "Ram (Free): " & Round($Mem[2] / 1000,0) & "MB", $hFont, $aInfo[0], $hFormat, $hBrush)
EndIf
if @DesktopWidth >= 800 Then
;~ _GDIPlus_GraphicsDrawString($Backbuffer,"Ram (Used): " & Round(($Mem[1]-$Mem[2]) / 1000,0) & "MB", 0, 35,"Arial",15,0x0400)
$tLayout = _GDIPlus_RectFCreate (0, 35, 0, 0)
$aInfo = _GDIPlus_GraphicsMeasureString ($Backbuffer, "Ram (Used): " & Round(($Mem[1]-$Mem[2]) / 1000,0) & "MB", $hFont, $tLayout, $hFormat)
_GDIPlus_GraphicsDrawStringEx ($Backbuffer, "Ram (Used): " & Round(($Mem[1]-$Mem[2]) / 1000,0) & "MB", $hFont, $aInfo[0], $hFormat, $hBrush)
EndIf
if @DesktopWidth >= 800 Then
;~ _GDIPlus_GraphicsDrawString($Backbuffer,"Ram (Free): " & 100 - $Mem[0] & "%", $RAMFREEPRO, $RAMFREEPROH,"Arial",15,0x0400)
$tLayout = _GDIPlus_RectFCreate ($RAMFREEPRO, $RAMFREEPROH, 0, 0)
$aInfo = _GDIPlus_GraphicsMeasureString ($Backbuffer, "Ram (Free): " & 100 - $Mem[0] & "%", $hFont, $tLayout, $hFormat)
_GDIPlus_GraphicsDrawStringEx ($Backbuffer, "Ram (Free): " & 100 - $Mem[0] & "%", $hFont, $aInfo[0], $hFormat, $hBrush)
EndIf
if @DesktopWidth >= 800 Then
;~ _GDIPlus_GraphicsDrawString($Backbuffer,"Angemeldet als: " & StringLeft(@UserName,10), $ANGEMELDET, $ANGEMELDETH,"Arial",15,0x0400)
$tLayout = _GDIPlus_RectFCreate ($ANGEMELDET, $ANGEMELDETH, 0, 0)
$aInfo = _GDIPlus_GraphicsMeasureString ($Backbuffer,"Angemeldet als: " & StringLeft(@UserName,10), $hFont, $tLayout, $hFormat)
_GDIPlus_GraphicsDrawStringEx ($Backbuffer, "Angemeldet als: " & StringLeft(@UserName,10), $hFont, $aInfo[0], $hFormat, $hBrush)
EndIf
if @DesktopWidth >= 800 Then
;~ _GDIPlus_GraphicsDrawString($Backbuffer,"Aktives Fenster: " & $TITLE, $AKTIVEW, $AKTIVEWH,"Arial",15,0x0400)
$tLayout = _GDIPlus_RectFCreate ($AKTIVEW, $AKTIVEWH, 0, 0)
$aInfo = _GDIPlus_GraphicsMeasureString ($Backbuffer, "Aktives Fenster: " & $TITLE, $hFont, $tLayout, $hFormat)
_GDIPlus_GraphicsDrawStringEx ($Backbuffer, "Aktives Fenster: " & $TITLE, $hFont, $aInfo[0], $hFormat, $hBrush)
EndIf
if @DesktopWidth >= 1600 Then
;~ _GDIPlus_GraphicsDrawString($Backbuffer,"CPU: " & $CPUS, $CPU, $CPUH,"Arial",15,0x0400)
$tLayout = _GDIPlus_RectFCreate ($CPU, $CPUH, 0, 0)
$aInfo = _GDIPlus_GraphicsMeasureString ($Backbuffer,"CPU: " & $CPUS, $hFont, $tLayout, $hFormat)
_GDIPlus_GraphicsDrawStringEx ($Backbuffer, "CPU: " & $CPUS, $hFont, $aInfo[0], $hFormat, $hBrush)
EndIf
if @DesktopWidth >= 1600 Then
;~ _GDIPlus_GraphicsDrawString($Backbuffer,"GPU: " & $GPUS, $GPU, $GPUH,"Arial",15,0x0400)
$tLayout = _GDIPlus_RectFCreate ($GPU, $GPUH, 0, 0)
$aInfo = _GDIPlus_GraphicsMeasureString ($Backbuffer, "GPU: " & $GPUS, $hFont, $tLayout, $hFormat)
_GDIPlus_GraphicsDrawStringEx ($Backbuffer,"GPU: " & $GPUS, $hFont, $aInfo[0], $hFormat, $hBrush)
EndIf
if @DesktopWidth >= 1900 Then
;~ _GDIPlus_GraphicsDrawString($Backbuffer,"IP: " & @IPAddress1, $IP, $IPH,"Arial",15,0x0400)
$tLayout = _GDIPlus_RectFCreate ($IP, $IPH, 0, 0)
$aInfo = _GDIPlus_GraphicsMeasureString ($Backbuffer, "IP: " & @IPAddress1, $hFont, $tLayout, $hFormat)
_GDIPlus_GraphicsDrawStringEx ($Backbuffer, "IP: " & @IPAddress1, $hFont, $aInfo[0], $hFormat, $hBrush)
EndIf
if @DesktopWidth >= 1900 Then
;~ _GDIPlus_GraphicsDrawString($Backbuffer,"CPU-Bit: " & $CPUBS, $CPUB, $CPUBH,"Arial",15,0x0400)
$tLayout = _GDIPlus_RectFCreate ($CPUB, $CPUBH, 0, 0)
$aInfo = _GDIPlus_GraphicsMeasureString ($Backbuffer, "CPU-Bit: " & $CPUBS, $hFont, $tLayout, $hFormat)
_GDIPlus_GraphicsDrawStringEx ($Backbuffer, "CPU-Bit: " & $CPUBS, $hFont, $aInfo[0], $hFormat, $hBrush)
EndIf
if @DesktopWidth >= 1900 Then
;~ _GDIPlus_GraphicsDrawString($Backbuffer,"OS: " & @OSVersion & " (" & @OSArch & ")", $OS, $OSH,"Arial",15,0x0400)
$tLayout = _GDIPlus_RectFCreate ($OS, $OSH, 0, 0)
$aInfo = _GDIPlus_GraphicsMeasureString ($Backbuffer, "OS: " & @OSVersion & " (" & @OSArch & ")", $hFont, $tLayout, $hFormat)
_GDIPlus_GraphicsDrawStringEx ($Backbuffer, "OS: " & @OSVersion & " (" & @OSArch & ")", $hFont, $aInfo[0], $hFormat, $hBrush)
EndIf
_GDIPlus_GraphicsDrawImage($Graphics, $Bitmap, 0, 0)
$HIDETASKLEISTE = regread("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2","Settings")
if StringMid($HIDETASKLEISTE,19,2) = "03" or StringMid($HIDETASKLEISTE,18,2) = "01" or StringMid($HIDETASKLEISTE,18,2) = "0D" Then
$VISIBLETASKLEISTE = 0
Else
$VISIBLETASKLEISTE = 40
EndIf
EndFunc