Jump to content

(Something like) Fire screensaver with AutoIt


lokster
 Share

Recommended Posts

(Something like) Fire screensaver. Compile the script and change the extension from .exe to .scr. Then doubleclick on it to see it running.

(this is windowed mode screenshot, the real screensaver is fullscreen)

Posted Image

The configuration dialog:

Posted Image

Fixed thanks to Zedna There is one problem - if you increase the particle count the screen flickers a lot...

fire.au3:

#NoTrayIcon
#include <GUIConstants.au3>
#include <Misc.au3>

Opt("ColorMode",1); use BGR color mode - its easier if you use Windows GDI use BGR format
Global $GDI32 = DllOpen("gdi32.dll")
Global $USER32 = DllOpen("user32.dll")

;~ Global Const $width = 320
;~ Global Const $height = 200
Global Const $width = @DesktopWidth
Global Const $height = @DesktopHeight
Global $colors, $MinRadius, $MaxRadius, $MinSpeed, $MaxSpeed, $StartColor, $EndColor, $colors, $BackGroundColor, $NumParticles, $MinShrinkSpeed, $MaxShrinkSpeed

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

If $CommandLine = "/s" Or Not @Compiled Then
    Opt("GUIOnEventMode", 1)
    GetSettings()

    $Form1 = GUICreate("Something like fire, by lokster", $width, $height, 0, 0, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
    GUISetCursor(16)
    GUISetBkColor($BackGroundColor, $Form1)
    GUISetState(@SW_SHOW)

    Global Const $pi = 3.1415926535897932384626433832795028841971693993751058209749445923078164062
    Global Const $degToRad = $pi / 180

    Global $DC = DllCall($USER32, "hwnd", "GetDC", "hwnd", $Form1)
    
    
; create memory DC with size = size of client area of main  window
    Global $client_rect = WinGetClientSize($Form1)
    Global $memory_dc = DllCall($GDI32, "hwnd", "CreateCompatibleDC", "hwnd", $DC[0])
    Global $memory_bm = DllCall($GDI32, "hwnd", "CreateCompatibleBitmap", _
            "ptr", $DC[0], _
            "int", $client_rect[0], _
            "int", $client_rect[1])

    DllCall($GDI32, "hwnd", "SelectObject", "hwnd", $memory_dc[0], "hwnd", $memory_bm[0])

    Dim $particles[$NumParticles][7]

    Global $rect = DllStructCreate("long;long;long;long;")
    DllStructSetData($rect, 1, 0)
    DllStructSetData($rect, 2, 0)
    DllStructSetData($rect, 3, $width)
    DllStructSetData($rect, 4, $height)

    For $i = 0 To $NumParticles - 1
        RandomizeParticle($i)
    Next

    Global $brush = DllCall($GDI32, "hwnd", "CreateSolidBrush", "int", $BackGroundColor)
    
    GUISetOnEvent($GUI_EVENT_CLOSE, "Bye")
    GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "Bye")
    
;~  $start = TimerInit()
;~  Global $frame = 0
    While 1
        DrawParticles()
;~      WinSetTitle($Form1, "", $frame / (TimerDiff($start) / 1000))
;~      $frame += 1
    WEnd

ElseIf $CommandLine == "/c" Then
    Opt("GUIOnEventMode", 1)
    #Region ### START Koda GUI section ### Form=D:\lokster\autoit\fire-screensaver\v0.2\config.kxf
    $Form1 = GUICreate("(Something like) Fire configuration", 271, 337, 268, 253)
    $Group3 = GUICtrlCreateGroup("Particle colors", 8, 160, 257, 65)
    $gradient1 = GUICtrlCreateLabel("", 40, 184, 192, 25)
    $btnParticleStartColor = GUICtrlCreateButton(">", 16, 184, 19, 26, 0)
    GUICtrlSetOnEvent($btnParticleStartColor, "btnParticleStartColorClick")
    $btnParticleEndColor = GUICtrlCreateButton("<", 238, 184, 19, 26, 0)
    GUICtrlSetOnEvent($btnParticleEndColor, "btnParticleEndColorClick")
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Group4 = GUICtrlCreateGroup("Background color", 8, 232, 257, 65)
    $lBackgroundColor = GUICtrlCreateLabel("", 40, 256, 192, 25)
    GUICtrlSetBkColor($lBackgroundColor, 0x000000)
    GUICtrlSetOnEvent($lBackgroundColor, "lBackgroundColorClick")
    GUICtrlSetCursor($lBackgroundColor, 0)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $btnOk = GUICtrlCreateButton("Ok", 8, 304, 75, 25, 0)
    GUICtrlSetOnEvent($btnOk, "btnOkClick")
    $btnCancel = GUICtrlCreateButton("Cancel", 190, 304, 75, 25, 0)
    GUICtrlSetOnEvent($btnCancel, "btnCancelClick")
    $Group2 = GUICtrlCreateGroup("Particles", 8, 8, 257, 145)
    $iMinSpeed = GUICtrlCreateInput("", 24, 40, 65, 21)
    $iMaxSpeed = GUICtrlCreateInput("", 24, 80, 65, 21)
    $Label3 = GUICtrlCreateLabel("Min speed", 24, 24, 53, 14)
    $Label4 = GUICtrlCreateLabel("Max speed", 24, 64, 56, 14)
    $Label1 = GUICtrlCreateLabel("Min radius", 96, 24, 52, 14)
    $iMinRadius = GUICtrlCreateInput("", 96, 40, 65, 21)
    $Label2 = GUICtrlCreateLabel("Max radius", 96, 64, 55, 14)
    $iMaxRadius = GUICtrlCreateInput("", 96, 80, 65, 21)
    $iNumParticles = GUICtrlCreateInput("", 24, 120, 65, 21)
    $Label5 = GUICtrlCreateLabel("Count", 24, 104, 32, 14)
    $iMaxShrinkSpeed = GUICtrlCreateInput("", 168, 80, 65, 21)
    $iMinShrinkSpeed = GUICtrlCreateInput("", 168, 40, 65, 21)
    $Label6 = GUICtrlCreateLabel("Min shrink speed", 168, 24, 84, 14)
    $Label7 = GUICtrlCreateLabel("Max shrink speed", 168, 64, 87, 14)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $lokster = GUICtrlCreateLabel("(c) 2007 by lokster", 91, 310, 91, 17)
    GUICtrlSetColor($lokster, 0xFF0000)
    GUICtrlSetOnEvent($lokster, "loksterClick")
    GUICtrlSetCursor($lokster, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    GUISetOnEvent($GUI_EVENT_CLOSE, "btnCancelClick")
    GetSettings()
    InitDialog()
    
    While 1
        Sleep(100)
    WEnd
EndIf

#region config dialog functions
Func InitDialog()
    GUICtrlSetData($iMinRadius, $MinRadius)
    GUICtrlSetData($iMaxRadius, $MaxRadius)
    GUICtrlSetData($iMinSpeed, $MinSpeed)
    GUICtrlSetData($iMaxSpeed, $MaxSpeed)
    GUICtrlSetData($iMinShrinkSpeed, $MinShrinkSpeed)
    GUICtrlSetData($iMaxShrinkSpeed, $MaxShrinkSpeed)
    GUICtrlSetData($iNumParticles, $NumParticles)
    DrawGradient(GUICtrlGetHandle($gradient1), $colors)
    GUICtrlSetBkColor($lBackgroundColor, $BackGroundColor)
EndFunc  ;==>InitDialog

Func loksterClick()
    ShellExecute("http://www.autoitscript.com/forum/index.php?showuser=18476")
EndFunc  ;==>loksterClick

Func DrawGradient($hwnd, $aColors)
    Local $DC_Gradient = DllCall($USER32, "hwnd", "GetDC", "hwnd", $hwnd)
    $pos = WinGetClientSize($hwnd)
    
    For $i = 0 To $pos[0]
        $color_index = Int(($i / $pos[0]) * (UBound($aColors) - 1))
        Local $pen = DllCall($GDI32, "hwnd", "CreatePen", "int", "0", "int", $pos[0] / UBound($aColors), "int", $aColors[$color_index])
        DllCall($GDI32, "int", "MoveToEx", "hwnd", $DC_Gradient[0], "int", $i, "int", 0, "ptr", 0)
        DllCall($GDI32, "hwnd", "SelectObject", "hwnd", $DC_Gradient[0], "hwnd", $pen[0])
        DllCall($GDI32, "int", "LineTo", "hwnd", $DC_Gradient[0], "int", $i, "int", $pos[1])
        DllCall($GDI32, "hwnd", "DeleteObject", "hwnd", $pen[0])
    Next
    DllCall($USER32, "int", "ReleaseDC", "hwnd", $DC_Gradient[0], "hwnd", $hwnd)
EndFunc  ;==>DrawGradient

Func btnCancelClick()
    DllClose($USER32)
    DllClose($GDI32)
    Exit
EndFunc  ;==>btnCancelClick

Func btnOkClick()
    RegWrite("HKEY_CURRENT_USER\SOFTWARE\K&S tech.\(something like) fire", "MinRadius", "REG_SZ", GUICtrlRead($iMinRadius))
    RegWrite("HKEY_CURRENT_USER\SOFTWARE\K&S tech.\(something like) fire", "MaxRadius", "REG_SZ", GUICtrlRead($iMaxRadius))
    RegWrite("HKEY_CURRENT_USER\SOFTWARE\K&S tech.\(something like) fire", "MinSpeed", "REG_SZ", GUICtrlRead($iMinSpeed))
    RegWrite("HKEY_CURRENT_USER\SOFTWARE\K&S tech.\(something like) fire", "MaxSpeed", "REG_SZ", GUICtrlRead($iMaxSpeed))
    RegWrite("HKEY_CURRENT_USER\SOFTWARE\K&S tech.\(something like) fire", "StartColor", "REG_SZ", $StartColor)
    RegWrite("HKEY_CURRENT_USER\SOFTWARE\K&S tech.\(something like) fire", "EndColor", "REG_SZ", $EndColor)
    RegWrite("HKEY_CURRENT_USER\SOFTWARE\K&S tech.\(something like) fire", "BackGroundColor", "REG_SZ", $BackGroundColor)
    RegWrite("HKEY_CURRENT_USER\SOFTWARE\K&S tech.\(something like) fire", "NumParticles", "REG_SZ", GUICtrlRead($iNumParticles))
    RegWrite("HKEY_CURRENT_USER\SOFTWARE\K&S tech.\(something like) fire", "MinShrinkSpeed", "REG_SZ", GUICtrlRead($iMinShrinkSpeed))
    RegWrite("HKEY_CURRENT_USER\SOFTWARE\K&S tech.\(something like) fire", "MaxShrinkSpeed", "REG_SZ", GUICtrlRead($iMaxShrinkSpeed))
    DllClose($USER32)
    DllClose($GDI32)
    Exit
EndFunc  ;==>btnOkClick

Func btnParticleEndColorClick()
    Local $color = _ChooseColor(0, $EndColor)
    If $color >= 0 Then
        Global $EndColor = $color
        Global $colors = ColorGradient($StartColor, $EndColor, 0xFF)
        InitDialog()
    EndIf
EndFunc  ;==>btnParticleEndColorClick

Func btnParticleStartColorClick()
    Local $color = _ChooseColor(0, $StartColor)
    If $color >= 0 Then
        Global $StartColor = $color
        Global $colors = ColorGradient($StartColor, $EndColor, 0xFF)
        InitDialog()
    EndIf
EndFunc  ;==>btnParticleStartColorClick

Func lBackgroundColorClick()
    Local $color = _ChooseColor(0, $BackGroundColor)
    If $color >= 0 Then
        Global $BackGroundColor = $color
        InitDialog()
    EndIf
EndFunc  ;==>lBackgroundColorClick

Func _RegRead($keyname, $valuename, $default = "")
    Local $result = RegRead($keyname, $valuename)
    If $result == "" Then $result = $default
    Return $result
EndFunc  ;==>_RegRead

#endregion

Func GetSettings()
    Global $MinRadius = _RegRead("HKEY_CURRENT_USER\SOFTWARE\K&S tech.\(something like) fire", "MinRadius", 10)
    Global $MaxRadius = _RegRead("HKEY_CURRENT_USER\SOFTWARE\K&S tech.\(something like) fire", "MaxRadius", 40)
    Global $MinSpeed = _RegRead("HKEY_CURRENT_USER\SOFTWARE\K&S tech.\(something like) fire", "MinSpeed", 1)
    Global $MaxSpeed = _RegRead("HKEY_CURRENT_USER\SOFTWARE\K&S tech.\(something like) fire", "MaxSpeed", 10)
    Global $StartColor = _RegRead("HKEY_CURRENT_USER\SOFTWARE\K&S tech.\(something like) fire", "StartColor", 0x0000A0)
    Global $EndColor = _RegRead("HKEY_CURRENT_USER\SOFTWARE\K&S tech.\(something like) fire", "EndColor", 0x0050FF)
    Global $BackGroundColor = _RegRead("HKEY_CURRENT_USER\SOFTWARE\K&S tech.\(something like) fire", "BackGroundColor", 0x000000)
    Global $NumParticles = _RegRead("HKEY_CURRENT_USER\SOFTWARE\K&S tech.\(something like) fire", "NumParticles", 50)
    
    Global $MinShrinkSpeed = _RegRead("HKEY_CURRENT_USER\SOFTWARE\K&S tech.\(something like) fire", "MinShrinkSpeed", 1)
    Global $MaxShrinkSpeed = _RegRead("HKEY_CURRENT_USER\SOFTWARE\K&S tech.\(something like) fire", "MaxShrinkSpeed", 3)
    
    Global $colors = ColorGradient($StartColor, $EndColor, 0xFF)
EndFunc  ;==>GetSettings

Func RandomizeParticle($i)
    $particles[$i][0] = Random($MinRadius, $MaxRadius, 1); size
    $particles[$i][1] = $colors[Random(0x00, UBound($colors) - 1, 1) ]; color
    
    $particles[$i][2] = Random(0, $width, 1);x pos
    $particles[$i][3] = $height;y pos

    $particles[$i][4] = Random($MinSpeed, $MaxSpeed);y speed
    $particles[$i][5] = Random($MinShrinkSpeed, $MaxShrinkSpeed);shrink speed
    $particles[$i][6] = Random(0, $pi);phase
EndFunc  ;==>RandomizeParticle

Func DrawParticles()
    Local $ret = DllCall($USER32, "int", "FillRect", "hwnd", $memory_dc[0], "ptr", DllStructGetPtr($rect), "hwnd", $brush[0])
    For $i = 0 To $NumParticles - 1
        Local $pen = DllCall($GDI32, "hwnd", "CreatePen", "int", "0", "int", $particles[$i][0], "int", $particles[$i][1])
        Local $pen_old = DllCall($GDI32, "hwnd", "SelectObject", "hwnd", $memory_dc[0], "hwnd", $pen[0])
;       Local $x = Sin($particles[$i][6]+$frame/100)*$particles[$i][0]
        DllCall($GDI32, "int", "MoveToEx", "hwnd", $memory_dc[0], "int", $particles[$i][2], "int", $particles[$i][3], "ptr", 0)
        DllCall($GDI32, "int", "LineTo", "hwnd", $memory_dc[0], "int", $particles[$i][2], "int", $particles[$i][3])
        DllCall($GDI32, "hwnd", "SelectObject", "hwnd", $memory_dc[0], "hwnd", $pen_old[0])
        DllCall($GDI32, "hwnd", "DeleteObject", "hwnd", $pen[0])
        
        $particles[$i][3] -= $particles[$i][4];move up
        $particles[$i][0] -= $particles[$i][5]; decrease the size with 1.5px
        If $particles[$i][0] < 0 Then;if particle size is 0
            RandomizeParticle($i);give birth to a new particle;)
        EndIf
    Next
; copy changed content of memory DC back to Window DC
    
    DllCall($GDI32, "int", "BitBlt", _
            "hwnd", $DC[0], _
            "int", 0, _
            "int", 0, _
            "int", $client_rect[0], _
            "int", $client_rect[1], _
            "hwnd", $memory_dc[0], _
            "int", 0, _
            "int", 0, _
            "int", 0xCC0020)
EndFunc  ;==>DrawParticles


Func Bye()
    DllCall($GDI32, "hwnd", "DeleteObject", "hwnd", $brush[0])
    DllCall($GDI32, "hwnd", "DeleteObject", "hwnd", $memory_bm[0])
    DllCall($GDI32, "int", "DeleteObject", "hwnd", $memory_dc[0])
    DllCall($USER32, "int", "ReleaseDC", "hwnd", $DC[0], "hwnd", $Form1)
    DllClose($USER32)
    DllClose($GDI32)
    Global $rect = 0
    Exit
EndFunc  ;==>Bye

Func ColorGradient($hInitialColor, $hFinalColor, $iReturnSize)
    $hInitialColor = Hex($hInitialColor, 6)
    $hFinalColor = Hex($hFinalColor, 6)
    
    Local $iRed1 = Dec(StringLeft($hInitialColor, 2))
    Local $iGreen1 = Dec(StringMid($hInitialColor, 3, 2))
    Local $iBlue1 = Dec(StringMid($hInitialColor, 5, 2))
    
    Local $iRed2 = Dec(StringLeft($hFinalColor, 2))
    Local $iGreen2 = Dec(StringMid($hFinalColor, 3, 2))
    Local $iBlue2 = Dec(StringMid($hFinalColor, 5, 2))
    
    Local $iPlusRed = ($iRed2 - $iRed1) / ($iReturnSize - 1)
    Local $iPlusBlue = ($iBlue2 - $iBlue1) / ($iReturnSize - 1)
    Local $iPlusGreen = ($iGreen2 - $iGreen1) / ($iReturnSize - 1)
    
    Dim $iColorArray[$iReturnSize]
    For $i = 0 To $iReturnSize - 1
        $iNowRed = Floor($iRed1 + ($iPlusRed * $i))
        $iNowBlue = Floor($iBlue1 + ($iPlusBlue * $i))
        $iNowGreen = Floor($iGreen1 + ($iPlusGreen * $i))
        $iColorArray[$i] = Dec(Hex($iNowRed, 2) & Hex($iNowGreen, 2) & Hex($iNowBlue, 2))
    Next
    Return ($iColorArray)
EndFunc  ;==>ColorGradient
Edited by lokster
Link to comment
Share on other sites

wow this is nice

I really gotta learn alot from ur stuff

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Link to comment
Share on other sites

That's a very nice effect. :rolleyes:

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

Nice script lokster.

Here is little optimized/corrected version:

- hidden cursor

- before deleteobject you must select original object

- GetStockObject can be outside while 1 loop, so DllCall($GDI32, "hwnd", "DeleteObject", "hwnd", $obj) in Bye() function now

About flickering look here

#NoTrayIcon
#include <GUIConstants.au3>

;~ Global Const $width HÌßÛØ[ÛÛÝ ÌÍÚZYÚHÛØ[ÛÛÝ  ÌÍÝÚYHÚÝÜvGF¤vÆö&Â6öç7Bb33c¶VvBÒFW6·F÷Vv@ ¤bb33c´6ÖDÆæU³ÒfwC²Q¡¸(ÀÌØí
½µµ¹1¥¹ôMÑÉ¥¹1Ð ÀÌØí
µ1¥¹lÅt°È¤)±Í(ÀÌ;CommandLine = "/c"
EndIf

If $CommandLine = "/s" [Ü
    ][ÝÑÕRSÛ][[ÙI][ÝËJB  ÌÍÑÜLHHÕRPÜX]J    ]÷Cµ6öÖWFærƶRf&'Æö·7FW"gV÷C²Âb33c·vGFÂb33c¶VvBÂÂÂÀÌØí]M}A=AU@°  ¥Ñ=H ÀÌØí]M}a}Q=A5=MP°ÀÌØí]M}a}Q==1]%9=¤¤(U%MtOnEvent($GUI_EVENT_CLOSE, "Bye")
    GUISetOnEvent($GUWÑUSÓSÕTÑSSÕK ][ÝÐYI][ÝÊBQÕRTÙ]ÝÛÜMBÕRTÙ]Ý]JÕ×ÔÒõr ¢vÆö&Âb33c´tD3"ÒFÆÄ÷VâgV÷C¶vF3"æFÆÂgV÷C²¢vÆö&Âb3ØíUMHÌÈô±±=Á¸ ÅÕ½ÐíÕÍÈÌȹ±°ÅÕ½Ðì¤(±½°ÀÌØíô±±
±° 36;USER32, "int", "GetDC", "hwnd", $FormJB ÌÍÑÈH   ÌÍÑÖÌBÕRTÙ]ÐÛÛÜ  ÌÍÑÜLJBvÆö&Âb33c¶çVÕ÷'F6ÆW2Ò¢FÒb33c·'F6ÆW5²b33c¶çVÕ÷'F6ÆÍulÕt((±½°ÀÌØíÉÐô±±MÑÉÕÑ
ÉÑ ÅÕ½Ðí±½¹í±½¹í±½¹í±½¹ìÅot;)
    DllStructSetData($rect, 1, 0)
    DllStructSetData($rect
BÝXÝÙ]]J ÌÍÜXÝË ÌÍÝÚY
BÝXÝÙ]]b33c·&V7BÂBÂb33c¶VvB  ¢f÷"b33c¶ÒFòb33c¶çVÕ÷'F6ÆW2´Ä(I¹½µ¥éAÉÑ¥± ÀÌØí¤¤(9áÐ((±½°ÀÌØí½¨ô±±all($GDI32, "hwnd", "GetStockObject", "int&quÝË
NÈ
HPÒ×ÐTÒ ÌÍÛØH   ÌÍÛØÌBBÚ[HBG&u'F6ÆW2¢tVæ@ ¤VÇ6S¶7W'&VçFÇFW&R2æò6öæfwW&FöâFÆöp¢á¥Ð)¹%()Õ¹I¹½µ¥éAÉÑ¥± ÀÌØí¤¤(ÀÌØíÁÉÑ¥±ÍlÀÌØí¥ul] = Random(10, 30, 1); size
    $particles[$i][1] = BitShift(RandÛJ
LJKN
H
È[ÛJLJNÈÛÛÜ   ÌÍÜXÛÖÉ3c¶Õ³%ÒÒ&æFöÒÂb33c·vGF·÷0¢b33c·'F6ÆW5²b33c¶Õ³5ÒôÀÌØí¡¥¡ÐíäÁ½Ì(ÀÌØíÁÉÑ¥±ÍlÀÌØí¥ulÑtôI¹½´ Ä°Ô¤íäÍÁEndFunc  ;==>RandomizeParticle

Func DrawParticles()
    
    DllCall(&#ÍÕTÑTÌ    ][ÝÚ[ ][ÝË  ][ÝÑ[XÝ  ][ÝË  ][ÝÚÛ    ][ÝË  ÌÍÑ2ÂgV÷C·G"gV÷C²ÂFÆÅ7G'V7DvWEG"b33c·&V7BÂgV÷C¶væBgV÷C²Âb33c¶ö&¤((½ÈÀÌØí¤ôÀQ¼ÀÌØí¹Õµ}ÁÉÑ¥±Ì´Ä(1½°ÀÌØíAn = DllCall($GDI32, "hwnd", "CreatePen", "int][ÝË  ][ÝÌ  ][ÝË  ][ÝÚ[ ][ÝË  ÌÍÜXÛÖÉÌÍÚWVÌK    ][ÝÚçBgV÷C²Âb33c·'F6ÆW5²b33c¶Õ³Ò¢Æö6Âb33c·VåööÆBÒFÆÄ6Æ ÀÌØí$ÌÈ°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°ÅÕ½ÐíM±Ñ=©ÐÅÕ½Ðì°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°$DC, "hwnd", $Pen[0])
        DllCall($GDI32, &quoÚ[ ][ÝË  ][ÝÓ[ÝUÑ^   ][ÝË  ][ÝÚÛ    ][ÝË  ÌÍÑË    ][ÝÚ[ ][C²Âb33c·'F6ÆW5²b33c¶Õ³%ÒÂgV÷C¶çBgV÷C²Âb33c·'F6ÆW5²b33c¶Õ³t°ÅÕ½ÐíÁÑÈÅÕ½Ðì°À¤(±±
±° ÀÌØí$ÌÈ°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐíineTo", "hwnd", $DC, "int", $particles[&ÌÍÚWVÌK   ][ÝÚ[ ][ÝË  ÌÍÜXÛÖÉÌÍÚWVÌ×JBØ[
    3c´tD3"ÂgV÷C¶væBgV÷C²ÂgV÷Cµ6VÆV7Dö&¦V7BgV÷C²ÂgV÷C¶væBgV÷C²Âb3ÌØí°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°ÀÌØíÁ¹}½±lÁt¤(±±
±° ÀÌØí$ÌÈ°ÅÕt;hwnd", "DeleteObject", "hwnd", $Pen[0])
    ÌÍÜXÛÖÉÌÍÚWVÌ×HOH    ÌÍÜXÛÖÉÌÍÚWVÍNÛ[ÝRW¢b33c·'F6ÆW5²b33c¶Õ³ÒÓÒ²FV7&V6RFR6¦RvFãW%ÀÌØíÁÉÑ¥±ÍlÀÌØí¥ulÁt±ÐìÀQ¡¸í¥ÁÉÑ¥±Í¥é¥ÌÀ(         RandomizeParticle($i);give birth to a new particle;)
        [Y^[[ÈÏOIÝÑ]ÔXÛÂ[ÈYJ
BØ[
    ÌÍtD3"ÂgV÷C¶væBgV÷C²ÂgV÷C´FVÆWFTö&¦V7BgV÷C²ÂgV÷C¶væBgV÷C²Âb33c¶¨¤(±½°ÀÌØíÉÐôÀ(±±
±° ÀÌØíUMHÌÈ°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°Åot;ReleaseDC", "int", $DC, "hwnd", $FormJBÛÜÙJ   ÌÍÕTÑTÌBÛÜÙJ    ÌÍÑÑLÌB^][[ÈÏÒfwC´'
Link to comment
Share on other sites

Here is antiflicker optimized version :rolleyes:

all painting is done to hidden memory DC (bitmap) and finally whole picture is copied by BitBlt API to screen (window DC).

#NoTrayIcon
#include <GUIConstants.au3>

;~ Global Const $width HÌßÛØ[ÛÛÝ ÌÍÚZYÚHÛØ[ÛÛÝ  ÌÍÝÚYHÚÝÜvGF¤vÆö&Â6öç7Bb33c¶VvBÒFW6·F÷Vv@ ¤bb33c´6ÖDÆæU³ÒfwC²Q¡¸(ÀÌØí
½µµ¹1¥¹ôMÑÉ¥¹1Ð ÀÌØí
µ1¥¹lÅt°È¤)±Í(ÀÌ;CommandLine = "/c"
EndIf

If $CommandLine = "/s" [Ü
    ][ÝÑÕRSÛ][[ÙI][ÝËJB  ÌÍÑÜLHHÕRPÜX]J    ]÷Cµ6öÖWFærƶRf&'Æö·7FW"gV÷C²Âb33c·vGFÂb33c¶VvBÂÂÂÀÌØí]M}A=AU@°  ¥Ñ=H ÀÌØí]M}a}Q=A5=MP°ÀÌØí]M}a}Q==1]%9=¤¤(U%MtOnEvent($GUI_EVENT_CLOSE, "Bye")
    GUISetOnEvent($GUWÑUSÓSÕTÑSSÕK ][ÝÐYI][ÝÊBQÕRTÙ]ÝÛÜMBÕRTÙ]Ý]JÕ×ÔÒõr ¢vÆö&Âb33c´tD3"ÒFÆÄ÷VâgV÷C¶vF3"æFÆÂgV÷C²¢vÆö&Âb3ØíUMHÌÈô±±=Á¸ ÅÕ½ÐíÕÍÈÌȹ±°ÅÕ½Ðì¤(±½°ÀÌØíô±±
±° 36;USER32, "int", "GetDC", "hwnd", $FormJB ÌÍÑÈH   ÌÍÑÖÌBNÈÜX]HY[[ÜHÈÚ]Ú^HHÚ^HÙÛY[B&VöbÖâvæF÷p vÆö&Âb33c¶6ÆVçE÷&V7BÒvävWD6ÆVçE6¦Rb33c´f÷´Ä¤(%±½°ÀÌØíµµ½Éå}ô}
ÉÑ
½µÁÑ¥± ÀÌØí¤(%±½°ÀÌØíemory_bm = _CreateCompatibleBitmap( $DC, $client_rect[0], $cY[ÜXÝÌWJBWÔÙ[XÝØXÝ
    ÌÍÛY[[ÜWÙË    ÌÍÛY[[ÜWØJBÕRTÙ]&´6öÆ÷"Âb33c´f÷&Ó¢vÆö&Âb33c¶çVÕ÷'F6ÆW2Ò¢FÒÀÌØíÁÉÑ¥±ÍlÀÌØí¹Õµ}ÁÉÑ¥±ÍulÕt((±½°ÀÌØíÉÐô±±MÑÉÕÑ
eate("long;long;long;long;")
    DllStructSetData($rect, 1, 
BÝXÝÙ]]J ÌÍÜXÝ
BÝXÝÙ]]J ÌÍÜXÝÂb33c·vGF¢FÆÅ7G'V7E6WDFFb33c·&V7BÂBÂb33c¶VvB  ¢f÷"ÀÌØí¤ôÀQ¼ÀÌØí¹Õµ}ÁÉÑ¥±Ì´Ä(I¹½µ¥éAÉÑ¥± ÀÌØí¤¤( Next

    Global $obj = DllCall($GDI32, "hwnd", "Ù]ÝØÚÓØXÝ ][ÝË  ][ÝÚ[ ][ÝË
NÈ
HPÒ×ÐTÒ ÌÍÛØH   33c¶ö&¥³Ð ¢vÆR¢G&u'F6ÆW2¢tVæ@ ¤VÇ6S¶7W'&VçFǡɥ̹¼½¹¥ÕÉÑ¥½¸¥±½(á¥Ð)¹%()Õ¹I¹½µ¥éAÉÑ¥± ÀÌ;i)
    $particles[$i][0] = Random(10, 30, 1); size
    $parXÛÖÉÌÍÚWVÌWHH]ÚY
[ÛJ
LJKN
H
È[ÛJL²6öÆ÷ ¢b33c·'F6ÆW5²b33c¶Õ³%ÒÒ&æFöÒÂb33c·vGF·Ì(ÀÌØíÁÉÑ¥±ÍlÀÌØí¥ulÍtôÀÌØí¡¥¡ÐíäÁ½Ì(ÀÌØíÁÉÑ¥±Íl#036;i][4] = Random(1, 5);y speed
EndFunc  ;==>RandomizeParticle

Func D]ÔXÛÊ
BØ[
    ÌÍÕTÑTÌ    ][ÝÚ[ ][ÝË  ][ÝÑ[XBgV÷C²ÂgV÷C¶væBgV÷C²Âb33c¶ÖVÖ÷'öF2ÂgV÷C·G"gV÷C²ÂFÆÅ7G'V7DvWEG ÀÌØíÉФ°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°ÀÌØí½¨¤((½ÈÀÌØí¤ôÀQ¼ÀÌ;num_particles - 1
        Local $Pen = DllCall($GDI32, "hwn   ][ÝË  ][ÝÐÜX]T[][ÝË  ][ÝÚ[ ][ÝË  ][ÝÌ  ][ÝË  ][ÝÚ[ ]÷C²Âb33c·'F6ÆW5²b33c¶Õ³ÒÂgV÷C¶çBgV÷C²Âb33c·'F6ÆW5²b33c¶ÕÅt¤(1½°ÀÌØíÁ¹}½±ô±±
±° ÀÌØí$ÌÈ°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°Åot;SelectObject", "hwnd", $memory_dc, "hwnd", ÌÍÔ[ÌJBØ[
    ÌÍÑÑLÌ ][ÝÚ[ ][ÝË  ][ÝÓ[ÝUÑ^   V÷C²ÂgV÷C¶væBgV÷C²Âb33c¶ÖVÖ÷'öF2ÂgV÷C¶çBgV÷C²Âb33c·'F6ÆW5²ÀÌØí¥ulÉt°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØíÁÉÑ¥±ÍlÀÌØí¥ulÍt°ÅÕ½ÐíÁÑÈÅÕ½Ðì°)
        DllCall($GDI32, "int", "LineTo", "hÛ   ][ÝË  ÌÍÛY[[ÜWÙË    ][ÝÚ[ ][ÝË  ÌÍÜXÛÖÉÌÍÚWVÌK    V÷C¶çBgV÷C²Âb33c·'F6ÆW5²b33c¶Õ³5Ò¢FÆÄ6ÆÂb33c´tD3"Âg½Ðí¡Ý¹ÅÕ½Ðì°ÅÕ½ÐíM±Ñ=©ÐÅÕ½Ðì°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°ÀÌØíµµ½Éå}°"hwnd", $pen_old[0])
        DllCall($GDI32, "hwnd][ÝË ][ÝÑ[]SØXÝ  ][ÝË  ][ÝÚÛ    ][ÝË  ÌÍÔ[ÌJBb33c·'F6ÆW5²b33c¶Õ³5ÒÓÒb33c·'F6ÆW5²b33c¶Õ³EÓ¶Ö÷fRW¢ÀÌØíÁÉÑ¥±ÍlÀÌØí¥ulÁt´ôÄìÉÍÑ¡Í¥éÝ¥Ñ Ä¸ÕÁà( If $particles[$i][0] < 0 Then;if particle size is 0
         [ÛZ^TXÛJ ÌÍÚJNÙÚ]HÈH]ÈXÛNÊB[YæW@ ²6÷6ævVB6öçFVçBöbÖVÖ÷'D2&6²FòvæF÷rD0 ô&D&ÇBb3ÌØí°À°À°ÀÌØí±¥¹Ñ}ÉÑlÁt°ÀÌØí±¥¹Ñ}ÉÑlÅt°ÀÌØíµµ½Éå}°À 0)
EndFunc  ;==>DrawParticles


Func Bye()
    DllCall($GDI32, &quÝÚÛ   ][ÝË  ][ÝÑ[]SØXÝ  ][ÝË  ][ÝÚÛ    ][ÝË  ÌÍÛØBÛö&Âb33c·&V7BÒ¢FÆÄ6ÆÂb33cµU4U#3"ÂgV÷C¶çBgV÷C²ÂgV÷Cµ&VÆV6ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØí°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°ÀÌØí½É´Ä¤(±±lose($USER32)
    DllClose($GDI32)
    _DeleteObject( $memory_bJBWÑ[]QÊ  ÌÍÛY[[ÜWÙÊB^][[ÈÏOIÝÐYBÈOH[Ý[Ûg&öÒvF3"æS2ÓÐ ¤gVæ2ô7&VFT6ö×F&ÆTD2b33c¶F2Âb33c¶FÆÅöÒb33¤Ìȹ±°Ìäì¤(íø%¡ÑÑÀè¼½µÍ¸¹µ¥É½Í½Ð¹½´½±¥ÉÉ佸µÕ̽¤½Ù½¹Í|Ðäå.asp
    Local $ret = DllCall( $dll_h, 'ptr', 'CreateCom]XQÉÌÎNË ÌÎNÜÌÎNË  ÌÍÚÊBT] ÌÍÜ]ÌB[[Â[ô7&VFT6ö×F&ÆT&FÖb33c¶F2Âb33c·rÂb33c¶Âb33c¶FÆÅöÒb33´v¤Ìȹ±°Ìäì¤(íø%¡ÑÑÀè¼½µÍ¸¹µ¥É½Í½Ð¹½´½±¥ÉÉ佸µÕ̽¤½¥ÑµÁÍ|Åá¹sp
    Local $ret = DllCall( $dll_h, 'ptr', 'CreateCompaXP]X   ÌÎNËÂIÌÎNÜÌÎNË    ÌÍÚËÂIÌÎNÚ[ ÌÎNË ÌÍÝËÂb33¶çBb33²Âb33c¶ &WGW&âb33c·&WE³Ð¤VæDgVæ0 ¤gVæ2ô&D&ÇBb33c¶ÍÑ¥¹Ñ¥½¹}¡°ÀÌØíÍÑ¥¹Ñ¥½¹}à°ÀÌØíÍÑ¥¹Ñ¥½¹}ä°ÀÌØíÍÑ¥¹Ñ¥½¹width, $destination_height, _
    $source_hdc, $source_x, &#036ÜÛÝÙWÞK   ÌÍØÛÙHHÐÌ    ÌÍÙÚH   ÌÎNÑÙLÌ    ÌÎNÊBßPÛÛ7Bb33cµ5$44õÒ43#£·âGG¢òö×6FâæÖ7&÷6ögBæ6öÒöÆ'&'öVâ×W2övF¥ÑµÁÍ|Áé¼¹ÍÀ(%1½°ÀÌØíÉÐô±±
±° ÀÌØí±±} °Ìäí¥¹ÐÌäì°9;BitBlt', _
    'ptr', $destination_hdc, _
    'int', &ÌÍÙÝ[][ÛÞÂIÌÎNÚ[  ÌÎNË ÌÍÙÝ[][ÛÞKÂIÌÎNÚ[ ÌÎNËb33c¶FW7FæFöå÷vGFÂð b33¶çBb33²Âb33c¶FW7FæFöåöVvBÂð b3äíÁÑÈÌäì°ÀÌØíͽÕÉ}¡°|($Ìäí¥¹ÐÌäì°ÀÌØíͽÕÉ}à°|($Ìäí¥¹Ð#39;, $source_y, _
    'int', $code)
    Return $ret[0]
En[Â[ÈÔÙ[XÝØXÝ
    ÌÍÚË    ÌÍÚÙ[Ø ÌÍÙÚH   ÌÎNÑÙL"æFÆÂb33²£·âGG¢òö×6FâæÖ7&÷6ögBæ6öÒöÆ'&'öVâ×W2övFöFWf6öç5óc6òæ7(%1½°ÀÌØíÉÐô±±
±° ÀÌØí±±} °Ìäí¡Ý¹Ìäì°ÌäíM±Ñ=©Ð#39;, 'ptr', $hdc, 'hwnd', $hgdiobj)
    Return &#03Ü]ÌB[[Â[ÈÑ[]SØXÝ
    ÌÍÚØXÝ ÌÍÙÚH   ÌÎNÑÙL"æFÆÂb33²£·âGG¢òö×6FâæÖ7&÷6ögBæ6öÒöÆ'&'öVâ×W2övFöFWf6öç5óg6²æ7(%1½°ÀÌØíÉÐô±±
±° ÀÌØí±±} °Ìäí¥¹ÐÌäì°Ìäí±Ñ=©Ð39;, 'hwnd', $hObject)
    Return $ret[0]
EndFunc

Func _Del]QÊ   ÌÍÚË    ÌÍÙÚH   ÌÎNÑÙLÌ    ÌÎNÊBßZËÛÙZXÜÜÛgBæ6öÒöÆ'&'öVâ×W2övFöFWf6öç5ó'&"æ7 Æö6Âb33c·&WBÒFÆÄ6ÆÂb33c±±} °Ìäí¥¹ÐÌäì°Ìäí±ÑÌäì°ÌäíÁÑÈÌäì°ÀÌØí¡¤(%IÑÕɸ$ret[0]
EndFunc
Edited by Zedna
Link to comment
Share on other sites

Well done with the anti-flicker version. Really nice :rolleyes:

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

Thx Zedna :rolleyes: Now, with anti-flickering it has become a real screensaver :rambo:

However, I made some tweaks to it, and added configuration dialog.

First I converted my old DllCalls to functions - these that were inside the DrawParticles() function. But then I noticed that the script was running almost two times slower. This was strange. The same DllCalls, but separated in functions were slower than if I call them inline.

I mean, that calling _BitBlt(....) or something else, was slower than making DllCall($GDI32,"int","BitBlt"....).

So, I get rid of the functions from gdi32.au3, and now the script makes direct dllcalls and runs at fine speed.

Any ideas what caused this slowdown?

The new version is in the first post.

Link to comment
Share on other sites

The config options are nice. Although why does it pop up if selected in screensaver GUI (DIsplay Options) ?

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

Because you need to compile the script and then chenge the extension of the compiled script from .exe to .scr.

:Edit

I changed the script a little, so if it is not compiled, it allways opens the screensaver, not the configuration dialog.

First post updated.

Edited by lokster
Link to comment
Share on other sites

I did compile and rename to .scr, right clicked it and chose Install so as to make it selectable in Display Options as a screensaver, but after preview exited the config GUI would pop up. Your updated version fixes that whether or not you meant it to :rolleyes:

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

I like the new options, I can make particles appear for longer.

Also, change the main while loop to only

While 1
        DrawParticles()
    WEnd

To allow it to handle more particles easier.

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...