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

    ; MouseChaser, by h2112
    #include <GDIPlus.au3>
    #include-once

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

    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

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

    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

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

    Local $ChaserWidth = 50 ; Breite des Fensters
    Local $ChaserHeight = 50 ; Höhe des Fensters

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

    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

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

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

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

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

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

    $ScreenDc = _WinAPI_GetDC($hWnd)
    $dc = _WinAPI_CreateCompatibleDC($ScreenDc)

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

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

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

    AdlibRegister("_MouseChaser_Chase", 10)
    AdlibRegister("_MouseChaser_Rotate", 10)

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

    If $testmode Then
    $MouseChaser = "_testmode"
    HotKeySet("{ESC}", "_MouseChaser_ShutDown")
    EndIf
    EndFunc ;==>_MouseChaser_StartUp

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

    #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

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

    #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

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

    #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

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

    #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

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

    #cs
    _MouseChaser_SetRotationSpeed($speed)
    $speed = Rotationsgeschwindigkeit
    Setzt die Rotationsgeschwindigkeit.
    #ce
    Func _MouseChaser_SetRotationSpeed($speed = 5)
    $rotationSpeed = $speed
    Return
    EndFunc ;==>_MouseChaser_SetRotationSpeed

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

    #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

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

    #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

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

    #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

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

    #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

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

    Func _testmode()
    $handles = _MouseChaser_GetHandles()
    _GDIPlus_GraphicsFillEllipse($handles[3], -24, -24, 48, 48, $brush[0])
    EndFunc ;==>_testmode

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

    Func _MouseChaser_Chase()
    Local $MousePos = MouseGetPos()
    WinMove($hWnd, "", $MousePos[0], $MousePos[1])
    EndFunc ;==>_MouseChaser_Chase

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

    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

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

    Func _MouseChaser_Rotate()
    _GDIPlus_MatrixRotate($matrix, $rotationSpeed)
    _GDIPlus_GraphicsSetTransform($backbuffer, $matrix)
    _MouseChaser_RedrawWindow()
    EndFunc ;==>_MouseChaser_Rotate

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

    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

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

    Func _GDIPlus_BrushCreateLinear($iX1, $iY1, $iX2, $iY2, $iARGB1 = 0xFF000000, $iARGB2 = 0xFFFFFFFF)
    Local $aResult, $start, $end, $sPoint, $ePoint

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

    $start = DllStructCreate("int X;int Y")
    DllStructSetData($start, "X", $iX1)
    DllStructSetData($start, "Y", $iY1)
    $sPoint = DllStructGetPtr($start)

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

    $end = DllStructCreate("int X;int Y")
    DllStructSetData($end, "X", $iX2)
    DllStructSetData($end, "Y", $iY2)
    $ePoint = DllStructGetPtr($end)

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

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

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

    Return SetError(0, $aResult[0], $aResult[6])
    EndFunc ;==>_GDIPlus_BrushCreateLinear

    [/autoit]


    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.

    Zitat

    [Heute, 11:39] Raupi: Soll ich es dir machen?
    [Heute, 11:47] BugFix: "Soll ich es dir machen? " - also Raupi !! bitte nicht so öffentlich :rofl:

    Zitat

    [Heute, 11:51] BugFix: und ich werde es mir jetzt machen - das Mittagessen :P

    AMsg UDF v1.00.00 IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 100%
    OwnStyle UDF Version 1.10.00 IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 100%

    Einmal editiert, zuletzt von H2112 (27. März 2010 um 23:51)

  • Danke.

    Ich auch nicht, war ja auch nur so ein langeweile Skript. ;)

    Zitat

    [Heute, 11:39] Raupi: Soll ich es dir machen?
    [Heute, 11:47] BugFix: "Soll ich es dir machen? " - also Raupi !! bitte nicht so öffentlich :rofl:

    Zitat

    [Heute, 11:51] BugFix: und ich werde es mir jetzt machen - das Mittagessen :P

    AMsg UDF v1.00.00 IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 100%
    OwnStyle UDF Version 1.10.00 IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 100%