BadBunny hat mich in der Shoutbox gefragt wie man Kreise auf ein transparentes Fenster malen könnte, um so wie bei Paint o.Ä. zu malen. (Ich hoffe ich hab das richtig verstanden ).
Naja, hier ist das Script. Gezeichnet wird übrigens durch Gedrückthalten der Strg Taste, während ihr mit Entfernen alles löschen könnt. Viel Spaß :D!
Edit: P.S: Mit Escape könnt ihr das Script beenden ...
Spoiler anzeigen
#include <GUIConstants.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <Misc.au3>
; - Author: name22 (http://www.autoit.de)
[/autoit] [autoit][/autoit] [autoit]Opt("GUIOnEventMode", 1)
OnAutoItExitRegister("_Close")
$vUser32DLL = DllOpen("User32.dll")
[/autoit] [autoit][/autoit] [autoit]$iGUIWidth = @DesktopWidth
$iGUIHeight = @DesktopHeight
$tSize = DllStructCreate($tagSIZE)
$pSize = DllStructGetPtr($tSize)
DllStructSetData($tSize, "X", $iGUIWidth)
DllStructSetData($tSize, "Y", $iGUIHeight)
$tSource = DllStructCreate($tagPOINT)
$pSource = DllStructGetPtr($tSource)
$tBlend = DllStructCreate($tagBLENDFUNCTION)
$pBlend = DllStructGetPtr($tBlend)
DllStructSetData($tBlend, "Alpha", 255)
DllStructSetData($tBlend, "Format", 1)
$hWnd = GUICreate("", $iGUIWidth, $iGUIHeight, 0, 0, BitOR(0x80000000, 0x08000000), BitOR(0x00080000, 0x00000008, 0x00000080))
GUISetState()
$hDC_Window = _WinAPI_GetDC($hWnd)
$hDC_Buffer = _WinAPI_CreateCompatibleDC($hDC_Window)
$hBitmap_Buffer = _WinAPI_CreateCompatibleBitmap($hDC_Window, $iGUIWidth, $iGUIHeight)
_WinAPI_SelectObject($hDC_Buffer, $hBitmap_Buffer)
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]$hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC_Buffer)
_GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2)
$hPen_Draw = _GDIPlus_PenCreate(0xFF000000, 15)
_GDIPlus_PenSetLineCap($hPen_Draw, 0x02, 0x02, 2)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Close", $hWnd)
HotKeySet("{DELETE}", "_Erase")
HotKeySet("{ESC}", "_Close")
$aMousePos = MouseGetPos()
$aMousePos_Old = MouseGetPos()
While Sleep(15)
$aMousePos = MouseGetPos()
Switch True
Case _IsPressed("11", $vUser32DLL)
Switch True
Case $aMousePos[0] <> $aMousePos_Old[0] Or $aMousePos[1] <> $aMousePos_Old[1]
_GDIPlus_GraphicsDrawLine($hGraphics, $aMousePos_Old[0], $aMousePos_Old[1], $aMousePos[0], $aMousePos[1], $hPen_Draw)
EndSwitch
EndSwitch
$aMousePos_Old = $aMousePos
[/autoit] [autoit][/autoit] [autoit]_WinAPI_UpdateLayeredWindow($hWnd, $hDC_Window, 0, $pSize, $hDC_Buffer, $pSource, 0, $pBlend, 2)
WEnd
Func _Erase()
_GDIPlus_GraphicsClear($hGraphics, 0x00000000)
EndFunc
Func _Close()
_WinAPI_ReleaseDC($hWnd, $hDC_Window)
_WinAPI_DeleteDC($hDC_Buffer)
_WinAPI_DeleteObject($hBitmap_Buffer)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_PenDispose($hPen_Draw)
_GDIPlus_Shutdown()
DllClose($vUser32DLL)
Exit
EndFunc
#region "GDIP.au3 Functions"
; #FUNCTION# ====================================================================================================================
; Name...........: _GDIPlus_PenSetLineCap
; Description ...: Sets the cap styles for the start, end, and dashes in a line drawn with the pen
; Syntax.........: _GDIPlus_PenSetLineCap($hPen, $iStartCap, $iEndCap, $iDashCap)
; Parameters ....: $hPen - Pointer to a Pen object
; $iStartCap - Line cap style for the start cap:
; |0x00 - Line ends at the last point. The end is squared off
; |0x01 - Square cap. The center of the square is the last point in the line. The height
; +and width of the square are the line width.
; |0x02 - Circular cap. The center of the circle is the last point in the line. The diameter
; +of the circle is the line width.
; |0x03 - Triangular cap. The base of the triangle is the last point in the line. The base
; +of the triangle is the line width.
; |0x10 - Line ends are not anchored.
; |0x11 - Line ends are anchored with a square. The center of the square is the last point in
; +the line. The height and width of the square are the line width.
; |0x12 - Line ends are anchored with a circle. The center of the circle is at the last point
; +in the line. The circle is wider than the line.
; |0x13 - Line ends are anchored with a diamond (a square turned at 45 degrees). The center of the diamond is at
; +the last point in the line. The diamond is wider than the line.
; |0x14 - Line ends are anchored with arrowheads. The arrowhead point is located at the last
; +point in the line. The arrowhead is wider than the line.
; |0xff - Line ends are made from a CustomLineCap object
; $iEndCap - Line cap style for the end cap (same values as $iStartCap)
; $iDashCap - Start and end caps for a dashed line:
; |0 - A square cap that squares off both ends of each dash
; |2 - A circular cap that rounds off both ends of each dash
; |3 - A triangular cap that points both ends of each dash
; Return values .: Success - True
; Failure - False and either:
; |@error and @extended are set if DllCall failed
; |$GDIP_STATUS contains a non zero value specifying the error code
; Remarks .......: None
; Related .......: _GDIPlus_PenSetDashCap, _GDIPlus_PenSetEndCap, _GDIPlus_PenSetStartCap
; Link ..........; @@MsdnLink@@ GdipSetPenLineCap197819
; Example .......; No
; ===============================================================================================================================
Func _GDIPlus_PenSetLineCap($hPen, $iStartCap, $iEndCap, $iDashCap)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetPenLineCap197819", "hwnd", $hPen, "int", $iStartCap, "int", $iEndCap, "int", $iDashCap)
If @error Then Return SetError(@error, @extended, False)
$GDIP_STATUS = $aResult[0]
Return $aResult[0] = 0
EndFunc ;==>_GDIPlus_PenSetLineCap
#endregion "GDIP.au3 Functions"