Hey Leute,
mir war in letzter Zeit langweilig da hab ich mal ein Programm geschrieben das automatisch einen zufälligen GUI-Hintergrund erstellt.
hoffe es gefällt euch:
Spoiler anzeigen
#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
_GDIPlus_Startup()
$GuiHeight = 600
$GuiWidth = 800
Dim $verhackung[2]
$verhackung[0] = False
$verhackung[1] = False
$hwnd = GUICreate("random background", $GuiWidth, $GuiHeight)
GUISetState(@SW_SHOW)
$hBuffer = _GDIPlus_GraphicsCreateFromHWND($hwnd)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($GuiWidth, $GuiHeight, $hBuffer)
$hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap)
SRandom(@HOUR * 10 + @MIN * 1000 + @SEC * 100000)
$Kastels = Random(3, 10, 1); Anzahl Kästchen
Dim $Pos[$Kastels][7]
For $i = 0 To $Kastels - 1 Step +1
$Pos[$i][0] = Random(0, $GuiWidth / $Kastels + Random(0, 0, 1), 1); edit second random for smaller kastels
$Pos[$i][1] = Random(0, $GuiHeight / ($Kastels - 2) + Random(0, 0, 1), 1); edit second random for smaller kastels
$Pos[$i][2] = Random(10, 600, 1)
$Pos[$i][3] = Random(10, 400, 1)
Do
If $Pos[$i][0] + $Pos[$i][2] > $GuiWidth Then
$Pos[$i][0] -= 10
$verhackung[0] = True
EndIf
If $Pos[$i][1] + $Pos[$i][3] > $GuiHeight Then
$Pos[$i][1] -= 10
$verhackung[1] = True
EndIf
If $Pos[$i][0]< $GuiWidth Then
$Pos[$i][0] += 10
$verhackung[0] = True
EndIf
If $Pos[$i][1]< $GuiHeight Then
$Pos[$i][1] += 10
$verhackung[1] = True
EndIf
Until $verhackung[0] and $verhackung[1]
Next
For $i = 0 To $Kastels - 1 Step +1
$String = String("0x" & Hex(Random(30000000, 99999999, 1), 2) & Hex(Random(10000000, 99999999, 1), 6)); zufällige Farben und Alpha Werte
$Pos[$i][4] = _GDIPlus_BrushCreateSolid($String)
If @error Then
ConsoleWriteError("Fatal Brush Error!")
EndIf
$Pos[$i][5] = Random(1, 3, 1)
$Pos[$i][6] = Random(-5, 5, 1)
Next
$back = String("0x" & Hex(Random(30000000, 99999999, 1), 2) & Hex(Random(10000000, 99999999, 1), 6))
Do
_GDIPlus_GraphicsClear($hGraphics,$back )
For $i = 0 To $Kastels - 1 Step +1
_GDIPlus_GraphicsFillRect($hGraphics, $Pos[$i][0], $Pos[$i][1], $Pos[$i][2], $Pos[$i][3], $Pos[$i][4])
ConsoleWrite(@CRLF & "-----------------------------------------------" & @CRLF & $Pos[$i][0] & @CRLF & $Pos[$i][1] & @CRLF & $Pos[$i][2] & @CRLF & $Pos[$i][3])
Next
For $i = 0 To $Kastels - 1 Step +1
If $Pos[$i][0] + $Pos[$i][2] > $GuiWidth Or $Pos[$i][0] < 0 Then
$Pos[$i][5] -= $Pos[$i][5] * 2
EndIf
If $Pos[$i][1] + $Pos[$i][3] > $GuiHeight Or $Pos[$i][1] < 0 Then
$Pos[$i][6] -= $Pos[$i][6] * 2
EndIf
$Pos[$i][0] += $Pos[$i][5]
If Random(0, 4, 1) = 1 Then
$Pos[$i][1] += $Pos[$i][6]
EndIf
Next
_GDIPlus_GraphicsDrawImageRect($hBuffer, $hBitmap, 0, 0, $GuiWidth, $GuiHeight)
Until GUIGetMsg() = $GUI_EVENT_CLOSE
For $i = 0 to $Kastels-1 step +1
_GDIPlus_BrushDispose($Pos[$i][4])
Next
_GDIPlus_Shutdown()