Ich hatte mal wieder Langeweile (Ja kommt ziehmlich häufig vor ;)).
Dann hatte ich halt eine Idee, und aus der Idee wurde eine UDF.
Ohne viele Worte:
Spoiler anzeigen
; MouseChaser, by h2112
#include <GDIPlus.au3>
#include-once
Local $ScreenDc, $dc, $tSize, $pSize, $tSource, $pSource, $tBlend, $pBlend, $tPoint, $pPoint ; Alles, was für die transparente GUI gebracht wird
Local $brush[2], $pen, $hEndCap
Local $hWnd, $hGraphic, $hBitmap, $backbuffer, $matrix
Local $MouseChaser = 0 ; Nummer oder Name der Funktion, die einen Mausverfolger zeichnet
Local $rotationSpeed = 5 ; Geschwindigkeit, der zu drehenden Matrix
Local $ChaserColour = 0xFF000000 ; Farbe des Mausverfolgers
Local $ChaserWidth = 50 ; Breite des Fensters
Local $ChaserHeight = 50 ; Höhe des Fensters
Local $testmode = False ; Wenn der Testmodes auf True ist, zeigt das Script alle vordefinierten Mausverfolger.
[/autoit] [autoit][/autoit] [autoit]If $testmode Then
_MouseChaser_StartUp()
_MouseChaser_SetRotationSpeed(4)
_MouseChaser_SetPos(75, 75)
While 1
_MouseChaser_SetChaserColour("0xFF" & String(Hex(Random(1, 255), 2)) & String(Hex(Random(1, 255), 2)) & String(Hex(Random(1, 255), 2)))
_MouseChaser_SetOwnChaser("_testmode")
For $i = 2 To 4
Sleep(5000)
_MouseChaser_SetChaser($i)
_MouseChaser_SetChaserColour("0xFF" & String(Hex(Random(1, 255), 2)) & String(Hex(Random(1, 255), 2)) & String(Hex(Random(1, 255), 2)))
Next
Sleep(5000)
WEnd
EndIf
#cs
_MouseChaser_StartUp()
Initialisiert die UDF.
#ce
Func _MouseChaser_StartUp()
Local $MousePos = MouseGetPos()
_GDIPlus_Startup()
$hWnd = GUICreate("Mausverfolger", $ChaserWidth, $ChaserHeight, $MousePos[0], $MousePos[1], 0x80000000, BitOR(0x00000080, 0x00080000, 0x00000008))
GUISetState()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($ChaserWidth, $ChaserHeight, $hGraphic)
$backbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($backbuffer, 4)
$matrix = _GDIPlus_MatrixCreate()
_GDIPlus_MatrixTranslate($matrix, $ChaserWidth / 2, $ChaserHeight / 2)
_GDIPlus_GraphicsSetTransform($backbuffer, $matrix)
$brush[0] = _GDIPlus_BrushCreateLinear(-$ChaserWidth / 2, -$ChaserHeight / 2, $ChaserWidth / 2, $ChaserHeight / 2, $ChaserColour, 0x00000000)
$brush[1] = _GDIPlus_BrushCreateSolid(0xFF000000)
$pen = _GDIPlus_PenCreate($ChaserColour, 10)
$hEndCap = _GDIPlus_ArrowCapCreate(1.5, 1.5)
_GDIPlus_PenSetCustomEndCap($pen, $hEndCap)
$ScreenDc = _WinAPI_GetDC($hWnd)
$dc = _WinAPI_CreateCompatibleDC($ScreenDc)
$tSize = DllStructCreate($tagSIZE)
$pSize = DllStructGetPtr($tSize)
DllStructSetData($tSize, "X", $ChaserWidth)
DllStructSetData($tSize, "Y", $ChaserHeight)
$tSource = DllStructCreate($tagPOINT)
$pSource = DllStructGetPtr($tSource)
$tBlend = DllStructCreate($tagBLENDFUNCTION)
$pBlend = DllStructGetPtr($tBlend)
DllStructSetData($tBlend, "Alpha", 255)
DllStructSetData($tBlend, "Format", 1)
$tPoint = DllStructCreate($tagPOINT)
$pPoint = DllStructGetPtr($tPoint)
DllStructSetData($tPoint, "X", 0)
DllStructSetData($tPoint, "Y", 0)
AdlibRegister("_MouseChaser_Chase", 10)
AdlibRegister("_MouseChaser_Rotate", 10)
If $testmode Then
$MouseChaser = "_testmode"
HotKeySet("{ESC}", "_MouseChaser_ShutDown")
EndIf
EndFunc ;==>_MouseChaser_StartUp
#cs
_MouseChaser_ShutDown()
Beendet die UDF.
#ce
Func _MouseChaser_ShutDown()
GUIDelete($hWnd)
AdlibUnRegister("_MouseChaser_Chase")
AdlibUnRegister("_MouseChaser_Rotate")
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($backbuffer)
_GDIPlus_MatrixDispose($matrix)
_GDIPlus_BrushDispose($brush)
_GDIPlus_PenDispose($pen)
_WinAPI_ReleaseDC($hWnd, $dc)
_WinAPI_ReleaseDC($hWnd, $ScreenDc)
_GDIPlus_Shutdown()
If $testmode Then Exit
EndFunc ;==>_MouseChaser_ShutDown
#cs
_MouseChaser_SetPos($ChaserWidth, $ChaserHeight)
$ChaserWidth = Breite des Fensters
$ChaserHeight = Höhe des Fensters
Ändert die Breite und Höhe des Fensters.
Achtung: Alle Handles werden geändert!
#ce
Func _MouseChaser_SetPos($Width, $Height)
Local $oldtestmode = $testmode
If $testmode Then $testmode = False
$ChaserWidth = $Width
$ChaserHeight = $Height
_MouseChaser_ShutDown()
If $oldtestmode Then $testmode = True
_MouseChaser_StartUp()
EndFunc ;==>_MouseChaser_SetPos
#cs
_MouseChaser_SetChaser($chaser)
$chaser = Nummer, die einen vordefinierten Mausverfolger aufruft
Setzt einen vordefinierten Mausverfolger.
#ce
Func _MouseChaser_SetChaser($Chaser)
If IsNumber($Chaser) Then
$MouseChaser = $Chaser
Return True
Else
Return False
EndIf
EndFunc ;==>_MouseChaser_SetChaser
#cs
_MouseChaser_SetOwnChaser($Chaser)
$Chaser = String, der den Namen der aufzurufenden Funktion enthält
Setzt eine eigene Funktion für den Mausverfolger.
#ce
Func _MouseChaser_SetOwnChaser($Chaser)
If IsString($Chaser) Then
$MouseChaser = $Chaser
Return True
Else
Return False
EndIf
EndFunc ;==>_MouseChaser_SetOwnChaser
#cs
_MouseChaser_SetRotationSpeed($speed)
$speed = Rotationsgeschwindigkeit
Setzt die Rotationsgeschwindigkeit.
#ce
Func _MouseChaser_SetRotationSpeed($speed = 5)
$rotationSpeed = $speed
Return
EndFunc ;==>_MouseChaser_SetRotationSpeed
#cs
_MouseChaser_SetChaserColour($Colour)
$Colour = HEX-Code der Farbe mit Alphachannel
Setzt die Farbe des Mausverfolgers.
#ce
Func _MouseChaser_SetChaserColour($Colour)
$ChaserColour = $Colour
_GDIPlus_BrushDispose($brush)
$brush[0] = _GDIPlus_BrushCreateLinear(-$ChaserWidth / 2, -$ChaserHeight / 2, $ChaserWidth / 2, $ChaserHeight / 2, $ChaserColour, 0x00000000)
_GDIPlus_BrushSetSolidColor($brush[1], $ChaserColour)
_GDIPlus_PenSetColor($pen, $ChaserColour)
EndFunc ;==>_MouseChaser_SetChaserColour
#cs
_MouseChaser_GetPos()
Gibt die Breite und Höhe in einem Array zurück.
$pos[0] = $ChaserWidth
$pos[1] = $ChaserHeight
#ce
Func _MouseChaser_GetPos()
Local $pos[2]
$pos[0] = $ChaserWidth
$pos[1] = $ChaserHeight
Return $pos
EndFunc ;==>_MouseChaser_GetPos
#cs
_MouseChaser_GetChaser()
Gibt den aktuellen Mausverfolger zurück.
Dieser kann eine Nummer, oder ein String sein.
#ce
Func _MouseChaser_GetChaser()
Return $MouseChaser
EndFunc ;==>_MouseChaser_GetChaser
#cs
_MouseChaser_GetHandles()
Gibt alle verwendeten Handles in einem Array zurück.
$ret[0] = $hWnd
$ret[1] = $hGraphic
$ret[2] = $hBitmap
$ret[3] = $backbuffer
$ret[4] = $matrix
#ce
Func _MouseChaser_GetHandles()
Local $ret[5]
$ret[0] = $hWnd
$ret[1] = $hGraphic
$ret[2] = $hBitmap
$ret[3] = $backbuffer
$ret[4] = $matrix
Return $ret
EndFunc ;==>_MouseChaser_GetHandles
Func _testmode()
$handles = _MouseChaser_GetHandles()
_GDIPlus_GraphicsFillEllipse($handles[3], -24, -24, 48, 48, $brush[0])
EndFunc ;==>_testmode
Func _MouseChaser_Chase()
Local $MousePos = MouseGetPos()
WinMove($hWnd, "", $MousePos[0], $MousePos[1])
EndFunc ;==>_MouseChaser_Chase
Func _MouseChaser_RedrawWindow()
_GDIPlus_GraphicsClear($backbuffer, 0x00000000)
_MouseChaser_DrawChaser()
Local $gdibitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
_WinAPI_SelectObject($dc, $gdibitmap)
_WinAPI_UpdateLayeredWindow($hWnd, $ScreenDc, 0, $pSize, $dc, $pSource, 0, $pBlend, 2)
_WinAPI_DeleteObject($gdibitmap)
EndFunc ;==>_MouseChaser_RedrawWindow
Func _MouseChaser_Rotate()
_GDIPlus_MatrixRotate($matrix, $rotationSpeed)
_GDIPlus_GraphicsSetTransform($backbuffer, $matrix)
_MouseChaser_RedrawWindow()
EndFunc ;==>_MouseChaser_Rotate
Func _MouseChaser_DrawChaser()
Select
Case $MouseChaser = 1
_GDIPlus_GraphicsClear($backbuffer, 0x00000000)
Case $MouseChaser = 2
_GDIPlus_GraphicsDrawArc($backbuffer, -20, -20, 39, 39, 0, 170, $pen)
Case $MouseChaser = 3
_GDIPlus_GraphicsFillEllipse($backbuffer, -19, -19, 10, 10, $brush[1])
Case $MouseChaser = 4
_GDIPlus_GraphicsFillPie($backbuffer, -25, -25, 50, 50, 0, 30, $brush[1])
Case Else
If IsString($MouseChaser) Then Call($MouseChaser)
EndSelect
EndFunc ;==>_MouseChaser_DrawChaser
Func _GDIPlus_BrushCreateLinear($iX1, $iY1, $iX2, $iY2, $iARGB1 = 0xFF000000, $iARGB2 = 0xFFFFFFFF)
Local $aResult, $start, $end, $sPoint, $ePoint
$start = DllStructCreate("int X;int Y")
DllStructSetData($start, "X", $iX1)
DllStructSetData($start, "Y", $iY1)
$sPoint = DllStructGetPtr($start)
$end = DllStructCreate("int X;int Y")
DllStructSetData($end, "X", $iX2)
DllStructSetData($end, "Y", $iY2)
$ePoint = DllStructGetPtr($end)
$aResult = DllCall($ghGDIPDll, "int", "GdipCreateLineBrushI", "ptr", $sPoint, "ptr", $ePoint, "int", $iARGB1, "int", $iARGB2, "int", 0, "int*", 0)
If @error Then Return SetError(@error, @extended, 0)
Return SetError(0, $aResult[0], $aResult[6])
EndFunc ;==>_GDIPlus_BrushCreateLinear
Ein Beispiel ist in der UDF drinnen, einfach mal in Zeile 16 $testmode auf True setzen.
Ich bin für Kritik und Verbesserungsvorschläge offen.