Das hier habe ich aus Langeweile geschrieben :D. Das mit der Uhrzeit ist nicht wirklich besonders, aber das "Drag & Drop" System könnte vielleicht jemandem nützlich sein :).
Das Script ist natürlich sehr anpassungsfähig.
Spoiler anzeigen
#include <GDIPlus.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]$iGUIWidth = 600 ;Breite der Grafik
$iGUIHeight = 600 ;Höhe der Grafik
$iX = Random(1, $iGUIWidth -100, 1) ;Startposition X
$iY = Random(1, $iGUIHeight -50, 1) ;Startposition Y
$vX = 0 ;Startbewegung X
$vY = 0 ;Startbewegung Y
$Resistance = 0.95 ;Stärke des "Luftwiederstands" (Wert zwischen 0 und 1, je geringer der Wert desto größer der Wiederstand).
$hWnd = GUICreate("Test", @DesktopWidth + 2, @DesktopHeight + 2, -1, -1, $WS_POPUP)
GUISetBkColor(0x000000) ;Hintergrundfarbe der GUI
GUISetState(@SW_MAXIMIZE)
GUISetState(@SW_SHOW)
$iX_Graphic = @DesktopWidth / 2 - $iGUIWidth / 2 ;Platziert die Grafik in der Mitte der GUI
$iY_Graphic = @DesktopHeight / 2 - $iGUIHeight / 2
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($iGUIWidth, $iGUIHeight, $hGraphic)
$hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)
$hFormatTime = _GDIPlus_StringFormatCreate()
$hFamilyTime = _GDIPlus_FontFamilyCreate("Arial") ;Hier kann der Name jeder beliebigen installierten Schriftart eingetragen werden
$hFontTime = _GDIPlus_FontCreate($hFamilyTime, 20) ;Hier kann die Schriftgröße angepasst werden
$sTime = @HOUR & ":" & @MIN & ":" & @SEC ;Man könnte natürlich auch einen Text o.Ä.verwenden
$aInfo = _GDIPlus_GraphicsMeasureString($hBuffer, $sTime, $hFontTime, _GDIPlus_RectFCreate(), $hFormatTime) ;Misst die Größe des Strings
$iWidth = DllStructGetData($aInfo[0], "width")
$iHeight = DllStructGetData($aInfo[0], "height")
$hBrushTime = _GDIPlus_BrushCreateSolid(0xFFFF0000) ;Hier kann die Schriftfarbe der Uhrzeit angepasst werden
[/autoit] [autoit][/autoit] [autoit]GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_ClickEvent")
While Sleep(10)
_ReDraw()
WEnd
Func _ReDraw()
If $sTime <> @HOUR & ":" & @MIN & ":" & @SEC Then
$sTime = @HOUR & ":" & @MIN & ":" & @SEC
$aInfo = _GDIPlus_GraphicsMeasureString($hBuffer, $sTime, $hFontTime, _GDIPlus_RectFCreate(), $hFormatTime)
$iWidth = DllStructGetData($aInfo[0], "width")
$iHeight = DllStructGetData($aInfo[0], "height")
EndIf
If ($vX > 0 And $iX >= $iGUIWidth - $iWidth) Or ($vX < 0 And $iX <= 0) Then $vX *= -0.9
If ($vY > 0 And $iY >= $iGUIHeight - $iHeight) Or ($vY < 0 And $iY <= 0) Then $vY *= -0.9
$iX += $vX
$iY += $vY
$vX *= $Resistance
$vY *= $Resistance
_GDIPlus_GraphicsClear($hBuffer, 0xFF080808) ;Hintergrundfarbe der Grafik
;~ _GDIPlus_GraphicsFillRect($hBuffer, $iX, $iY, $iWidth, $iHeight)
$tLayoutTime = _GDIPlus_RectFCreate(Floor($iX), Floor($iY), $iWidth, $iHeight)
_GDIPlus_GraphicsDrawStringEx($hBuffer, $sTime, $hFontTime, $tLayoutTime, $hFormatTime, $hBrushTime)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, $iX_Graphic, $iY_Graphic, $iGUIWidth, $iGUIHeight)
EndFunc ;==>_ReDraw
Func _ClickEvent()
$aMousePos = GUIGetCursorInfo($hWnd)
If _PtIsInRect($aMousePos[0] - $iX_Graphic, $aMousePos[1] - $iY_Graphic, $iX, $iY, $iWidth, $iHeight) Then
$iDistX = $aMousePos[0] - $iX_Graphic - $iX
$iDistY = $aMousePos[1] - $iY_Graphic - $iY
While _IsPressed("01") ;Das hier ist für den "Drag & Drop" Effekt zuständig
Sleep(10)
$aMousePos = GUIGetCursorInfo($hWnd)
$iDiffX = $aMousePos[0] - $iX_Graphic - $iX - $iDistX
$iDiffY = $aMousePos[1] - $iY_Graphic - $iY - $iDistY
$vX = $iDiffX / 8
$vY = $iDiffY / 8
_ReDraw()
WEnd
EndIf
EndFunc ;==>_ClickEvent
Func _PtIsInRect($iXPoint, $iYPoint, $iXRect, $iYRect, $iWidthRect, $iHeightRect) ;Überprüft ob ein Punkt innerhalb eine Rechtecks ist
If $iXPoint >= $iXRect And $iYPoint >= $iYRect And $iXPoint <= $iXRect + $iWidthRect And $iYPoint <= $iYRect + $iHeightRect Then Return 1
Return 0
EndFunc ;==>_PtIsInRect
Func _Exit() ;Aufräumen...
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_GraphicsDispose($hBuffer)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_FontDispose($hFontTime)
_GDIPlus_FontFamilyDispose($hFamilyTime)
_GDIPlus_StringFormatDispose($hFormatTime)
_GDIPlus_BrushDispose($hBrushTime)
_GDIPlus_Shutdown()
Exit
EndFunc ;==>_Exit