Infofeld über Taskleiste

  • 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
    [autoit]

    #cs ----------------------------------------------------------------------------

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

    AutoIt Version: 3.3.6.1
    Author: t4ggno

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

    Script Function:
    Creates a infoGui

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

    #ce ----------------------------------------------------------------------------

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

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <GDIPlus.au3>
    #include <WinAPI.au3>

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

    $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

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

    Global $Binaer[8] = [128,64,32,16,8,4,2,1]
    Global $STATE = "SHOW"

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

    if @OSArch = "X64" then
    $REG = "HKLM64"
    ElseIf @OSArch = "X86" then
    $REG = "HKLM"
    Else
    Exit
    EndIf

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

    $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

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

    $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)

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

    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

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

    _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)

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

    $hBrush = _GDIPlus_BrushCreateSolid (0xFFFFFFFF)
    $hFormat = _GDIPlus_StringFormatCreate ()
    $hFamily = _GDIPlus_FontFamilyCreate ("Arial")
    $hFont = _GDIPlus_FontCreate ($hFamily, 15, 2)

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

    $BK = _GDIPlus_BitmapCreateFromFile("Bild.bmp")
    $BILD_BREITE = _GDIPlus_ImageGetWidth($BK)
    $BILD_HOEHE = _GDIPlus_ImageGetHeight($BK)

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

    WinSetOnTop("Binary-Clock","",1)
    GUISetState(@SW_SHOW)

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

    AdlibRegister("AKTUA",1000)
    AdlibRegister("WINC",200)
    AdlibRegister("WINMOV",10)
    AKTUA()

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

    While 1

    if GUIGetMsg() = $GUI_EVENT_CLOSE then Exit
    Sleep(2000)

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

    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

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

    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

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

    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)

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

    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

    [/autoit]

    3 Mal editiert, zuletzt von 4Soldier93 (5. August 2011 um 19:46)

  • Habe ne neue Version herausgebracht.

    Der Code ist nun leserlich, habe die automatische Fensterverkleinerung angepasst und eien einstellmöglichkeit über TrayIcon hinzugefügt.

    Außerdem habe ich meinen Code umgestellt auf "GuiOnEventMode" (da viele dies bevorzugen und besser finden).

    Nun habe ich allerdings das Problem, dass bei meinem "About"-Fenster der button "Fertig" und der Button zu meiner Homepage nicht tut. Könnte mir jemand vllt erklären warum dies nicht funktioniert??

    Danke und Gruß
    t4ggno

    [EDIT:} Das ist leider noch die etwas ältere Version. Habe die neuste derzeit nicht dabei.
    Werde die neuste version so bald wie möglich hochladen

    Einmal editiert, zuletzt von 4Soldier93 (5. August 2011 um 19:38)

  • Ist gut geworden. Vllt solltest du das Drawen auch beim moven anlagen, denn wenn das Fenster wieder hochkommt ist es kurz Weiß.

    mfg BB

    "IF YOU'RE GOING TO KILL IT
    OPEN SOURCE IT!"

    by Phillip Torrone

    Zitat von Shoutbox

    [Heute, 11:16] Andy: ....böseböseböseböse....da erinnere ich mich daran, dass man den Puschelschwanz eines KaRnickels auch "Blume" nennt....ob da eins zum anderen passt? :rofl: :rofl: :rofl: :rofl:

    https://autoit.de/index.php?page…leIt#post251138

    Neon Snake

  • Hallo,

    danke erstmal für dein Feedback!

    Das mit dem weiß ist mir auch aufgefallen. Allerdings weiß ich nicht wie ich das ändern kann?!
    Gibt es irgend ein Style um dies festzulegen?

    Gruß
    t4ggno

  • So bin wieder zurück vom Urlaub und übermorgen kann ich endlich die richtige Version hochladen :)

    Kann mir den mittleweise jemand bei dem problem helfen?