Linie auf Bildschirm zeichnen

  • Hallo,

    ich möchte mit autoit eine Linie zeichnen, welche immer im vordergrund ist. (nicht für Spiele oder Videoanwendungen)

    Ich hab schon ein wenig rumgeschaut, aber leider bin ich immer wieder auf gdi+ gestoßen. Damit kann ich aber nur Linien in einem Gui zeichnen.

    Ich möchte aber, dass nur die Linien zu sehen sind.

    Gibt es da eine UDF oder eine andere Möglichkeit?

    mfg reeky

    Einmal editiert, zuletzt von reeky (4. Juni 2012 um 22:56)

  • So z.B.

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <GDIPlus.au3>
    #include <timers.au3>
    #include <misc.au3>
    #Include <WinAPI.au3>

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

    HotKeySet("{ESC}","_ende")

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

    Global Const $GWL_EXSTYLE = -20

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

    $dll = DllOpen("user32.dll")

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

    Global $ballpos1=@DesktopWidth/2
    Global $ballpos2=@DesktopHeight/2
    Global $BewegungSenkrecht=Random(5, 7, 1)
    Global $BewegungWagrecht=Random(5, 7, 1)
    Global $Speed=10

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

    _GDIPlus_Startup()

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

    Global $hGui = GUICreate("Rahmen", @DesktopWidth, @DesktopHeight, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
    WinSetOnTop("Rahmen","",1)
    GUISetBkColor(0xABCDEF)
    _WinAPI_SetLayeredWindowAttributes($hGui, 0xABCDEF, 255)
    GUISetState()
    Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui)
    $Pinsel = _GDIPlus_PenCreate(0xFF0000FF, 20)
    Global $vanish = _GDIPlus_PenCreate(0xFF000000, 20)
    ;Global $vanish = _GDIPlus_PenCreate(0xFFABCDEF, 20) // Alles mit der Farbe ABCDEF verschwindet
    ;_GDIPlus_GraphicsClear ( $hGraphic, 0xFFABCDEF ) // Wenn du hier mit drübermalst ist alles weg
    $t1 = _Timer_SetTimer(0, 20, "move")
    $begin=TimerInit()

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

    _Win_SetClickThrough($hGui)

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

    While 1
    $nmsg=GUIGetMsg()
    Switch $nmsg
    Case $gui_event_close
    Exit
    EndSwitch
    WEnd

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

    Func _ende()
    _GDIPlus_GraphicsClear ( $hGraphic, 0xFFABCDEF )
    _GDIPlus_PenDispose($Pinsel)
    _GDIPlus_PenDispose($vanish)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_ende

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

    Func move($a, $b, $c, $d)
    _GDIPlus_GraphicsDrawArc ( $hGraphic, $ballpos1, $ballpos2, 70, 70, 180, 360, $vanish )
    $ballpos1+=$BewegungWagrecht * $Speed
    $ballpos2+=$BewegungSenkrecht * $Speed
    _GDIPlus_GraphicsDrawArc ( $hGraphic, $ballpos1, $ballpos2, 70, 70, 180, 360, $Pinsel )
    If $ballpos1 >= @DesktopWidth - 80 And $BewegungWagrecht > 0 Then $BewegungWagrecht = Random(-7, -5, 1)
    If $ballpos1 < 10 And $BewegungWagrecht < 0 Then $BewegungWagrecht = Random(5, 7, 1)
    If $ballpos2 >= @DesktopHeight - 95 And $BewegungSenkrecht > 0 Then $BewegungSenkrecht = Random(-7, -5, 1)
    If $ballpos2 < 30 And $BewegungSenkrecht < 0 Then $BewegungSenkrecht = Random(5, 7, 1)
    If _GDIPlus_PenGetColor ( $vanish )=0xFF000000 Then
    _GDIPlus_PenSetColor ( $vanish, 0xFFFFFF00 )
    ElseIf _GDIPlus_PenGetColor ( $vanish )=0xFFFFFF00 Then
    _GDIPlus_PenSetColor ( $vanish, 0xFFFF0000 )
    ElseIf _GDIPlus_PenGetColor ( $vanish )=0xFFFF0000 Then
    _GDIPlus_PenSetColor ( $vanish, 0xFF00FF00 )
    ElseIf _GDIPlus_PenGetColor ( $vanish )=0xFF00FF00 Then
    _GDIPlus_PenSetColor ( $vanish, 0xFF000000 )
    EndIf
    $dif=TimerDiff( $begin )
    If $dif>12000 Then
    _GDIPlus_GraphicsClear ( $hGraphic, 0xFFABCDEF )
    $begin=TimerInit()
    EndIf
    EndFunc ;==>move

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

    Func _Win_SetClickThrough($title,$text = "",$noclic = True)
    ; UDF von ProgAndy
    Local $hWnd = WinGetHandle($title,$text)
    If @error Then Return SetError(1,0,0)
    If $noclic Then
    _WinAPI_SetWindowLong($hWnd,$GWL_EXSTYLE,BitOR(_WinAPI_GetWindowLong($hWnd,$GWL_EXSTYLE),$WS_EX_TRANSPARENT))
    If @error Then Return SetError(2,0,0)
    ;WinSetTrans($hWnd,"",255) ; Sets the Layered Attribute, but still shows the window :) Hier müsste man checken ob es das attribute schon hat, habs mal auskommentiert
    If @error Then Return SetError(2,0,0)
    Else
    _WinAPI_SetWindowLong($hWnd,$GWL_EXSTYLE,BitAND(_WinAPI_GetWindowLong($hWnd,$GWL_EXSTYLE),BitNOT($WS_EX_TRANSPARENT)))
    If @error Then Return SetError(2,0,0)
    EndIf
    Return 1
    EndFunc

    [/autoit]

    Damit malst du auf ein GUI zwar, aber es ist unsichtbar und es lässt Klicks durch.