GDI+ Beispiele

  • Hallo,

    hier ein paar GDI+ Beispiele, die ich programmiert habe, um ein bißchen mehr über GDI+ zu lernen.
    Es ist nichts bombastisches, aber vielleicht gefällt's euch ja ;)

    Codes wurden mit AutoIt v3.3.0.0 erstellt:

    #01 - Fliegende Perlenkette:

    Spoiler anzeigen
    [autoit]


    ;coded by UEZ 2009-01-09 - thanks to smashly for _GDIPlus_BrushSetSolidColor() function :)
    #AutoIt3Wrapper_Run_Obfuscator=y
    #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0
    #AutoIt3Wrapper_UseUpx=n
    #AutoIt3Wrapper_Run_After=upx.exe --best "%out%"
    #AutoIt3Wrapper_Run_After=del "Flying Pearl Necklaces_Obfuscated.au3"

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

    #include <GuiConstantsEx.au3>
    #include <GDIPlus.au3>
    Opt('MustDeclareVars', 1)
    Global Const $Pi = 4 * ATan(1)
    Global Const $width = 400
    Global Const $height = $width
    Global $hGUI, $Graphic, $ParticleBitmap, $ParticleBuffer, $Brush1, $Brush2
    Global $starting_point, $i, $j, $k, $l, $xcoord1, $ycoord1, $xcoord2, $ycoord2, $size, $red, $green, $blue, $min_size

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

    $hGUI = GUICreate("GDI+: Flying Pearl Necklaces by UEZ 2009", $width, $height)
    GUISetState(@SW_SHOW)

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

    _GDIPlus_Startup ()
    $Graphic = _GDIPlus_GraphicsCreateFromHWND ($hGUI) ;create graphic
    $ParticleBitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $Graphic) ;create bitmap
    $ParticleBuffer = _GDIPlus_ImageGetGraphicsContext($ParticleBitmap) ;create buffer
    _GDIPlus_GraphicsSetSmoothingMode($ParticleBuffer, 4) ;Antialiasing
    _GDIPlus_GraphicsClear($ParticleBuffer) ;clear buffer
    $Brush1 = _GDIPlus_BrushCreateSolid(0)
    $Brush2 = _GDIPlus_BrushCreateSolid(0)

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

    $i = -650
    $l = $i
    $starting_point = 0
    $min_size = 10
    Do
    _GDIPlus_GraphicsClear($ParticleBuffer, 0xFFFFFFFF) ;clear buffer
    $k = 2^12
    $starting_point -= 0.05
    For $j = 0 To $k Step 32
    $red = ((Sin(2^1 * ($i + $j) / 2^10) + 1) / 2) * 256
    $green = ((Sin(2^2 * ($i + $j) / 2^9) + 1) / 2) * 256
    $blue = ((Sin(2^3 * ($i + $j) / 2^8) + 1) / 2) * 256
    _GDIPlus_BrushSetSolidColor($Brush1, "0xCF" & Hex($red, 2) & Hex($green, 2) & Hex($blue, 2))
    _GDIPlus_BrushSetSolidColor($Brush2, "0xCF" & Hex($blue, 2) & Hex($red, 2) & Hex($green, 2))
    $size = $i - $j
    $xcoord1 = $width / 2 - (($i - $j) / 2) + Sin($starting_point) * -Sin(($i - $j) * $Pi / 90) * 64
    $ycoord1 = $height / 2 - (($i - $j) / 2) + -Cos($starting_point) * Cos(($i - $j) * $Pi / 90) * 32
    _GDIPlus_GraphicsFillEllipse($ParticleBuffer, $xcoord1, $ycoord1, $size / 6, $size / 6, $Brush1)
    $xcoord2 = $width / 2 - (-($i - $j) / -1.75) - Sin($starting_point) * Sin(($i - $j) * $Pi / 120) * 32
    $ycoord2 = $height / 2 - (($i - $j) / -1.75) - Cos($starting_point) * Cos(($i - $j) * $Pi / 75) * 16
    _GDIPlus_GraphicsFillEllipse($ParticleBuffer, $xcoord2, $ycoord2, $size / 8 , $size / 8, $Brush2)
    Next
    _GDIPlus_GraphicsDrawImageRect($Graphic, $ParticleBitmap, 0, 0, $width, $height) ;copy to bitmap
    $i += 3
    If $i > $k + Abs($l) Then $i = $l
    Sleep(20)
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

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

    ; Clean up resources
    _GDIPlus_BrushDispose($Brush1)
    _GDIPlus_BrushDispose($Brush2)
    _GDIPlus_GraphicsDispose ($Graphic)
    _GDIPlus_BitmapDispose($ParticleBitmap)
    _GDIPlus_GraphicsDispose($ParticleBuffer)
    _GDIPlus_Shutdown ()
    Exit

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

    ; #FUNCTION# ====================================================================
    ; Name...........: _GDIPlus_BrushSetSolidColor
    ; Description ...: Set the color of a Solid Brush object
    ; Syntax.........: _GDIPlus_BrushSetSolidColor($hBrush, [$iARGB = 0xFF000000])
    ; Parameters ....: $hBrush - Handle to a Brush object
    ; $iARGB - Alpha, Red, Green and Blue components of brush
    ; Return values .: Success - True
    ; Failure - False
    ; Author ........:
    ; Modified.......: smashly
    ; Remarks .......:
    ; Related .......:
    ; Link ..........; @@MsdnLink@@ GdipSetSolidFillColor
    ; Example .......; Yes
    ; ================================================================================
    Func _GDIPlus_BrushSetSolidColor($hBrush, $iARGB = 0xFF000000)
    Local $aResult

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

    $aResult = DllCall($ghGDIPDll, "int", "GdipSetSolidFillColor", "hwnd", $hBrush, "int", $iARGB)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
    EndFunc ;==>_GDIPlus_BrushSetSolidColor

    [/autoit]

    #02 - Fliegende Quadrate:

    Spoiler anzeigen
    [autoit]


    ;coded by UEZ 2009-01-08
    #AutoIt3Wrapper_Run_Obfuscator=y
    #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0
    #AutoIt3Wrapper_UseUpx=n
    #AutoIt3Wrapper_Run_After=upx.exe --best "%out%"
    #AutoIt3Wrapper_Run_After=del "Flying Squares_Obfuscated.au3"

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

    #include <GuiConstantsEx.au3>
    #include <GDIPlus.au3>
    Opt("MustDeclareVars", 1)
    Opt("GUIOnEventMode", 1)
    Global Const $Pi = 4 * ATan(1)
    Global Const $width = 400
    Global Const $height = 400
    Global $hGUI, $hWnd, $hGraphic, $ParticleBitmap, $ParticleBuffer, $hBrush0, $Brush, $hBrush2, $Pen
    Global $frequenz, $i, $j, $k, $xcoord, $ycoord, $size, $red, $green, $blue, $start

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

    ; Create GUI
    $hGUI = GUICreate("GDI+: Flying Squares by UEZ 2009", $width, $height)
    $hWnd = WinGetHandle($hGUI)
    GUISetState()

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

    _GDIPlus_Startup ()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd) ;create graphic
    $ParticleBitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $hGraphic) ;create bitmap
    $ParticleBuffer = _GDIPlus_ImageGetGraphicsContext($ParticleBitmap) ;create buffer
    ;~ $Brush = _GDIPlus_BrushCreateSolid(0xAF777777)
    $Pen = _GDIPlus_PenCreate(0, 1)
    _GDIPlus_GraphicsClear($ParticleBuffer) ;clear buffer
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    $start = -64
    $i = $start
    $frequenz = 0
    ; Loop until user exits
    Do
    _GDIPlus_GraphicsClear($ParticleBuffer, 0xCF000000) ;clear buffer
    $k = 768 ;amount of squares
    $frequenz -= 0.025 ;smaller value = less frequency
    For $j = $k To 0 Step -32
    $red = ((Sin(2 ^ 0 * ($j - $i) / 2 ^ 5) + 1) / 2) * 256
    $green = ((Sin(2 ^ 0 * ($j - $i) / 2 ^ 7) + 1) / 2) * 256
    $blue = ((Sin(2 ^ 0 * ($j - $i) / 2 ^ 9) + 1) / 2) * 256
    ;~ $Brush = _GDIPlus_BrushCreateSolid("0x0F" & Hex($red, 2) & Hex($green, 2) & Hex($blue, 2))
    _GDIPlus_PenSetColor($Pen, "0xEF" & Hex($red, 2) & Hex($green, 2) & Hex($blue, 2))
    $size = $i - $j
    $xcoord = $width / 2 - (($i - $j) / 2) + Sin($frequenz) * -Sin(($i - $j) * $Pi / 180) * 64
    $ycoord = $height / 2 - (($i - $j) / 2) + -Cos($frequenz) * Cos(($i - $j) * $Pi / 150) * 32
    If $size <= 2 * $width + 4 And $size <= 2 * $height Then _GDIPlus_GraphicsDrawRect($ParticleBuffer, $xcoord, $ycoord, $size, $size, $Pen)
    ;~ _GDIPlus_GraphicsFillRect($ParticleBuffer, $xcoord, $ycoord, $size, $size, $Brush);filled squares
    Next
    ;~_GDIPlus_BrushDispose($Brush)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $ParticleBitmap, 0, 0, $width, $height) ;copy to bitmap
    $i += 3
    If $i > $k + 2^9 Then $i = $start
    Until Not Sleep(20)

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

    Func _Exit()
    ; Clean up resources
    _GDIPlus_GraphicsDispose ($hGraphic)
    _GDIPlus_BitmapDispose($ParticleBitmap)
    _GDIPlus_GraphicsDispose($ParticleBuffer)
    ;~ _GDIPlus_BrushDispose($Brush)
    _GDIPlus_Shutdown ()
    Exit
    EndFunc

    [/autoit]

    #03 - Rotierende Quadrate:

    Spoiler anzeigen
    [autoit]


    ;coded by UEZ 2009-01-12
    #AutoIt3Wrapper_Run_Obfuscator=y
    #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0
    #AutoIt3Wrapper_UseUpx=n
    #AutoIt3Wrapper_Run_After=upx.exe --best "%out%"
    #AutoIt3Wrapper_Run_After=del /f /q "Rotating Squares_Obfuscated.au3"

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

    #include <GuiConstantsEx.au3>
    #include <GDIPlus.au3>
    Opt('MustDeclareVars', 1)
    Global Const $Pi = 4 * ATan(1)
    Global Const $width = @DesktopWidth / 2
    Global Const $height = @DesktopHeight / 2
    Global $hGUI, $hGraphic, $Bitmap, $GDI_Buffer, $Pen, $Brush, $ellipse_size, $ellipse_size_double
    Global $i, $j, $k, $xcoord, $ycoord, $red, $green, $blue
    Global $x1, $x2, $x3, $x4, $y1, $y2, $y3, $y4

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

    $hGUI = GUICreate("GDI+: Rotating Squares by UEZ 2009", $width, $height)
    GUISetState(@SW_SHOW)

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

    _GDIPlus_Startup ()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hGUI) ;create graphic
    $Bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $hGraphic) ;create bitmap
    $GDI_Buffer = _GDIPlus_ImageGetGraphicsContext($Bitmap) ;create buffer
    $Pen = _GDIPlus_PenCreate(0, 2)
    $Brush = _GDIPlus_BrushCreateSolid(0xFF000000)
    _GDIPlus_GraphicsSetSmoothingMode($GDI_Buffer, 4)

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

    _GDIPlus_GraphicsClear($GDI_Buffer)
    $ellipse_size = 1.025
    $ellipse_size_double = $ellipse_size * 2
    $i = 1
    Do
    ;~ _GDIPlus_GraphicsClear($GDI_Buffer) ;clear buffer
    _GDIPlus_GraphicsFillEllipse($GDI_Buffer, $width / 2 - $ellipse_size * $k, $height / 2 - $ellipse_size* $k, $ellipse_size_double * $k, $ellipse_size_double * $k, $Brush) ;clear only area where the squares are drawn
    If $k <= 3 * $width / 7 Then $k += 1
    For $j = 8 To $k Step 24 + Cos($i * $Pi / 60) * 12
    $red = ((Sin(2^0 * ($j - $i) / 2^5) + 1) / 2) * 256
    $green = ((Sin(2^0 * ($j - $i) / 2^7) + 1) / 2) * 256
    $blue = ((Sin(2^0 * ($j - $i) / 2^9) + 1) / 2) * 256
    _GDIPlus_PenSetColor($Pen, "0xEF" & Hex($red, 2) & Hex($green, 2) & Hex($blue, 2)) ;Set the pen color
    $xcoord = $j ;+ Sin($i * $Pi / 60) * 8
    $ycoord = $j ;+ Cos($i * $Pi / 60) * 8
    Square($xcoord, $ycoord, $j * Sin($i / $k * $Pi * 4) * 2 / 3)
    Next
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $Bitmap, 0, 0, $width, $height) ;copy to bitmap
    $i += 1.5
    Sleep(30)
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

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

    ; Clean up resources
    _GDIPlus_PenDispose($Pen)
    _GDIPlus_BitmapDispose($Bitmap)
    _GDIPlus_GraphicsDispose($GDI_Buffer)
    _GDIPlus_GraphicsDispose ($hGraphic)
    _GDIPlus_Shutdown ()

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

    Func Square($xx1, $yy1, $i) ;coded by UEZ
    Local $degree = 45
    Local Const $pi_Div_180 = 4 * ATan(1) / 180
    $x1 = $xx1 * Cos(($i + $degree + 0) * $pi_Div_180) + $width / 2
    $y1 = $yy1 * Sin(($i + $degree + 0) * $pi_Div_180) + $height / 2
    $x2 = $xx1 * Cos(($i + $degree + 90) * $pi_Div_180) + $width / 2
    $y2 = $yy1 * Sin(($i + $degree + 90) * $pi_Div_180) + $height / 2
    $x3 = $xx1 * Cos(($i + $degree + 180) * $pi_Div_180) + $width / 2
    $y3 = $yy1 * Sin(($i + $degree + 180) * $pi_Div_180) + $height / 2
    $x4 = $xx1 * Cos(($i + $degree + 270) * $pi_Div_180) + $width / 2
    $y4 = $yy1 * Sin(($i + $degree + 270) * $pi_Div_180) + $height / 2
    _GDIPlus_GraphicsDrawLine($GDI_Buffer, $x1, $y1, $x2, $y2, $Pen)
    _GDIPlus_GraphicsDrawLine($GDI_Buffer, $x2, $y2, $x3, $y3, $Pen)
    _GDIPlus_GraphicsDrawLine($GDI_Buffer, $x3, $y3, $x4, $y4, $Pen)
    _GDIPlus_GraphicsDrawLine($GDI_Buffer, $x4, $y4, $x1, $y1, $Pen)
    EndFunc

    [/autoit]

    #05 - L-System Fraktale:

    Spoiler anzeigen
    [autoit]


    ;coded by UEZ 2009-01-17 -=> recursion is very slow with AutoIt !!! :(
    #AutoIt3Wrapper_Run_Obfuscator=y
    #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0
    #AutoIt3Wrapper_UseUpx=n
    ;~ #AutoIt3Wrapper_Run_After=upx.exe --best "%out%"
    #AutoIt3Wrapper_Run_After=upx.exe --ultra-brute "%out%"
    #AutoIt3Wrapper_Run_After=del "L-System Fractals_Obfuscated.au3"

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

    #include <Array.au3>
    #include <GDIPlus.au3>
    #Include <Misc.au3>

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

    Opt('MustDeclareVars', 1)
    Opt("GUIOnEventMode", 1)

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

    Global $dll = DllOpen("user32.dll")
    Global Const $Pi = 4 * ATan(1)
    Global Const $Pi_Div_180 = $Pi / 180
    Global Const $width = 800
    Global Const $height = 600
    Global $hGUI, $hWnd, $hGraphic, $Bitmap, $Pen
    Global $angle = 0, $x1, $y1, $x2, $y2, $random
    Global $length, $depth, $dir, $degree, $dist_rel
    Global $font_size, $String_Format, $Font_Family, $Font, $Text_Layout, $Brush, $text

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

    $hGUI = GUICreate("GDI+: L-System Fractals by UEZ 2009 (press F9 to save current image)", $width, $height)
    GUISetState(@SW_SHOW)

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

    GUISetOnEvent(-3, "_Exit")

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

    _GDIPlus_Startup ()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hGUI)
    $Pen = _GDIPlus_PenCreate(0, 1)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 4) ; AntiAlias

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

    $font_size = 7
    $String_Format = _GDIPlus_StringFormatCreate ()
    $Font_Family = _GDIPlus_FontFamilyCreate ("Arial")
    $Font = _GDIPlus_FontCreate ($Font_Family, $font_size, 2)
    $Brush = _GDIPlus_BrushCreateSolid (0xDF000000) ;text color

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

    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

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

    $random = Random(1, 11, 1)

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

    AdlibEnable("Save_PIC", 50)

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

    While 1
    Switch $random
    Case 1 ;Dragon Curve
    $x1 = $width / 4.2
    $y1 = $height / 2.8
    $length = 500
    $depth = Random(6, 18, 1)
    $dir = 1
    $angle = 0
    $text = "Dragon Curve, Recursion Depth = " & $depth
    Draw_Text()
    Dragon($length, $depth, $dir)
    Case 2 ;Levy-C Curve
    $x1 = $width / 3.65
    $y1 = $height / 2.875
    $length = 475
    $depth = Random(6, 18, 1)
    $dir = 1
    $angle = 0
    $text = "Levy-C Curve, Recursion Depth = " & $depth
    Draw_Text()
    Levy_C($length, $depth, $dir)
    Case 3 ;Koch Curve
    $x1 = $width / 5.3
    $y1 = $height / 1.35
    $x2 = ""
    $y2 = ""
    $length = 500
    $depth = Random(2, 8, 1)
    $dir = 1
    $angle = 0
    $text = "Koch Curve, Recursion Depth = " & $depth
    Draw_Text()
    Koch($length, $depth, $dir) ;F
    Turn(-$dir * 2 * $degree) ;--
    Koch($length, $depth, $dir) ;F
    Turn(-$dir * 2 * $degree) ;--
    Koch($length, $depth, $dir) ;F
    Case 4 ;Peano Curve
    $x1 = $width / 8
    $y1 = $height / 2
    $length = 600
    $depth = Random(2, 5, 1)
    $dir = 1
    $angle = 0
    $text = "Peano Curve, Recursion Depth = " & $depth
    Draw_Text()
    Peano($length, $depth, $dir)
    Case 5 ;Triangle
    $x1 = $width / 10.8
    $y1 = $height / 1.03
    $length = 1300
    $depth = Random(2, 10, 1)
    $dir = 1
    $angle = 0
    $text = "Triangle, Recursion Depth = " & $depth
    Draw_Text()
    Triangle($length, $depth, $dir)
    Case 6 ;Arrowhead Curve
    $x1 = $width / 10.80
    $y1 = $height / 1.05
    $length = 650
    $depth = Random(3, 9, 1)
    $dir = 1
    $angle = 0
    $text = "Arrowhead Curve, Recursion Depth = " & $depth
    Draw_Text()
    Arrowhead_R($length, $depth, $dir) ;R
    Case 7 ;Penta Plexity
    $x1 = $width / 3.55
    $y1 = $height / 15
    $length = 350
    $depth = Random(1, 6, 1)
    $dir = 1
    $angle = 0
    $text = "Penta Plexity, Recursion Depth = " & $depth
    Draw_Text()
    ;F++F++F++F++F
    Penta_Plexity($length, $depth, $dir) ;F
    Turn($dir * 2 * $degree) ;++
    Penta_Plexity($length, $depth, $dir) ;F
    Turn($dir * 2 * $degree) ;++
    Penta_Plexity($length, $depth, $dir) ;F
    Turn($dir * 2 * $degree) ;++
    Penta_Plexity($length, $depth, $dir) ;F
    Turn($dir * 2 * $degree) ;++
    Penta_Plexity($length, $depth, $dir) ;F
    Case 8 ;Sierpinski Carpet
    $x1 = $width / 8
    $y1 = $height / 2
    $length = 600
    $depth = Random(2, 6, 1)
    $dir = 1
    $angle = 0
    $text = "Sierpinski Carpet, Recursion Depth = " & $depth
    Draw_Text()
    Sierpinski_Carpet($length, $depth, $dir) ;F
    Case 9 ;Gosper Curve
    $depth = Random(4, 6, 1)
    $x1 = $width / 1.45
    $y1 = $height / 7 - $depth
    $length = 480
    $dir = 1
    $angle = 0
    $text = "Gosper Curve, Recursion Depth = " & $depth
    Draw_Text()
    Gosper_R($length, $depth, $dir) ;R
    Case 10 ;Sierpinski Triangle
    $x1 = $width / 10.666
    $y1 = $height / 1.05
    $length = 325
    $depth = Random(2, 9, 1)
    $dir = 1
    $angle = 0
    $text = "Sierpinski Triangle, Recursion Depth = " & $depth
    Draw_Text()
    ;FXF--FF--FF
    Sierpinski_F($length, $depth, $dir) ;F
    Sierpinski_X($length, $depth, $dir) ;X
    Sierpinski_F($length, $depth, $dir) ;F
    Turn(-$dir * 2 * $degree) ;--
    Sierpinski_F($length, $depth, $dir) ;F
    Sierpinski_F($length, $depth, $dir) ;F
    Turn(-$dir * 2 * $degree) ;--
    Sierpinski_F($length, $depth, $dir) ;F
    Sierpinski_F($length, $depth, $dir) ;F
    Case 11 ;Pythagoras Tree
    $x1 = $width / 2
    $y1 = $height / 1.1
    $length = 110
    $depth = Random(5, 15, 1)
    $dir = 1
    $angle = 5
    $text = "Pythagoras Tree, Recursion Depth = " & $depth
    Draw_Text()
    Pythagoras($length, $depth, $dir)
    EndSwitch
    $random += 1
    If $random = 12 Then $random = 1
    Sleep(4000)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)
    Wend

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

    Func Pythagoras($length, $split, $dir)

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

    If _IsPressed("20", $dll) Then ;hold pressed spacebar to abort current drawing
    $split = 0
    $dir = 0
    $length = 0
    EndIf
    If $split = 0 Then
    Pythagoras_Square($length)
    Else
    $dist_rel = Sqrt(3) / 2
    $degree = 30
    Pythagoras_Square($length)
    Forward_Only($length)
    Turn(-$dir * 1 * $degree)
    Pythagoras($length * $dist_rel, $split - 1, 1)
    Turn($dir * 3 * $degree)
    Forward_Only($length * $dist_rel)
    Pythagoras($length / 2, $split - 1, 1)
    Forward_Only(-$length * $dist_rel)
    Turn(-$dir * 2 * $degree)
    Forward_Only(-$length)
    EndIf
    ;Sleep(0)
    EndFunc

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

    Func Pythagoras_Square($length)
    Local $i
    For $i = 1 To 4
    Draw_and_Forward($length)
    Turn($dir * 90)
    Next
    EndFunc

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

    Func Sierpinski_X($length, $split, $dir)
    ;FXF--FF--FF
    ;X -> --FXF++FXF++FXF--
    ;F -> FF

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

    If _IsPressed("20", $dll) Then ;hold pressed spacebar to abort current drawing
    $split = 0
    $dir = 0
    $length = 0
    EndIf
    If $split = 0 Then
    ;~ Draw_and_Forward($length)
    Else
    $dist_rel = 2
    $degree = 60
    Turn(-$dir * 2 * $degree) ;--
    Sierpinski_F($length / $dist_rel, $split - 1, 1) ;F
    Sierpinski_X($length / $dist_rel, $split - 1, 1) ;X
    Sierpinski_F($length / $dist_rel, $split - 1, 1) ;F
    Turn($dir * 2 * $degree) ;++
    Sierpinski_F($length / $dist_rel, $split - 1, 1) ;F
    Sierpinski_X($length / $dist_rel, $split - 1, 1) ;X
    Sierpinski_F($length / $dist_rel, $split - 1, 1) ;F
    Turn($dir * 2 * $degree) ;++
    Sierpinski_F($length / $dist_rel, $split - 1, 1) ;F
    Sierpinski_X($length / $dist_rel, $split - 1, 1) ;X
    Sierpinski_F($length / $dist_rel, $split - 1, 1) ;F
    Turn(-$dir * 2 * $degree) ;--
    EndIf
    ;Sleep(0)
    EndFunc

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

    Func Sierpinski_F($length, $split, $dir)
    ;FXF--FF--FF
    ;X -> --FXF++FXF++FXF--
    ;F -> FF

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

    If _IsPressed("20", $dll) Then ;hold pressed spacebar to abort current drawing
    $split = 0
    $dir = 0
    $length = 0
    EndIf
    If $split = 0 Then
    Draw_and_Forward($length)
    Else
    $dist_rel = 2
    $degree = 60
    Sierpinski_F($length / $dist_rel, $split - 1, 1) ;F
    Sierpinski_F($length / $dist_rel, $split - 1, 1) ;F
    EndIf
    ;Sleep(0)
    EndFunc

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

    Func Gosper_R($length, $split, $dir)
    ;F -> R or F -> L
    ;R -> R+L++L-R--RR-L+
    ;L -> -R+LL++L+R--R-L

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

    If _IsPressed("20", $dll) Then ;hold pressed spacebar to abort current drawing
    $split = 0
    $dir = 0
    $length = 0
    EndIf
    If $split = 0 Then
    Draw_and_Forward($length)
    Else
    $dist_rel = Sqrt(7)
    $degree = 60
    Gosper_R($length / $dist_rel, $split - 1, 1) ;R
    Turn($dir * 1 * $degree) ;+
    Gosper_L($length / $dist_rel, $split - 1, 1) ;L
    Turn($dir * 2 * $degree) ;++
    Gosper_L($length / $dist_rel, $split - 1, 1) ;L
    Turn(-$dir * 1 * $degree) ;-
    Gosper_R($length / $dist_rel, $split - 1, 1) ;R
    Turn(-$dir * 2 * $degree) ;--
    Gosper_R($length / $dist_rel, $split - 1, 1) ;R
    Gosper_R($length / $dist_rel, $split - 1, 1) ;R
    Turn(-$dir * 1 * $degree) ;-
    Gosper_L($length / $dist_rel, $split - 1, 1) ;L
    Turn($dir * 1 * $degree) ;+
    EndIf
    ;Sleep(0)
    EndFunc

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

    Func Gosper_L($length, $split, $dir)
    ;F -> R or F -> L
    ;R -> R+L++L-R--RR-L+
    ;L -> -R+LL++L+R--R-L

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

    If _IsPressed("20", $dll) Then ;hold pressed spacebar to abort current drawing
    $split = 0
    $dir = 0
    $length = 0
    EndIf
    If $split = 0 Then
    Draw_and_Forward($length)
    Else
    $dist_rel = Sqrt(7)
    $degree = 60
    Turn(-$dir * 1 * $degree) ;-
    Gosper_R($length / $dist_rel, $split - 1, 1) ;R
    Turn($dir * 1 * $degree) ;+
    Gosper_L($length / $dist_rel, $split - 1, 1) ;L
    Gosper_L($length / $dist_rel, $split - 1, 1) ;L
    Turn($dir * 2 * $degree) ;++
    Gosper_L($length / $dist_rel, $split - 1, 1) ;L
    Turn($dir * 1 * $degree) ;+
    Gosper_R($length / $dist_rel, $split - 1, 1) ;R
    Turn(-$dir * 2 * $degree) ;--
    Gosper_R($length / $dist_rel, $split - 1, 1) ;R
    Turn(-$dir * 1 * $degree) ;-
    Gosper_L($length / $dist_rel, $split - 1, 1) ;L
    EndIf
    ;Sleep(0)
    EndFunc

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

    Func Sierpinski_Carpet($length, $split, $dir)
    ;F
    ;F -> F+F-F-FF-F-F-fF
    ;f -> fff

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

    If _IsPressed("20", $dll) Then ;hold pressed spacebar to abort current drawing
    $split = 0
    $dir = 0
    $length = 0
    EndIf
    If $split = 0 Then
    Draw_and_Forward($length)
    Else
    $dist_rel = 3
    $degree = 90
    Sierpinski_Carpet($length / $dist_rel, $split - 1, 1) ;F
    Turn($dir * 1 * $degree) ;+
    Sierpinski_Carpet($length / $dist_rel, $split - 1, 1) ;F
    Turn(-$dir * 1 * $degree) ;-
    Sierpinski_Carpet($length / $dist_rel, $split - 1, 1) ;F
    Turn(-$dir * 1 * $degree) ;-
    Sierpinski_Carpet($length / $dist_rel, $split - 1, 1) ;F
    Sierpinski_Carpet($length / $dist_rel, $split - 1, 1) ;F
    Turn(-$dir * 1 * $degree) ;-
    Sierpinski_Carpet($length / $dist_rel, $split - 1, 1) ;F
    Turn(-$dir * 1 * $degree) ;-
    Sierpinski_Carpet($length / $dist_rel, $split - 1, 1) ;F
    Turn(-$dir * 1 * $degree) ;-
    Sierpinski_Carpet_Forward_Only($length / $dist_rel, $split - 1, 1) ;f
    Sierpinski_Carpet($length / $dist_rel, $split - 1, 1) ;F
    EndIf
    ;Sleep(0)
    EndFunc

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

    Func Sierpinski_Carpet_Forward_Only($length, $split, $dir) ;f
    ;F
    ;F -> F+F-F-FF-F-F-fF
    ;f -> fff
    Forward_Only($length / $dist_rel) ;f
    Forward_Only($length / $dist_rel) ;f
    Forward_Only($length / $dist_rel) ;f
    ;Sleep(0)
    EndFunc

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

    Func Penta_Plexity($length, $split, $dir)
    ;F++F++F++F++F
    ;F -> F++F++F|F-F++F

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

    If _IsPressed("20", $dll) Then ;hold pressed spacebar to abort current drawing
    $split = 0
    $dir = 0
    $length = 0
    EndIf
    If $split = 0 Then
    Draw_and_Forward($length)
    Else
    $dist_rel = ((Sqrt(5) + 1) / 2)^2
    $degree = 36
    Penta_Plexity($length / $dist_rel, $split - 1, 1) ;F
    Turn($dir * 2 * $degree) ;++
    Penta_Plexity($length / $dist_rel, $split - 1, 1) ;F
    Turn($dir * 2 * $degree) ;++
    Penta_Plexity($length / $dist_rel, $split - 1, 1) ;F
    Turn($dir * 5 * $degree) ;180°
    Penta_Plexity($length / $dist_rel, $split - 1, 1) ;F
    Turn(-$dir * 1 * $degree) ;-
    Penta_Plexity($length / $dist_rel, $split - 1, 1) ;F
    Turn($dir * 2 * $degree) ;++
    Penta_Plexity($length / $dist_rel, $split - 1, 1) ;F
    EndIf
    ;Sleep(0)
    EndFunc

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

    Func Arrowhead_R($length, $split, $dir)
    ;F -> R oder F -> L
    ;R -> -L+R+L-
    ;L -> +R-L-R+

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

    If _IsPressed("20", $dll) Then ;hold pressed spacebar to abort current drawing
    $split = 0
    $dir = 0
    $length = 0
    EndIf
    If $split = 0 Then
    Draw_and_Forward($length)
    Else
    $dist_rel = 2
    $degree = 60
    Turn(-$dir * 1 * $degree) ;-
    Arrowhead_L($length / $dist_rel, $split - 1, 1) ;L
    Turn($dir * 1 * $degree) ;+
    Arrowhead_R($length / $dist_rel, $split - 1, 1) ;R
    Turn($dir * 1 * $degree) ;+
    Arrowhead_L($length / $dist_rel, $split - 1, 1) ;L
    Turn(-$dir * 1 * $degree) ;--
    EndIf
    ;Sleep(0)
    EndFunc

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

    Func Arrowhead_L($length, $split, $dir)
    ;F -> R oder F -> L
    ;R -> -L+R+L-
    ;L -> +R-L-R+

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

    If _IsPressed("20", $dll) Then ;hold pressed spacebar to abort current drawing
    $split = 0
    $dir = 0
    $length = 0
    EndIf
    If $split = 0 Then
    Draw_and_Forward($length)
    Else
    $dist_rel = 2
    $degree = 60
    Turn($dir * 1 * $degree) ;+
    Arrowhead_R($length / $dist_rel, $split - 1, 1) ;R
    Turn(-$dir * 1 * $degree) ;-
    Arrowhead_L($length / $dist_rel, $split - 1, 1) ;L
    Turn(-$dir * 1 * $degree) ;-
    Arrowhead_R($length / $dist_rel, $split - 1, 1) ;R
    Turn($dir * 1 * $degree) ;+
    EndIf
    ;Sleep(0)
    EndFunc

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

    Func Triangle($length, $split, $dir)
    ;F--F--F
    ;F -> F--F--F--ff
    ;ff -> ff

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

    If _IsPressed("20", $dll) Then ;hold pressed spacebar to abort current drawing
    $split = 0
    $dir = 0
    $length = 0
    EndIf
    If $split = 0 Then
    Draw_and_Forward($length)
    Else
    $dist_rel = 2
    $degree = 60
    Triangle($length / $dist_rel, $split - 1, 1) ;F
    Turn(-$dir * 2 * $degree) ;--
    Triangle($length / $dist_rel, $split - 1, 1) ;F
    Turn(-$dir * 2 * $degree) ;--
    Triangle($length / $dist_rel, $split - 1, 1) ;F
    Turn(-$dir * 2 * $degree) ;--
    Forward_Only($length / $dist_rel) ;f
    Forward_Only($length / $dist_rel) ;f
    EndIf
    ;Sleep(0)
    EndFunc

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

    Func Dragon($length, $split, $dir)
    ;F -> R
    ;R -> +R--L+
    ;L -> -R++L-

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

    If _IsPressed("20", $dll) Then ;hold pressed spacebar to abort current drawing
    $split = 0
    $dir = 0
    $length = 0
    EndIf
    If $split = 0 Then
    Draw_and_Forward($length)
    Else
    $degree = 45
    $dist_rel = Sqrt(2)
    Turn($dir * $degree) ;+
    Dragon($length / $dist_rel, $split - 1, 1) ;R
    Turn(-$dir * 2 * $degree) ;--
    Dragon($length / $dist_rel, $split - 1, -1) ;L
    Turn($dir * $degree) ;+
    EndIf
    ;Sleep(0)
    EndFunc

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

    Func Levy_C($length, $split, $dir)
    ;F
    ;F -> +F--F+

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

    If _IsPressed("20", $dll) Then ;hold pressed spacebar to abort current drawing
    $split = 0
    $dir = 0
    $length = 0
    EndIf
    If $split = 0 Then
    Draw_and_Forward($length)
    Else
    $degree = 45
    $dist_rel = 1.45
    Turn($dir * $degree) ;+
    Levy_C($length / $dist_rel, $split - 1, 1) ;F
    Turn(-$dir * 2 * $degree) ;--
    Levy_C($length / $dist_rel, $split - 1, 1) ;F
    Turn($dir * $degree) ;+
    EndIf
    ;Sleep(0)
    EndFunc

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

    Func Koch($length, $split, $dir)
    ;F--F--F
    ;F -> F+F--F+F

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

    If _IsPressed("20", $dll) Then ;hold pressed spacebar to abort current drawing
    $split = 0
    $dir = 0
    $length = 0
    EndIf
    If $split = 0 Then
    Draw_and_Forward($length)
    Else
    $dist_rel = 3
    $degree = 60
    Koch($length / $dist_rel, $split - 1, 1) ;F
    Turn($dir * $degree) ;+
    Koch($length / $dist_rel, $split - 1, 1) ;F
    Turn(-$dir * 2 * $degree) ;--
    Koch($length / $dist_rel, $split - 1, 1) ;F
    Turn($dir * $degree) ;+
    Koch($length / $dist_rel, $split - 1, 1) ;F
    EndIf
    ;Sleep(0)
    EndFunc

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

    Func Peano($length, $split, $dir)
    ;F
    ;F -> F-F+F+F+F-F-F-F+F

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

    If _IsPressed("20", $dll) Then ;hold pressed spacebar to abort current drawing
    $split = 0
    $dir = 0
    $length = 0
    EndIf
    If $split = 0 Then
    Draw_and_Forward($length)
    Else
    $dist_rel = 3
    $degree = 90
    Peano($length / $dist_rel, $split - 1, 1) ;F
    Turn(-$dir * $degree) ;-
    Peano($length / $dist_rel, $split - 1, 1) ;F
    Turn($dir * $degree) ;+
    Peano($length / $dist_rel, $split - 1, 1) ;F
    Turn($dir * $degree) ;+
    Peano($length / $dist_rel, $split - 1, 1) ;F
    Turn($dir * $degree) ;+
    Peano($length / $dist_rel, $split - 1, 1) ;F
    Turn(-$dir * $degree) ;-
    Peano($length / $dist_rel, $split - 1, 1) ;F
    Turn(-$dir * $degree) ;-
    Peano($length / $dist_rel, $split - 1, 1) ;F
    Turn(-$dir * $degree) ;-
    Peano($length / $dist_rel, $split - 1, 1) ;F
    Turn($dir * $degree) ;+
    Peano($length / $dist_rel, $split - 1, 1) ;F
    EndIf
    ;Sleep(0)
    EndFunc

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

    Func Turn ($degrees)
    $angle = $angle + ($degrees * $Pi_Div_180)
    EndFunc

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

    Func Draw_and_Forward($length)
    $x2 = $x1 + Cos($angle) * $length
    $y2 = $y1 + Sin($angle) * $length
    ;~ Local $red = 0 ;((Cos(1 * $x1 / 2^6) + 1) / 2) * 256
    ;~ Local $green = 0;((Cos(1.25 * $y2 / 2^6) + 1) / 2) * 256
    ;~ Local $blue = 0;((Cos(1.5 * $x2 / 2^6) + 1) / 2) * 256
    ;~ _GDIPlus_PenSetColor($Pen, "0xEF" & Hex($red, 2) & Hex($green, 2) & Hex($blue, 2)) ;Set the pen color
    _GDIPlus_PenSetColor($Pen, "0x60000000") ;Set the pen color
    _GDIPlus_GraphicsDrawLine($hGraphic, $x1, $y1, $x2, $y2, $Pen)
    $x1 = $x2
    $y1 = $y2
    EndFunc

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

    Func Forward_Only($length)
    $x2 = $x1 + Cos($angle) * $length
    $y2 = $y1 + Sin($angle) * $length
    $x1 = $x2
    $y1 = $y2
    EndFunc

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

    Func Draw_Text()
    Local $Text_Layout2
    Local $text_info = "UEZ 2009 ;-)"
    $Text_Layout = _GDIPlus_RectFCreate (0, $height - 1.75 * $font_size, 0, 0)
    $Text_Layout2 = _GDIPlus_RectFCreate ($width - StringLen($text_info) * $font_size * 0.67, $height - 1.75 * $font_size, 0, 0)
    _GDIPlus_GraphicsDrawStringEx ($hGraphic, $text, $Font, $Text_Layout, $String_Format, $Brush)
    _GDIPlus_GraphicsDrawStringEx ($hGraphic, $text_info, $Font, $Text_Layout2, $String_Format, $Brush)
    EndFunc

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

    Func Save_PIC()
    If _IsPressed("78", $dll) Then
    _GDIPlus_Save_to_Image(@ScriptDir & "\L-SF-Screenshot_" & @YEAR & @MON & @MDAY & "_" & @HOUR & @MIN & @SEC, $hGUI)
    If @error Then MsgBox(16, "ERROR", "Image was not saved!", 10)
    EndIf
    EndFunc

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

    ; #FUNCTION# =============================================================================
    ; Name...........: _GDIPlus_Save_to_Image
    ; Description ...: INTERNAL FUNCTION - save drawn image to file
    ; Syntax.........: _GraphGDIPlus_Reference_Pixel($file, $hWnd)
    ; Parameters ....: $file - filename
    ; $hWnd - handle to GUI
    ; Autor .........: ptrex, ProgAndy, UEZ
    ; =========================================================================================
    Func _GDIPlus_Save_to_Image($file, $hWnd, $CLSID = "PNG")
    Local $hDC, $memBmp, $memDC, $hImage, $w, $h, $size, $sCLSID
    If $file <> "" Or $hWnd <> "" Then
    $size = WinGetClientSize($hWnd)
    $w = $size[0]
    $h = $size[1]
    $hDC = _WinAPI_GetDC($hWnd)
    $memDC = _WinAPI_CreateCompatibleDC($hDC)
    $memBmp = _WinAPI_CreateCompatibleBitmap($hDC, $w, $h)
    _WinAPI_SelectObject ($memDC, $memBmp)
    _WinAPI_BitBlt($memDC, 0, 0, $w, $h, $hDC, 0, 0, 0x00CC0020) ; 0x00CC0020 = $SRCCOPY
    $hImage = _GDIPlus_BitmapCreateFromHBITMAP ($memBmp)
    $sCLSID = _GDIPlus_EncodersGetCLSID ($CLSID)
    ;~ _GDIPlus_ImageSaveToFile($hImage, $file)
    _GDIPlus_ImageSaveToFileEx ($hImage, $file & "." & StringLower($CLSID), $sCLSID)
    If @error Then
    Return SetError(1, 0, 0)
    Else
    Return SetError(0, 0, 0)
    EndIf
    _GDIPlus_ImageDispose ($hImage)
    _WinAPI_ReleaseDC($hWnd, $hDC)
    _WinAPI_DeleteDC($memDC)
    _WinAPI_DeleteObject ($memBmp)
    Else
    Return SetError(1, 0, 0)
    EndIf
    EndFunc

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

    Func _Exit()
    AdlibDisable()
    ; Clean up resources
    _GDIPlus_PenDispose($Pen)
    _GDIPlus_GraphicsDispose ($hGraphic)
    _GDIPlus_FontDispose ($Font)
    _GDIPlus_FontFamilyDispose ($Font_Family)
    _GDIPlus_StringFormatDispose ($String_Format)
    _GDIPlus_BrushDispose($Brush)
    _GDIPlus_Shutdown ()
    DllClose($dll)
    Exit
    EndFunc

    [/autoit]

    #06 - Sinus Laufschrift:

    Spoiler anzeigen
    [autoit]


    ;coded by UEZ 2009-01-29
    #AutoIt3Wrapper_Run_Obfuscator=y
    #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0
    #AutoIt3Wrapper_UseUpx=n
    ;~ #AutoIt3Wrapper_Run_After=upx.exe --best "%out%"
    #AutoIt3Wrapper_Run_After=upx.exe --ultra-brute "%out%"
    #AutoIt3Wrapper_Run_After=del /f /q "Sinus Scroller_Obfuscated.au3"

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

    #include <GUIConstantsEx.au3>
    #include <GDIplus.au3>

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

    Opt("GUIOnEventMode", 1)
    Opt('MustDeclareVars', 1)

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

    Global Const $width = Int(@DesktopWidth * (@DesktopHeight / @DesktopWidth) * 0.666)
    Global Const $height = Int(@DesktopHeight * (@DesktopHeight / @DesktopWidth) * 0.666)
    Global Const $pi = 4 * ATan(1)
    Global Const $pi_div_m170 = $pi / - 270
    Global Const $pi_div_10 = $pi / 10
    Global Const $pi_div_180 = $pi / 180
    Global Const $height_div_2 = $height / 2
    Global Const $width_div_2 = $width / 2
    Global Const $font_size = Int(($width + $height) / 16)
    Global Const $font_size2 = Int(($width + $height) / 32)

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

    Global $hGUI, $graphics, $bitmap, $GDI_Buffer
    Global $hBrush, $hFormat, $hFamily, $hFont, $hFont2, $text_color, $text_sin, $text_scroller, $tLayout, $pen, $brush
    Global $i, $j, $k, $l
    Global $m, $n, $x, $y, $z, $color
    Global $arr_text_sin, $letter_distance, $x, $y, $lenght, $end, $scroller_length
    Global $dc, $ScreenDc, $gdibitmap
    Global $title = "GDI+: Sinus Scroller by UEZ 2009"

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

    $hGUI = GUICreate($title, $width, $height)
    GUISetState(@SW_SHOW)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

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

    _GDIPlus_Startup()
    $graphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics)
    $GDI_Buffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
    _GDIPlus_GraphicsSetSmoothingMode($GDI_Buffer, 4)

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

    $ScreenDc = _WinAPI_GetDC($hGUI)
    $text_color = 0xEFD0D0FF
    $hBrush = _GDIPlus_BrushCreateSolid($text_color)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, $font_size, 2)
    $hFont2 = _GDIPlus_FontCreate($hFamily, $font_size2, 2)
    $pen = _GDIPlus_PenCreate(0)
    $brush = _GDIPlus_BrushCreateSolid(0)

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

    $text_scroller = "YES, another GDI+ example, SINUS SCROLLER, by UEZ in 01/2009! :) Let's start... "
    $text_sin = "I was inspired by the old good intro school on C64 when I was 15 and did some assembler intros :-). "
    $text_sin &= "Greetings to all forum members at http://www.autoitscript.com and http://www.autoit.de. I hope you like it! ;) The END."
    $arr_text_sin = StringSplit($text_sin, "")

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

    Global $stars = 128
    Dim $arr_stars_x[$stars]
    Dim $arr_stars_y[$stars]
    Dim $aFont_Sized[Int($height / 4)]
    Global Const $min_size = 4
    Global Const $max_size = UBound($aFont_Sized) - 1

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

    For $n = 0 To UBound($aFont_Sized) - 1
    $aFont_Sized[$n] = _GDIPlus_FontCreate($hFamily, $n + $min_size, 0)
    Next

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

    For $n = 0 To UBound($arr_stars_y) - 1
    $arr_stars_y[$n] = Random(1, $height - 1, 1)
    Next

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

    For $n = 0 To UBound($arr_stars_x) - 1
    $arr_stars_x[$n] = Random(-$width * 1.5, -1, 1)
    Next

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

    Dim $arr_star_speed[8]
    $arr_star_speed[0] = 1.00
    $arr_star_speed[1] = 1.33
    $arr_star_speed[2] = 1.66
    $arr_star_speed[3] = 2.00
    $arr_star_speed[4] = 2.33
    $arr_star_speed[5] = 2.66
    $arr_star_speed[6] = 3.33
    $arr_star_speed[7] = 4.50
    _GDIPlus_GraphicsSetSmoothingMode($GDI_Buffer, 2)

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

    $tLayout = _GDIPlus_RectFCreate(0, 0)

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

    Scroller_Ini()

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

    Do
    Sinus_Scroller()
    Until False

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

    Func Stars()
    $m = 0
    For $n = 0 To UBound($arr_stars_x) - 1
    Switch $arr_star_speed[$m]
    Case 1.00
    $color = 0xAF888888
    Case 1.33
    $color = 0xBF999999
    Case 1.66
    $color = 0xCFAAAAAA
    Case 2.00
    $color = 0xCFBBBBBB
    Case 2.33
    $color = 0xDFCCCCCC
    Case 2.66
    $color = 0xDFDDDDDD
    Case 3.33
    $color = 0xEFEEEEEE
    Case 4.50
    $color = 0xEFFFFFFF
    EndSwitch
    ;~ If $arr_stars_x[$n] >= 0 And $arr_stars_x[$n] <= $width Then Set_Pixel($arr_stars_x[$n], $arr_stars_y[$n], $color)
    If $arr_stars_x[$n] >= 0 And $arr_stars_x[$n] <= $width Then _GDIPlus_BitmapSetPixel($bitmap, $arr_stars_x[$n], $arr_stars_y[$n], $color)
    $arr_stars_x[$n] += $arr_star_speed[$m]
    $m += 1
    If $m = UBound($arr_star_speed) - 1 Then $m = 0
    If $arr_stars_x[$n] >= $width Then
    $arr_stars_y[$n] = Random(1, $height - 1, 1)
    $arr_stars_x[$n] = 0
    EndIf
    Next
    Sleep(5)
    EndFunc ;==>Stars

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

    Func Sinus_Scroller()
    $letter_distance = 32
    $l = 0
    For $k = $width To 0 - (StringLen($text_sin) * $letter_distance * 1.1) Step -1.5
    _GDIPlus_GraphicsClear($GDI_Buffer, 0xFF000000)
    For $i = 1 To UBound($arr_text_sin) - 1
    $x = $k + ($i * $letter_distance) + ($width_div_2 * Cos($l - ($i * $pi / ATan($i * $pi_div_m170) * - 0.25))) * 0.4
    $y = ($height_div_2 - 1.666 * $font_size2) + ($height * Sin($l - ($i * $pi_div_10))) * 0.35
    $l += 0.00025
    If $x > -$max_size And $x <= $width Then
    DllStructSetData($tLayout, "x", $x)
    DllStructSetData($tLayout, "y", $y)
    $z = Sin(($y * 0.25) * $pi_div_180) * $max_size
    If $z < 0 Then Abs($z)
    _GDIPlus_GraphicsDrawStringEx($GDI_Buffer, $arr_text_sin[$i], $aFont_Sized[$z], $tLayout, $hFormat, $hBrush)
    EndIf
    Next
    Sleep(5)
    Stars()
    ;~ _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)
    $gdibitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($bitmap)
    $dc = _WinAPI_CreateCompatibleDC($ScreenDc)
    _WinAPI_SelectObject($dc, $gdibitmap)
    _WinAPI_DeleteObject($gdibitmap)
    _WinAPI_BitBlt($ScreenDc, 0, 0, $Width, $Height, $dc, 0, 0, 0x00CC0020) ; 0x00CC0020 = $SRCCOPY
    _WinAPI_DeleteDC($dc)
    Next
    EndFunc ;==>Sinus_Scroller

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

    Func Scroller_Ini() ;very simple scroller
    $letter_distance = $font_size
    $lenght = $font_size * 1.666 * 0.36
    $k = $width
    $end = 0
    $scroller_length = StringLen($text_scroller) * $lenght
    $y = -($font_size * 0.2) + ($height_div_2 - $font_size * 0.5) ;center scroller
    AdlibEnable("Scroller", 15)
    While Not $end
    Sleep(10)
    WEnd
    EndFunc ;==>Scroller

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

    Func Scroller()
    _GDIPlus_GraphicsClear($GDI_Buffer, 0xFF000000)
    $x = $k + $letter_distance
    DllStructSetData($tLayout, "x", $x)
    DllStructSetData($tLayout, "y", $y)
    _GDIPlus_GraphicsDrawStringEx($GDI_Buffer, $text_scroller, $hFont, $tLayout, $hFormat, $hBrush)
    _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)
    $k -= 2
    If -$scroller_length >= $k Then
    $end = 1
    AdlibDisable()
    EndIf
    EndFunc

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

    Func _GDIPlus_BitmapSetPixel($hBitmap, $iX, $iY, $iARGB = 0xFF000000)
    Local $aRet
    $aRet = DllCall($ghGDIPDll, "int", "GdipBitmapSetPixel", "hwnd", $hBitmap, "int", $iX, "int", $iY, "dword", $iARGB)
    Return
    EndFunc ;==>_GDIPlus_BitmapSetPixel

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

    ;~ Func _GDIPlus_BrushSetSolidColor($hBrush, $iARGB = 0xFF000000)
    ;~ Local $aResult
    ;~ $aResult = DllCall($ghGDIPDll, "int", "GdipSetSolidFillColor", "hwnd", $hBrush, "int", $iARGB)
    ;~ If @error Then Return SetError(@error, @extended, 0)
    ;~ Return SetError($aResult[0], 0, $aResult[0] = 0)
    ;~ EndFunc ;==>_GDIPlus_BrushSetSolidColor

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

    Func _Exit()
    _WinAPI_ReleaseDC($hGUI, $ScreenDc)
    _WinAPI_DeleteObject ($gdibitmap)
    For $n = 0 To UBound($aFont_Sized) - 1
    _GDIPlus_FontDispose($aFont_Sized[$n])
    Next
    _GDIPlus_PenDispose($pen)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_BrushDispose($brush)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontDispose($hFont2)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_GraphicsDispose($GDI_Buffer)
    _GDIPlus_BitmapDispose($bitmap)
    _GDIPlus_GraphicsDispose($graphics)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

    [/autoit]


    AiO Download Link (kompilierte Exes + Quellcode)


    Was gefällt euch von den GDI+ Beispielen am besten?

    Gruß,
    UEZ;-)

    PS: viel mehr Beispiele im engl. Forum!

    2009-01-23: Perspektive im Code von Fliegende Quadrate korrigiert. Nun zeichnet es von hinten nach vorne!
    2009-01-30: Sinus Laufschrift hunzugefügt
    2009-02-02: #01 - Fliegende Perlenkette modifiziert (seperate Farbe für jede Kugel)
    2009-02-05: Dreick und Pfeilspitze in #05 - L-System Fraktale hinzugefügt
    2009-02-06: Sierpinski Dreieck, Gosper Kurve, Sierpinski Teppich und Penta Plexity in #05 - L-System Fraktale (10 Module nun) hinzugefügt
    2009-02-07: Pythagoras Baum in #05 - L-System Fraktale (11 Module nun) hinzugefügt
    2009-02-08: Sterne Scrolling in #06 - Sinus Laufschrift hinzugefügt
    2009-03-03: AiO Link hinzugefügt
    2009-11-14: #01 - #06 aktualisiert
    2009-11-23: Screenshot (F9) in #05 - L-System Fraktale hinzugefügt

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

    22 Mal editiert, zuletzt von UEZ (11. Dezember 2009 um 16:43)

  • Ich finde sie ganz gut.

    Nett wäre als Bildscirmschoner, aber das geht warscheinlich nicht.

    tobi_girst

    MfG. tobi_girst

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »tobi_girst« (Morgen, 25:63)

  • Warum nicht ?

    Kompilieren als EXE, umbenennen zu SCN und nutzen. Es gab im Forum mal einen Beitrag eines Matrix-Schoners, das der Bildschirmschoner auf jede Taste/Mausbewegung reagiert. Musst Du mal nach suchen.

    Wenn Du es nicht mehr finden solltes, poste ich den Code nochmal.

    Zur Nutzung dieses Forum's, ist ein Übersetzer für folgende Begriffe unerlässlich:

    "On-Bort, weier, verscheiden, schädliges, Butten steyling, näckstet, Parr, Porblem, scripe, Kompletenz, harken, manuel zu extramieren, geckukt, würglich, excell, acces oder Compilevorgeng"

  • Warum nicht ?
    Läuft bei mir schon seit über einem halben Jahr, ohne Probleme bis jetzt.

    Zur Nutzung dieses Forum's, ist ein Übersetzer für folgende Begriffe unerlässlich:

    "On-Bort, weier, verscheiden, schädliges, Butten steyling, näckstet, Parr, Porblem, scripe, Kompletenz, harken, manuel zu extramieren, geckukt, würglich, excell, acces oder Compilevorgeng"

  • Dass das geht ist klar, aber ein Screensaver im klassischen Sinn ist das nicht (Full Screen, Multimonitor Support, Konfiguration, etc.).

    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

  • Natürlich kann man die Beispiele als Bildschirmschoner programmieren! Nur kann man nicht einfach die exe in scr umbenennen und das war's.

    Wenn ich Zeit habe, kann ich das mal machen... Ansonsten kann man sich im englischen Forum umsehen. Dort gibt es sehr gute Beispiele, wie man einen Bildschirmschoner bastelt ! 8)


    Gruß,
    UEZ

    Stimmt, habs grade ausprobiert. Einfach die GUICREATE("TXT"), gegen _SS_GUICREATE() ausrtauschen. das war's! Nix vergrößert / Zentriert, aber das is tja erst mal egal.
    autoit.de/wcf/attachment/3714/

    MfG. tobi_girst

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »tobi_girst« (Morgen, 25:63)

    Einmal editiert, zuletzt von tobi_girst (20. Januar 2009 um 15:57)

  • Hallo

    Hab dich und deine Projekte ja schon etwas länger im englischen Forum verfolgt ;)
    Also erstmal herzlich Willkommen hier im Deutschen AutoIt Forum!

    Die GDI+ Examples sind sehr hübsch, weiter so :thumbup:

    Mfg Spider

    Danke :D

    So riesen Projekte habe ich eigentlich nicht laufen. Vielleicht das SIC2 Projekt...

    UEZ :rock:

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

  • Dass das geht ist klar, aber ein Screensaver im klassischen Sinn ist das nicht (Full Screen, Multimonitor Support, Konfiguration, etc.).

    UEZ

    Also FullScreen geht, aber mit Multi-Monitor (hier aber nur zwei einzelne Anzeigen) hat mein Script natürlich ein Problem. Konnte ich gerade sehen, als ich den zweiten Schirm angemacht habe.

    Zur Nutzung dieses Forum's, ist ein Übersetzer für folgende Begriffe unerlässlich:

    "On-Bort, weier, verscheiden, schädliges, Butten steyling, näckstet, Parr, Porblem, scripe, Kompletenz, harken, manuel zu extramieren, geckukt, würglich, excell, acces oder Compilevorgeng"

  • Hier der Code für ein Screensaver 8)

    Spoiler anzeigen

    ;coded by UEZ 2009-01-22
    #include <GDIPlus.au3>
    #include <WindowsConstants.au3>
    Opt('MustDeclareVars', 1)
    If WinExists("ScrnSav:" & @ScriptFullPath) Then WinKill("ScrnSav:" & @ScriptFullPath)
    AutoItWinSetTitle("ScrnSav:" & @ScriptFullPath)

    Const $appname = "Mesmerizing Squares Screensaver"
    Const $ver = "0.75"
    Const $build = "2009-01-22"
    Const $Pi = 3.1415926535897932384626
    Global $hGUI, $hWnd, $hGraphic, $Bitmap, $GDI_Buffer, $Pen
    Global $i, $j, $k, $xcoord, $ycoord, $red, $green, $blue
    Global $x1, $x2, $x3, $x4, $y1, $y2, $y3, $y4, $x, $y
    Global $VirtualDesktopHeight, $VirtualDesktopWidth, $VirtualDesktopX, $VirtualDesktopY
    Global $width, $height, $new, $last, $user32, $parent_PID, $child_PID
    Global $CommandLine

    $width = @DesktopWidth
    $height = @DesktopHeight

    $VirtualDesktopWidth = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 78);sm_virtualwidth
    $VirtualDesktopWidth = $VirtualDesktopWidth[0]
    $VirtualDesktopHeight = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 79);sm_virtualheight
    $VirtualDesktopHeight = $VirtualDesktopHeight[0]
    $VirtualDesktopX = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 76);sm_xvirtualscreen
    $VirtualDesktopX = $VirtualDesktopX[0]
    $VirtualDesktopY = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 77);sm_yvirtualscreen
    $VirtualDesktopY = $VirtualDesktopY[0]


    If $CmdLine[0] > 0 Then
    $CommandLine = StringLeft($CmdLine[1], 2)
    Else
    $CommandLine = "/s"
    EndIf


    If $CommandLine = "/c" Then
    MsgBox(64, "Information", "Nothing to configure yet, maybe later ;-)" & @CRLF & @CRLF & _
    "(c) UEZ " & $build, 15)
    Exit
    ElseIf $CommandLine = "/p" Then
    If UBound($CmdLine) < 3 Then
    MsgBox(16, "ERROR!", "Program was called wrongly!")
    Exit
    EndIf
    Preview_SS()
    ElseIf $CommandLine = "/s" Then
    Start_SS()
    EndIf
    Exit

    Func Preview_SS()
    $width = 152
    $height = 112
    $hGUI = GUICreate($appname, $width, $height, 0, 0, 0x80000000)
    $hWnd = WinGetHandle($hGUI)
    $user32 = DllOpen("user32.dll")
    DllCall($user32, "int", "SetParent", "hwnd", $hGUI, "hwnd", HWnd($CmdLine[2])) ;set preview window
    DllClose($user32)
    GUISetState()
    Ini_GDI()
    $VirtualDesktopX = 0
    $VirtualDesktopY = 0
    $x = $width
    $y = $height
    $parent_PID = _ProcessGetParent(@AutoItPID)
    While 1
    If Not WinExists($hWnd) Then _Exit()
    $child_PID = _ProcessGetChildren($parent_PID)
    If $child_PID[0] > 1 Then _Exit() ;if another screensaver is selected in ComboBox close ss
    Draw(16)
    Sleep(30)
    WEnd
    _Exit()
    EndFunc

    Func Start_SS()
    $hGUI = GUICreate($appname, $VirtualDesktopWidth, $VirtualDesktopHeight, $VirtualDesktopX, $VirtualDesktopY, $WS_POPUP, BitOr($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
    $hWnd = WinGetHandle($hGUI)
    GUISetState()
    GUISetCursor(16, 1) ; hide mouse cursor
    $width = $VirtualDesktopWidth
    $height = $VirtualDesktopHeight
    $x = @DesktopWidth
    $y = @DesktopHeight
    Ini_GDI()
    $k = 0
    $i = 1
    While 1
    $new = _IdleTicks()
    If $new < $last Then
    ExitLoop
    EndIf
    $last = $new
    Draw(28)
    WEnd
    _Exit()
    EndFunc

    Func Ini_GDI()
    _GDIPlus_Startup ()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd) ;create graphic
    $Bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $hGraphic) ;create bitmap
    $GDI_Buffer = _GDIPlus_ImageGetGraphicsContext($Bitmap) ;create buffer
    $Pen = _GDIPlus_PenCreate(0, 1)
    _GDIPlus_GraphicsSetSmoothingMode($GDI_Buffer, 4)
    _GDIPlus_GraphicsClear($GDI_Buffer)
    EndFunc

    Func Draw($density)
    _GDIPlus_GraphicsClear($GDI_Buffer) ;clear buffer
    If $k <= 3 * $x / 7 Then $k += 1
    For $j = 8 To $k Step $density + Sin($i * $Pi / 60) * 8
    $red = ((Sin(2^0 * ($j - $i) / 2^5) + 1) / 2) * 256
    $green = ((Sin(2^0 * ($j - $i) / 2^7) + 1) / 2) * 256
    $blue = ((Sin(2^0 * ($j - $i) / 2^9) + 1) / 2) * 256
    _GDIPlus_PenSetColor($Pen, "0xEF" & Hex($red, 2) & Hex($green, 2) & Hex($blue, 2)) ;Set the pen color
    $xcoord = $j
    $ycoord = $j
    Square($xcoord, $ycoord, $j * Cos($i / $k * $Pi))
    Next
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $Bitmap, 0, 0, $width, $height) ;copy to bitmap
    $i += 1.5
    Sleep(30)
    EndFunc

    Func _Exit()
    _GDIPlus_PenDispose($Pen)
    _GDIPlus_BitmapDispose($Bitmap)
    _GDIPlus_GraphicsDispose($GDI_Buffer)
    _GDIPlus_GraphicsDispose ($hGraphic)
    _GDIPlus_Shutdown ()
    Exit
    EndFunc

    Func Square($xx1, $yy1, $i)
    Local $degree
    $degree = 45
    $x1 = $xx1 * Cos(($i + $degree + 0) * $Pi / 180) + $x / 2 + Abs($VirtualDesktopX)
    $y1 = $yy1 * Sin(($i + $degree + 0) * $Pi / 180) + $y / 2 + Abs($VirtualDesktopY)
    $x2 = $xx1 * Cos(($i + $degree + 90) * $Pi / 180) + $x / 2 + Abs($VirtualDesktopX)
    $y2 = $yy1 * Sin(($i + $degree + 90) * $Pi / 180) + $y / 2 + Abs($VirtualDesktopY)
    $x3 = $xx1 * Cos(($i + $degree + 180) * $Pi / 180) + $x / 2 + Abs($VirtualDesktopX)
    $y3 = $yy1 * Sin(($i + $degree + 180) * $Pi / 180) + $y / 2 + Abs($VirtualDesktopY)
    $x4 = $xx1 * Cos(($i + $degree + 270) * $Pi / 180) + $x / 2 + Abs($VirtualDesktopX)
    $y4 = $yy1 * Sin(($i + $degree + 270) * $Pi / 180) + $y / 2 + Abs($VirtualDesktopY)
    _GDIPlus_GraphicsDrawLine($GDI_Buffer, $x1, $y1, $x2, $y2, $Pen)
    _GDIPlus_GraphicsDrawLine($GDI_Buffer, $x2, $y2, $x3, $y3, $Pen)
    _GDIPlus_GraphicsDrawLine($GDI_Buffer, $x3, $y3, $x4, $y4, $Pen)
    _GDIPlus_GraphicsDrawLine($GDI_Buffer, $x4, $y4, $x1, $y1, $Pen)
    EndFunc

    Func _IdleTicks() ; thanks to erifash for the routine
    Local $aTSB = DllCall("kernel32.dll", "long", "GetTickCount")
    Local $ticksSinceBoot = $aTSB[0]
    Local $struct = DllStructCreate("uint;dword")
    DllStructSetData($struct, 1, DllStructGetSize($struct))
    DllCall("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr($struct))
    Local $ticksSinceIdle = DllStructGetData($struct, 2)
    Return ($ticksSinceBoot - $ticksSinceIdle)
    EndFunc ;==>_IdleTicks

    Func _ProcessGetParent($i_pid) ;get PID from parent process done by SmOke_N
    Local $TH32CS_SNAPPROCESS = 0x00000002

    Local $a_tool_help = DllCall("Kernel32.dll", "long", "CreateToolhelp32Snapshot", "int", $TH32CS_SNAPPROCESS, "int", 0)
    If IsArray($a_tool_help) = 0 Or $a_tool_help[0] = -1 Then Return SetError(1, 0, $i_pid)

    Local $tagPROCESSENTRY32 = _
    DllStructCreate ( _
    "dword dwsize;" & _
    "dword cntUsage;" & _
    "dword th32ProcessID;" & _
    "uint th32DefaultHeapID;" & _
    "dword th32ModuleID;" & _
    "dword cntThreads;" & _
    "dword th32ParentProcessID;" & _
    "long pcPriClassBase;" & _
    "dword dwFlags;" & _
    "char szExeFile[260]" _
    )
    DllStructSetData($tagPROCESSENTRY32, 1, DllStructGetSize($tagPROCESSENTRY32))

    Local $p_PROCESSENTRY32 = DllStructGetPtr($tagPROCESSENTRY32)

    Local $a_pfirst = DllCall("Kernel32.dll", "int", "Process32First", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32)
    If IsArray($a_pfirst) = 0 Then Return SetError(2, 0, $i_pid)

    Local $a_pnext, $i_return = 0
    If DllStructGetData($tagPROCESSENTRY32, "th32ProcessID") = $i_pid Then
    $i_return = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID")
    DllCall("Kernel32.dll", "int", "CloseHandle", "long", $a_tool_help[0])
    If $i_return Then Return $i_return
    Return $i_pid
    EndIf

    While @error = 0
    $a_pnext = DLLCall("Kernel32.dll", "int", "Process32Next", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32)
    If DllStructGetData($tagPROCESSENTRY32, "th32ProcessID") = $i_pid Then
    $i_return = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID")
    If $i_return Then ExitLoop
    $i_return = $i_pid
    ExitLoop
    EndIf
    WEnd

    DllCall("Kernel32.dll", "int", "CloseHandle", "long", $a_tool_help[0])
    Return $i_return
    EndFunc

    Func _ProcessGetChildren($i_pid) ; First level children processes only done by SmOke_N
    Local Const $TH32CS_SNAPPROCESS = 0x00000002

    Local $a_tool_help = DllCall("Kernel32.dll", "long", "CreateToolhelp32Snapshot", "int", $TH32CS_SNAPPROCESS, "int", 0)
    If IsArray($a_tool_help) = 0 Or $a_tool_help[0] = -1 Then Return SetError(1, 0, $i_pid)

    Local $tagPROCESSENTRY32 = _
    DllStructCreate _
    ( _
    "dword dwsize;" & _
    "dword cntUsage;" & _
    "dword th32ProcessID;" & _
    "uint th32DefaultHeapID;" & _
    "dword th32ModuleID;" & _
    "dword cntThreads;" & _
    "dword th32ParentProcessID;" & _
    "long pcPriClassBase;" & _
    "dword dwFlags;" & _
    "char szExeFile[260]" _
    )
    DllStructSetData($tagPROCESSENTRY32, 1, DllStructGetSize($tagPROCESSENTRY32))

    Local $p_PROCESSENTRY32 = DllStructGetPtr($tagPROCESSENTRY32)

    Local $a_pfirst = DllCall("Kernel32.dll", "int", "Process32First", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32)
    If IsArray($a_pfirst) = 0 Then Return SetError(2, 0, $i_pid)

    Local $a_pnext, $a_children[11] = [10], $i_child_pid, $i_parent_pid, $i_add = 0
    $i_child_pid = DllStructGetData($tagPROCESSENTRY32, "th32ProcessID")
    If $i_child_pid <> $i_pid Then
    $i_parent_pid = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID")
    If $i_parent_pid = $i_pid Then
    $i_add += 1
    $a_children[$i_add] = $i_child_pid
    EndIf
    EndIf

    While 1
    $a_pnext = DLLCall("Kernel32.dll", "int", "Process32Next", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32)
    If IsArray($a_pnext) And $a_pnext[0] = 0 Then ExitLoop
    $i_child_pid = DllStructGetData($tagPROCESSENTRY32, "th32ProcessID")
    If $i_child_pid <> $i_pid Then
    $i_parent_pid = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID")
    If $i_parent_pid = $i_pid Then
    If $i_add = $a_children[0] Then
    ReDim $a_children[$a_children[0] + 10]
    $a_children[0] = $a_children[0] + 10
    EndIf
    $i_add += 1
    $a_children[$i_add] = $i_child_pid
    EndIf
    EndIf
    WEnd

    If $i_add <> 0 Then
    ReDim $a_children[$i_add + 1]
    $a_children[0] = $i_add
    EndIf

    DllCall("Kernel32.dll", "int", "CloseHandle", "long", $a_tool_help[0])
    If $i_add Then Return $a_children
    Return SetError(3, 0, 0)
    EndFunc

    Einfach kompilieren, in .scr umbennen (oder hier herunterladen ) und ab ins System32 Verzeichnis! Dann einfach den SS auswählen :rock:

    Zur Zeit ohne Einstellmöglichkeiten.

    UEZ

    2009-01-23: kein richtiger Multi Monitor Support -> sollte jetzt funzen!

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

    6 Mal editiert, zuletzt von UEZ (31. Januar 2009 um 00:19)

  • hi uez,

    erst mal nice jop [Blockierte Grafik: http://www.autoit.de/wcf/images/smilies/thumbup.png]

    hab deinen screensaver grad mal getestet. bei mir geht leider die vorschau noch nicht.

    [autoit]

    ElseIf $CommandLine = "/p" Then Preview_SS()

    [/autoit]

    folgender fehler wird bei mir angezeigt:

    Line-1:
    Error: Array variable has incorrect number of subscripts or subscript dimension range execeeded.
    ...

  • Danke für das Lob :D

    Was meinst du mit Vorschau? Wenn du einen Bildschirmschoner aussuchst (in dem kleinen Vorschaufenster) oder erst wenn du auf den Vorschau Knopf drückst?

    Ich habe auf folgenden Systemen den Bildschirmschoner getestet und konnte keine Fehlermeldung sehen:
    Vista Enterprise x32
    Windows Server2003 x32
    Windows Server 2008 x32
    WindowsXP x32

    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

  • hi noch ne frage...ich kenn mich in der commandline noch nicht so aus. kann man den befehl auch unabhänig von dem exe namen vergeben.

    Beispiel:
    wenn die exe "screensaver" heißt würden die befehle ja nur mit
    screensaver /s
    screensaver /p ;usw gehn
    kann man hier noch andere befehle zuweisen, wie:
    save /s
    oder bin ich hier grad ganz falsch?

  • Zitat von UEZ

    Was meinst du mit Vorschau? Wenn du einen Bildschirmschoner aussuchst (in dem kleinen Vorschaufenster) oder erst wenn du auf den Vorschau Knopf drückst?


    ich hab das ganze per cmd ausgeführt^^ und dann kam der fehler

  • Probiere's doch mal so: den Code kompilieren, die Exe umbenennen in z.B. Qudrate.scr und nach C:\Windows\System32 kopieren, falls dies der Pfad sein sollte. Dann in der Systemsteuerung den Bildschirmschoner aussuchen.

    Dass /P aus der CMD nicht funktioniert liegt daran, dass $CmdLine[2] nicht definiert ist. /P wird intern aufgerufen!


    Ich habe auch den Code angepasst, dass /P nicht aus der CMD gestartet werden kann!

    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

    Einmal editiert, zuletzt von UEZ (23. Januar 2009 um 13:47)

  • das würde mich ja grad interessieren ... np
    ich denke ich eröffne mal ein neues thema unter hilfe "cmdline"