Jump to content

Snow on your desktop


Dellairion
 Share

Recommended Posts

Updated (without gui for now).

I'm still having the problem that the snow is erasing any

changes made to the desktop while the app is running (and i have no idea how to fix this).

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Description=Snow on your desktop
#AutoIt3Wrapper_Res_Fileversion=0.1.4.0
#AutoIt3Wrapper_Res_LegalCopyright=Dellairion
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

; Version 0.1.4
; By Dellairion
;
; Changelog:
; 0.1.4
;  - Added support for Windows versions before vista
;
; 0.1.3
;  - Snow stacks up now
;
; 0.1.2
;  - Added whirlfactor
;  - Snow will now stay at the bottom


; INCLUDES
#Include <Misc.au3>
#include <Array.au3>
#include <Constants.au3>
#include <GUIListBox.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include "includes\prospeed30.au3"
_Singleton(@ScriptName); Only 1 instance may be active at the same time

; OPTIONS
Opt("GUICloseOnESC", 0)
Opt("GUIOnEventMode", 1)
Opt("OnExitFunc", "Quit")
;Opt("TrayMenuMode", 1)
;Opt("TrayOnEventMode", 1)


; VARIABLES F=pathtofile, P=path, S=system, LS=loadsprite, SP=sprite, IV=imagevar, A=array, L=rest
$S_OS = @OSVersion
$S_Username = @UserName
$F_Settings = "\settings.ini"
$S_Resolution_Width = @DesktopWidth ; add *2 if you have dual screen (cpu intensive)
$S_Resolution_Height = @DesktopHeight

$L_Snowflakes = 50 ; number of falling snow flakes at the same time (1-200)
$L_Whirlfactor = 15 ; X axis movement of snowflakes (0-30)
$L_Loopspeed = 10 ; can be compared with the cpu usage in % (1-100)
$L_Stackup = 25 ; snow stackup at the bottom (0-300)
;$L_Pixelsteps = 3 ; Amount of pixels between every refesh that the snowflake skip
$IV_Snowflakesize = 15 ; The size of 1 snowflake (to split them up out of the picture)
$IV_Snowflakecount = 12 ; The number of snowflakes in the image

If FileExists($F_Settings) Then
    $L_Snowflakes = IniRead($F_Settings, $S_Username, "Snowflakes", $L_Snowflakes)
    $L_Whirlfactor = IniRead($F_Settings, $S_Username, "Whirlfactor", $L_Whirlfactor)
    $L_Loopspeed = IniRead($F_Settings, $S_Username, "Loopspeed", $L_Loopspeed)
    $L_Stackup = IniRead($F_Settings, $S_Username, "Stackup", $L_Stackup)
    ;$L_Pixelsteps = IniRead($F_Settings, $S_Username, "PixelSteps", $L_Pixelsteps)
EndIf

Global $Stackup_Timer = TimerInit()
Global $L_Stackup_Current = 0
Global $A_Snowflakeslist[1]
$A_Snowflakeslist[0] = 0


;LOADIN SNOWFLAKES
$LS_Snowflakes = loadsprite("images\snow.bmp")
If $S_OS <> "WIN_VISTA" Then
    WinMinimizeAll()
    Sleep(250)
EndIf
$L_HDC = GetDesktopHDC()
;$L_HDC = GetWindowHDC()
CreateBuffer($S_Resolution_Width, $S_Resolution_Height)
SetBuffer($L_HDC)
;InitPixelEffects()



;MAIN LOOP
$i = 1
While 1
    Sleep(1000-$L_Loopspeed*10)
    R_Snowflakes()
WEnd




;FUNCTIONS C=create, D=delete, R=render, LA=add to list, LD=delete from list, S=set, RS=reset
Func R_Snowflakes()
    If $A_Snowflakeslist[0] < $L_Snowflakes Then C_Snowflake()
    
    $F_Waitstackup = 7 ; (3-10)
    $F_Stackuptime = StringReplace($S_Resolution_Width, "-", "")/$L_Snowflakes*$F_Waitstackup*1000
    
    $F_Respawned = 0
    $i = 1
    Do
        If GetSpriteY($A_Snowflakeslist[$i]) >= $S_Resolution_Height-Round($IV_Snowflakesize/2, 0)-$L_Stackup_Current Then ; HasSpriteArrived($A_Snowflakeslist[$i]) <- doesnt work for sprites in table mode
            If $L_Stackup > 0 Then
                If $L_Stackup_Current < $L_Stackup Then
                    SpriteToHDC($A_Snowflakeslist[$i])
                ElseIf TimerDiff($Stackup_Timer) < $F_Stackuptime Then
                    SpriteToHDC($A_Snowflakeslist[$i])
                EndIf
            EndIf
            
            Sleep(Round($L_Snowflakes/3+20, 0))
            D_Snowflake($A_Snowflakeslist[$i])
            ;If $F_Respawned < $L_Snowflakes/10+1 Then RS_Snowflake($A_Snowflakeslist[$i])
            
            If $A_Snowflakeslist[0] < $L_Snowflakes And $F_Respawned < $L_Snowflakes/10+1 Then C_Snowflake()
            $F_Respawned += 1
        Else
            $i += 1
        EndIf
    Until $i >= $A_Snowflakeslist[0]
    
    If TimerDiff($Stackup_Timer) >= $F_Stackuptime And $L_Stackup_Current < $L_Stackup Then
        $L_Stackup_Current += 2
        $Stackup_Timer = TimerInit()
    EndIf
EndFunc


Func C_Snowflake()
    $F_Snowflaketype = Random(0, $IV_Snowflakecount-1, 1)
    $F_Snowflakespeed = Random(1, 3, 1)
    $F_Snowflakestartx = Random(-$IV_Snowflakesize+1, $S_Resolution_Width-1, 1)
    $F_SpriteID = sprite($LS_Snowflakes, $L_HDC, $F_Snowflaketype*$IV_Snowflakesize, 0, $IV_Snowflakesize, $IV_Snowflakesize, 1, 1, 1, $F_Snowflakestartx, -$IV_Snowflakesize-1)
    
    setspritespeed($F_SpriteID, $F_SnowflakeSpeed, $F_SnowflakeSpeed)
    ;movesprite($F_SpriteID, $F_Snowflakestartx, $S_Resolution_Height-Round($IV_Snowflakesize/2, 0))
    S_Whirlfactor($F_SpriteID)
    LA_Snowflake($F_SpriteID)
    
    $A_Snowflakeslist[0] += 1
EndFunc


Func D_Snowflake($F_SpriteID)
    MarkSprite($F_SpriteID, 1)
    DeleteSprite($F_SpriteID)
    LD_Snowflake($F_SpriteID)
    cleanup(1)
    
    $A_Snowflakeslist[0] -= 1
EndFunc

#cs
Func RS_Snowflake($F_SpriteID) ; weard
    $F_Snowflaketype = Random(0, $IV_Snowflakecount-1, 1)
    $F_Snowflakespeed = Random(1, 3, 1)
    $F_Snowflakestartx = Random(-$IV_Snowflakesize+1, $S_Resolution_Width-1, 1)
    
    SetSpritePos($F_SpriteID, $F_Snowflakestartx, -$IV_Snowflakesize-1, $F_Snowflakestartx, -$IV_Snowflakesize-1)
    SetSpriteAnim($F_SpriteID, $F_Snowflaketype*$IV_Snowflakesize, 0, $IV_Snowflakesize, $IV_Snowflakesize, 1, 1, 1)
    SetSpriteSpeed($F_SpriteID, $F_Snowflakespeed, $F_Snowflakespeed)
    S_Whirlfactor($F_SpriteID)
EndFunc
#ce

Func LA_Snowflake($F_SpriteID)
    _ArrayAdd($A_Snowflakeslist, $F_SpriteID)
EndFunc


Func LD_Snowflake($F_SpriteID)
    _ArrayDelete($A_Snowflakeslist, _ArraySearch($A_Snowflakeslist, $F_SpriteID))
EndFunc


Func S_Whirlfactor($F_SpriteID)
    $X = GetSpriteX($F_SpriteID)
    $Y = GetSpriteY($F_SpriteID)
    $Y_End = $S_Resolution_Height-Round($IV_Snowflakesize/2, 0)-$L_Stackup_Current
    
    If $L_Whirlfactor = 0 Then
        movesprite($F_SpriteID, $X, $Y_End)
    Else
        $X2 = $X
        $X_Movement_Prev = 0
        $F_Stepsize = 50
        $F_Table = $X&" "&$Y
        For $i = $Y+$F_Stepsize To $Y_End-$F_Stepsize Step $F_Stepsize
            $X_Movement = Random($X_Movement_Prev-5, $X_Movement_Prev+5, 1)
            If $X_Movement > $L_Whirlfactor Then $X_Movement = $L_Whirlfactor
            If $X_Movement < -$L_Whirlfactor Then $X_Movement = -$L_Whirlfactor
            
            $F_Table &= " "&$X2+$X_Movement&" "&$i
            
            $X2 = $X2+$X_Movement
            $X_Movement_Prev = $X_Movement
        Next
        $F_Table &= " "&$X2&" "&$Y_End
        
        SpriteTableMode($F_SpriteID, 1)
        SetSpriteMovingMode($F_SpriteID, 1)
        ;movesprite($F_SpriteID, $X, $Y_End) ; lol
        MoveSpriteWithTable($F_SpriteID, $F_Table)
    EndIf
EndFunc


;Func HasSpriteWithTableArrived($F_SpriteID)
;   
;EndFunc


Func Quit()
    DeleteAllSprites()
    DestroyBuffer()
    ControlSend("Program Manager", "", "", "{F5}")
    Exit
EndFunc

Package (with required image and prospeed included)

Snow_Desktop.rar

Dellairion

Edited by Dellairion
Link to comment
Share on other sites

  • Replies 62
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

As far as I can see, there will be no way to fix the fickering problem. You best idea is to make a gif of snowflakes falling and us GuiCtrlCreatePic() to place it on your gui. You will want to use @desktopWidth and @DesktopHeight in both cases.

The flickering can be slowed down by reducing the speed in the fall of snowflakes but that will cause other problems including a lag like effect.

You could also try using an * mark set to white with a size of 13. That shouldnt flicker at all but your graphics will be lower.

Hope this helps. :)

Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 
Link to comment
Share on other sites

You could also try using an * mark set to white with a size of 13. That shouldnt flicker at all but your graphics will be lower.

lol nice idea but not what i'm looking for ^_^

Try using this:

CODEControlMove($GUI_Snow, '', $Snowflake, $Snowflake_X, $Snowflake_y)

Instead of

CODEGUICtrlSetPos($Snowflake, $Snowflake_X, $Snowflake_Y)

There doesn't seem to much difference, but I think there is some.

k thanks i'll use it :)

Is it maybe possible to stop the gui from refreshing everytime the snowflake goes some pixels downwards so only he control itself will be refreshing?

Hmms or maybe i should use a seprate gui for every snowflake? :)

Link to comment
Share on other sites

I've tryed it with sprites like this:

; GUI SNOW
$GUI_Snow = GUICreate("Snow", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_LAYERED)
$L_SnowBackground = GUICtrlCreateLabel("", 0, 0, @DesktopWidth, @DesktopHeight)
GUICtrlSetBkColor($L_SnowBackground, 0xff00ff)
;GUICtrlSetState(@SW_LOCK, $GUI_Snow)
;GUISetState(@SW_DISABLE, $GUI_Snow)
GUISetState(@SW_SHOW, $GUI_Snow)
Background("", 0, 0, @DesktopWidth, @DesktopHeight)
DllCall("user32.dll", "long", "SetLayeredWindowAttributes", "hwnd", $GUI_Snow, "long", 0x00ff00ff, "long", 255, "long", 1)
;LoadImage(@ScriptDir&"\Files\snowflake13.gif", 0, 0, 0, 0, 1)
$Snowflake_Load = loadsprite(@ScriptDir&"\Files\snowflake13.gif")
$Snowflake = Sprite($Snowflake_Load, 0, 0, 15, 15, 1, 1, 0, $Snowflake_X, $Snowflake_Y)
;WinSetOnTop($GUI_Snow, "", 1)
; END GUI SNOW

It works but if i move a window it's going really slow

If you had something else in mind please post :)

Link to comment
Share on other sites

#include <Prospeed.au3>

HotKeySet("{Esc}","_Exit")
WinMinimizeAll()

screencopie()

$M_load = loadsprite("snowflake14.gif")

Dim $sp[50]
For $i = 1 to 49
    $sp[$i] = sprite($M_load, 0, 0, 15, 15, 1, 1, 1, Random(1,1024,1), Random(0,200,1))
    setspritespeed($sp[$i],Random(1,2,1),Random(1,2,1))
    $x = GetSpriteX($sp[$i])
    movesprite($sp[$i], $x, 800)
    Sleep(250)
Next


While 1
    For $i = 1 to 49
        $hasarrived = HasSpriteArrived($sp[$i])
        If $hasarrived = 1 Then
            deletesprite($sp[$i])
            $sp[$i] = sprite($M_load, 0, 0, 15, 15, 1, 1, 1, Random(1,1024,1), Random(0,10,1))
            setspritespeed($sp[$i],Random(1,2,1),Random(1,2,1))
            $x = GetSpriteX($sp[$i])
            movesprite($sp[$i], $x, 800)
        EndIf   
    Next
    Sleep(20)
WEnd

Func _Exit()
   Exit
EndFunc

Edited by jpam
Link to comment
Share on other sites

...i press ok & how comes nothing happens ?How to use this?

C:\Documents and Settings\......\Desktop\Prospeed.au3 (763) : ==> Subscript used with non-Array variable.: 
DllCall($S_DLL, "long","CopyExtBmp", "long", $S_fensterkopie1[0], "long", 0, "long", 0, "long", @DesktopWidth, "long", @DesktopHeight, "long", $hDC, "long", 0, "long", 0, "long", 0) 
DllCall($S_DLL, "long","CopyExtBmp", "long", $S_fensterkopie1^ ERROR

its aint working..

Edited by goldenix
My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
Share on other sites

You will need the "dll" file located here

http://www.autoitscript.com/forum/index.ph...st&p=286823

put this is the same folder as the script above

8)

Aha is see, pretty interesting, its just needs a 3D effect & it will b pretty nice.

Yet i see that, the longer it runs, the more Memory it consumes....this makes it pretty useless, well unless I write another exe, that will start & turn it off lets say each 5 min.

:)

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
Share on other sites

#include <Prospeed.au3>

HotKeySet("{Esc}","_Exit")
WinMinimizeAll()

screencopie()

$M_load = loadsprite("snowflake14.gif")

Dim $sp[400]
For $i = 1 to 49
    $sp[$i] = sprite($M_load, 0, 0, 15, 15, 1, 1, 1, Random(1,1024,1), Random(0,200,1))
    setspritespeed($sp[$i],Random(1,2,1),Random(1,2,1))
    $x = GetSpriteX($sp[$i])
    movesprite($sp[$i], $x, 800)
    Sleep(250)
Next


While 1
    For $i = 1 to 49
        $hasarrived = HasSpriteArrived($sp[$i])
        If $hasarrived = 1 Then
            MarkSprite($sp[$i],1)
            deletesprite($sp[$i])
            cleanup(1)
            $sp[$i] = sprite($M_load, 0, 0, 15, 15, 1, 1, 1, Random(1,1024,1), Random(0,10,1))
            setspritespeed($sp[$i],Random(1,2,1),Random(1,2,1))
            $x = GetSpriteX($sp[$i])
            movesprite($sp[$i], $x, 800)
        EndIf   
    Next
    Sleep(20)
WEnd

Func _Exit()
   Exit
EndFunc

no memory comsuming anymore :)

Link to comment
Share on other sites

#include <Prospeed.au3>

HotKeySet("{Esc}","_Exit")
WinMinimizeAll()

screencopie()

$M_load = loadsprite("snow.bmp")

Dim $sp[400]
Dim $format[4]
$format[1] = 0
$format[2] = 27
$format[3] = 54

For $i = 1 to 49
    $r = Random(1,3,1)
    $sp[$i] = sprite($M_load, $format[$r], 0, 27, 27, 1, 1, 1, Random(1,1024,1), Random(0,200,1))
    Select
        Case $r = 1
            setspritespeed($sp[$i],3,3)
        Case $r = 2
            setspritespeed($sp[$i],2,2)
        Case $r = 3 
            setspritespeed($sp[$i],1,1)
    EndSelect
    $x = GetSpriteX($sp[$i])
    movesprite($sp[$i], $x, 780)
    Sleep(250)
Next

While 1
    For $i = 1 to 49
        $hasarrived = HasSpriteArrived($sp[$i])
        If $hasarrived = 1 Then
            MarkSprite($sp[$i],1)
            deletesprite($sp[$i])
            cleanup(1)
            $r = Random(1,3,1)
            $sp[$i] = sprite($M_load, $format[$r], 0, 27, 27, 1, 1, 1, Random(1,1024,1), Random(0,10,1))
            If $r = 1 Then setspritespeed($sp[$i],3,3)
            If $r = 2 Then setspritespeed($sp[$i],2,2)
            If $r = 3 Then setspritespeed($sp[$i],1,1)
            $x = GetSpriteX($sp[$i])
            movesprite($sp[$i], $x, 780)
        EndIf   
    Next
    Sleep(20)
WEnd

Func _Exit()
   Exit
EndFunc

some snow in depth

sorry, i can't stop :)

snow.bmp

Link to comment
Share on other sites

yea, i know

sprites get a screencopie from the desktop

when a new window comes in front, they must get a new screencopie

i can fix that

but that's for tomorro :)

Watching and waiting! ^_^

... also, can you make them kinda "stack-up" a little at the bottom and lower corners, kinda like an window would appear???

8)

NEWHeader1.png

Link to comment
Share on other sites

Watching and waiting! ^_^

... also, can you make them kinda "stack-up" a little at the bottom and lower corners, kinda like an window would appear???

8)

hhmm........ please explain

"stack-up" ? dificult word for me

sorry, i'am a old man :)

Link to comment
Share on other sites

Maybe you fix this also:

with resolution 1280 x 1024 the snow falls like this:

Screen & snow* at first after we put Random(1,1280,1)

--------------------------------------

|**************************|

|**************************|

|**************************|

| stops falling hire |

| |

| |

| |

| |

| |

--------------------------------------

After a while

--------------------------------------

|**************************|

|**************************|

|**************************|

|**************************|

|**************************|

| stops falling hire |

| |

| |

--------------------------------------

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
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...