#include <WinAPI.au3>
#include <GDIPlus.au3>
#include <Misc.au3>

_GDIPlus_Startup()

HotKeySet("{ESC}", "_Exit")

Global $hGui, $hGrafik, $hBrusch_Red, $hBrusch_Green
Global $aRects[4][3] = [[50, 50, False],[250, 50, False],[50, 250, False],[250, 250, False]]
Global $aHandle[4]

$hGui = GUICreate("GDI+ Script von Blume", 400, 400)
GUISetBkColor(0xFFFFFF)
GUISetState()

$hBrusch_Red = _GDIPlus_BrushCreateSolid(0xFFFF0000)
$hBrusch_Green = _GDIPlus_BrushCreateSolid(0xFF00FF00)
$hGrafik = _GDIPlus_GraphicsCreateFromHWND($hGui)

For $iX = 0 To UBound($aRects) - 1
	$aHandle[$iX] = GUICtrlCreateLabel("", $aRects[$iX][0], $aRects[$iX][1], 100, 100)
	_GDIPlus_GraphicsFillRect($hGrafik, $aRects[$iX][0], $aRects[$iX][1], 100, 100, $hBrusch_Red)
Next

While True
	$aInfo = GUIGetCursorInfo($hGui)
	While _IsPressed("01")
		Sleep(10)
	WEnd
	For $iX = 0 To UBound($aRects) - 1
		If $aInfo[4] = $aHandle[$iX] And $aInfo[2] Then
			If $aRects[$iX][2] Then
				_GDIPlus_GraphicsFillRect($hGrafik, $aRects[$iX][0], $aRects[$iX][1], 100, 100, $hBrusch_Red)
			Else
				_GDIPlus_GraphicsFillRect($hGrafik, $aRects[$iX][0], $aRects[$iX][1], 100, 100, $hBrusch_Green)
			EndIf
			$aRects[$iX][2] = Not $aRects[$iX][2]
		EndIf
	Next
	Sleep(10)
WEnd


Func _Exit()
	_GDIPlus_BrushDispose($hBrusch_Red)
	_GDIPlus_BrushDispose($hBrusch_Green)
	_GDIPlus_GraphicsDispose($hGrafik)
	_GDIPlus_Shutdown()
	Exit
EndFunc   ;==>_Exit