Jump to content

Another screensaver


lokster
 Share

Recommended Posts

Here is another screensaver made by me. This time - particles following lissajous curves.

Note: if there is a "presets" subfolder of the folder where the screensaver is installed, the screensaver will load random presets from this folder OR generate internal random preset, without saving it.

It choses randomly whether to load random preset from file or to generate random one internally.

IMPORTANT: the config files from versions before v20070628 does not work anymore corectly!

Screenshots

Config dialog:

Posted Image

Fullscreen:

Posted Image

Source:

lissajous.au3

CODE

#NoTrayIcon

#include <GUIConstants.au3>

#include <Math.au3>

#include <Misc.au3>

#include <File.au3>

Opt("GUIOnEventMode", 1)

Opt("ColorMode", 1) ; use BGR color mode - its easier if you use Windows GDI use BGR format

Global Const $pi = 3.1415926535

Global Const $degToRad = $pi / 180

Global $frame, $colors, $StartColor, $EndColor, $BackGroundColor, $NumParticles, $current_preset, $max_size, $randomize_interval

Global $x_amplitude1, $x_amplitude2, $x_frequency1, $x_frequency2, $x_phase1, $x_phase2

Global $y_amplitude1, $y_amplitude2, $y_frequency1, $y_frequency2, $y_phase1, $y_phase2

Global $parametersChange = False

Global $mode = 1

If UBound($CmdLine) > 1 Then

$Command = StringLeft($CmdLine[1], 2)

If $Command == "/c" Then

$mode = 0

ElseIf $Command == "/s" Then

$mode = 1

ElseIf $Command == "/p" Then

$mode = 2

EndIf

Else

If @Compiled Then $mode = 0

EndIf

Global $speed, $colors, $BackGroundColor, $x_amplitude1, $x_amplitude2, $x_frequency1, $x_frequency2, $x_phase1, $x_phase2, $y_amplitude1, $y_amplitude2, $y_frequency1, $y_frequency2, $y_phase1, $y_phase2, $NumParticles, $max_size

Global $GDI32 = DllOpen("gdi32.dll")

Global $USER32 = DllOpen("user32.dll")

Global $Display_width = DllCall($USER32, "int", "GetSystemMetrics", "int", 78);SM_CXVIRTUALSCREEN

$Display_width = $Display_width[0]

Global $Display_height = DllCall($USER32, "int", "GetSystemMetrics", "int", 79);SM_CYVIRTUALSCREEN

$Display_height = $Display_height[0]

Switch $mode ;0 - config, 1 - run, 2 - preview

Case 0

#region CONFIGURE the screensaver

#Region ### START Koda GUI section ### Form=D:\lokster\autoit\lissajous-screensaver\v0.2\config.kxf

Local $Form1 = GUICreate("Lissajous magic configuration (v.20070628)", 607, 303, 208, 303)

Local $Group2 = GUICtrlCreateGroup("Particles", 8, 0, 249, 193)

Local $iXAmplitude1 = GUICtrlCreateInput("", 32, 32, 65, 21)

Local $iXFrequency1 = GUICtrlCreateInput("", 104, 32, 65, 21)

Local $iXPhase1 = GUICtrlCreateInput("", 176, 32, 65, 21)

Local $iYAmplitude1 = GUICtrlCreateInput("", 32, 56, 65, 21)

Local $iYFrequency1 = GUICtrlCreateInput("", 104, 56, 65, 21)

Local $iYPhase1 = GUICtrlCreateInput("", 176, 56, 65, 21)

Local $iXAmplitude2 = GUICtrlCreateInput("", 32, 96, 65, 21)

Local $iXFrequency2 = GUICtrlCreateInput("", 104, 96, 65, 21)

Local $iXPhase2 = GUICtrlCreateInput("", 176, 96, 65, 21)

Local $iYAmplitude2 = GUICtrlCreateInput("", 32, 120, 65, 21)

Local $iYFrequency2 = GUICtrlCreateInput("", 104, 120, 65, 21)

Local $Label3 = GUICtrlCreateLabel("Amplitude1 %", 32, 16, 67, 14)

Local $iYPhase2 = GUICtrlCreateInput("", 176, 120, 65, 21)

Local $iNumParticles = GUICtrlCreateInput("", 32, 160, 65, 21)

Local $iMaxSize = GUICtrlCreateInput("", 104, 160, 65, 21)

Local $Label1 = GUICtrlCreateLabel("Frequency1", 104, 16, 60, 14)

Local $Label5 = GUICtrlCreateLabel("Particle count", 32, 144, 69, 14)

Local $Label6 = GUICtrlCreateLabel("Amplitude2 %", 32, 80, 67, 14)

Local $Label2 = GUICtrlCreateLabel("Frequency2", 104, 80, 60, 14)

Local $Label8 = GUICtrlCreateLabel("Phase1 x100", 176, 16, 66, 14)

Local $Label9 = GUICtrlCreateLabel("Phase2 x100", 176, 80, 66, 14)

Local $Label12 = GUICtrlCreateLabel("X", 16, 37, 12, 17)

GUICtrlSetFont($Label12, 8, 800, 0, "MS Sans Serif")

Local $Label13 = GUICtrlCreateLabel("Y", 16, 60, 12, 17)

GUICtrlSetFont($Label13, 8, 800, 0, "MS Sans Serif")

Local $Label15 = GUICtrlCreateLabel("X", 16, 101, 12, 17)

GUICtrlSetFont($Label15, 8, 800, 0, "MS Sans Serif")

Local $Label16 = GUICtrlCreateLabel("Y", 16, 124, 12, 17)

GUICtrlSetFont($Label16, 8, 800, 0, "MS Sans Serif")

Local $btnRandomizePreset = GUICtrlCreateButton("Randomize", 176, 160, 67, 21, 0)

GUICtrlSetOnEvent($btnRandomizePreset, "btnRandomizePresetClick")

Local $Label11 = GUICtrlCreateLabel("Max size %", 104, 144, 56, 14)

GUICtrlCreateGroup("", -99, -99, 1, 1)

Local $Group3 = GUICtrlCreateGroup("Particle colors", 8, 200, 121, 49)

Local $gradient1 = GUICtrlCreateLabel("", 40, 216, 56, 25)

Local $btnParticleStartColor = GUICtrlCreateButton(">", 16, 216, 19, 26, 0)

GUICtrlSetOnEvent($btnParticleStartColor, "btnParticleStartColorClick")

Local $btnParticleEndColor = GUICtrlCreateButton("<", 102, 216, 19, 26, 0)

GUICtrlSetOnEvent($btnParticleEndColor, "btnParticleEndColorClick")

GUICtrlCreateGroup("", -99, -99, 1, 1)

Local $Group4 = GUICtrlCreateGroup("Background color", 136, 200, 121, 49)

Local $lBackgroundColor = GUICtrlCreateLabel("", 168, 216, 56, 25)

GUICtrlSetBkColor($lBackgroundColor, 0x000000)

GUICtrlSetOnEvent($lBackgroundColor, "lBackgroundColorClick")

GUICtrlSetCursor($lBackgroundColor, 0)

GUICtrlCreateGroup("", -99, -99, 1, 1)

Local $Group1 = GUICtrlCreateGroup("Curve Preview", 264, 0, 337, 273)

Local $preview = GUICtrlCreateLabel("", 272, 24, 320, 240)

GUICtrlSetBkColor($preview, 0x000000)

GUICtrlCreateGroup("", -99, -99, 1, 1)

Local $btnOk = GUICtrlCreateButton("Ok", 8, 280, 59, 17, 0)

GUICtrlSetOnEvent($btnOk, "btnOkClick")

Local $btnCancel = GUICtrlCreateButton("Cancel", 72, 280, 59, 17, 0)

GUICtrlSetOnEvent($btnCancel, "btnCancelClick")

Local $lokster = GUICtrlCreateLabel("© 2007 by lokster", 507, 281, 91, 17)

GUICtrlSetColor($lokster, 0xFF0000)

GUICtrlSetOnEvent($lokster, "loksterClick")

GUICtrlSetCursor($lokster, 0)

Local $btnSave = GUICtrlCreateButton("Save", 136, 280, 59, 17, 0)

GUICtrlSetOnEvent($btnSave, "btnSaveClick")

Local $btnLoad = GUICtrlCreateButton("Load", 200, 280, 59, 17, 0)

GUICtrlSetOnEvent($btnLoad, "btnLoadClick")

Local $btnFullscreenPreview = GUICtrlCreateButton("Fullscreen Preview", 264, 280, 97, 17, 0)

GUICtrlSetOnEvent($btnFullscreenPreview, "btnFullscreenPreviewClick")

Local $iRandomPreset = GUICtrlCreateInput("10", 136, 254, 33, 21)

GUICtrlSetTip($iRandomPreset, "How often the preset changes. 0 is disabled")

Local $Label14 = GUICtrlCreateLabel("Change preset every", 8, 258, 102, 17)

Local $sec = GUICtrlCreateLabel("sec", 172, 257, 21, 17)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

$iXAmplitude1UpDown = GUICtrlCreateUpdown($iXAmplitude1)

$iYAmplitude1UpDown = GUICtrlCreateUpdown($iYAmplitude1)

$iXFrequency1UpDown = GUICtrlCreateUpdown($iXFrequency1)

$iYFrequency1UpDown = GUICtrlCreateUpdown($iYFrequency1)

$iNumParticlesUpDown = GUICtrlCreateUpdown($iNumParticles)

$iYAmplitude2UpDown = GUICtrlCreateUpdown($iYAmplitude2)

$iXAmplitude2UpDown = GUICtrlCreateUpdown($iXAmplitude2)

$iXFrequency2UpDown = GUICtrlCreateUpdown($iXFrequency2)

$iYFrequency2UpDown = GUICtrlCreateUpdown($iYFrequency2)

$iXPhase1UpDown = GUICtrlCreateUpdown($iXPhase1)

$iYPhase1UpDown = GUICtrlCreateUpdown($iYPhase1)

$iXPhase2UpDown = GUICtrlCreateUpdown($iXPhase2)

$iYPhase2UpDown = GUICtrlCreateUpdown($iYPhase2)

$iMaxSizeUpdown = GUICtrlCreateUpdown($iMaxSize)

#region update preview

GUICtrlSetOnEvent($iXAmplitude1UpDown, "parametersChange")

GUICtrlSetOnEvent($iYAmplitude1UpDown, "parametersChange")

GUICtrlSetOnEvent($iXFrequency1UpDown, "parametersChange")

GUICtrlSetOnEvent($iYFrequency1UpDown, "parametersChange")

GUICtrlSetOnEvent($iNumParticlesUpDown, "parametersChange")

GUICtrlSetOnEvent($iYAmplitude2UpDown, "parametersChange")

GUICtrlSetOnEvent($iXAmplitude2UpDown, "parametersChange")

GUICtrlSetOnEvent($iXFrequency2UpDown, "parametersChange")

GUICtrlSetOnEvent($iYFrequency2UpDown, "parametersChange")

GUICtrlSetOnEvent($iXPhase1UpDown, "parametersChange")

GUICtrlSetOnEvent($iYPhase1UpDown, "parametersChange")

GUICtrlSetOnEvent($iXPhase2UpDown, "parametersChange")

GUICtrlSetOnEvent($iYPhase2UpDown, "parametersChange")

GUICtrlSetOnEvent($iXAmplitude1, "parametersChange")

GUICtrlSetOnEvent($iYAmplitude1, "parametersChange")

GUICtrlSetOnEvent($iXFrequency1, "parametersChange")

GUICtrlSetOnEvent($iYFrequency1, "parametersChange")

GUICtrlSetOnEvent($iNumParticles, "parametersChange")

GUICtrlSetOnEvent($iYAmplitude2, "parametersChange")

GUICtrlSetOnEvent($iXAmplitude2, "parametersChange")

GUICtrlSetOnEvent($iXFrequency2, "parametersChange")

GUICtrlSetOnEvent($iYFrequency2, "parametersChange")

GUICtrlSetOnEvent($iXPhase1, "parametersChange")

GUICtrlSetOnEvent($iYPhase1, "parametersChange")

GUICtrlSetOnEvent($iXPhase2, "parametersChange")

GUICtrlSetOnEvent($iYPhase2, "parametersChange")

GUICtrlSetOnEvent($iMaxSize, "parametersChange")

GUICtrlSetOnEvent($iRandomPreset, "parametersChange")

#endregion

GUICtrlSetData($iRandomPreset, $randomize_interval)

$HWND = GUICtrlGetHandle($preview)

#endregion CONFIGURE the screensaver

Case 1

#region RUN the screensaver

Global $Form1 = GUICreate("Form1", $Display_width, $Display_height, 0, 0, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))

GUISetCursor(16)

GUISetState(@SW_SHOW)

Global $HWND = $Form1

#endregion RUN the screensaver

Case 2

Exit ; there are some issues with the preview, so it's disabled (for now)

#region PREVIEW the screensaver

If UBound($CmdLine) > 2 Then

Global $HWND = HWnd($CmdLine[2])

_Singleton("preview lissajous")

Else

Exit

EndIf

#endregion PREVIEW the screensaver

EndSwitch

Global $DC = DllCall($USER32, "hwnd", "GetDC", "hwnd", $HWND)

Global $client_rect = WinGetClientSize($HWND)

Global $rect = DllStructCreate("long;long;long;long;")

DllStructSetData($rect, 1, 0)

DllStructSetData($rect, 2, 0)

DllStructSetData($rect, 3, $client_rect[0])

DllStructSetData($rect, 4, $client_rect[1])

Global $client_rect1_div_100 = $client_rect[1] / 100

Global $x_max_radius = $client_rect[0] / 2

Global $y_max_radius = $client_rect[1] / 2

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])

If $mode == 1 Then GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "Bye")

GUISetOnEvent($GUI_EVENT_CLOSE, "Bye")

Global $randomize_interval = _RegRead("HKEY_CURRENT_USER\SOFTWARE\K&S tech.\lissajous magic", "randomize_interval", 10)

LoadConfig(@ScriptDir & "\lissajous.ini")

If $mode == 1 And $randomize_interval > 0 Then AdlibEnable("aRandomizeParams", $randomize_interval * 1000)

$start = TimerInit()

Global $frame = 0

Global $randomize = False

If $mode == 2 Then

While 1

$frame = TimerDiff($start) / $speed

If Not WinExists($HWND) Then Bye()

;I know that calling a function with so much params is not very readable, but... who cares? :rolleyes:

DrawParticles($DC, $memory_dc, $frame, $NumParticles, $BackGroundColor, $colors, $max_size, $x_amplitude1, $x_amplitude2, $x_frequency1, $x_frequency2, $x_phase1, $x_phase2, $y_amplitude1, $y_amplitude2, $y_frequency1, $y_frequency2, $y_phase1, $y_phase2)

WEnd

Else

While 1

$frame = TimerDiff($start) / $speed

If ($mode == 1 And __IsPressed(0x20)) Or $randomize Then

RandomizeParams(Random(0, 1, 1)) ;randomly select random file or internal random preset

ElseIf $parametersChange == True Then

parametersChange()

EndIf

DrawParticles($DC, $memory_dc, $frame, $NumParticles, $BackGroundColor, $colors, $max_size, $x_amplitude1, $x_amplitude2, $x_frequency1, $x_frequency2, $x_phase1, $x_phase2, $y_amplitude1, $y_amplitude2, $y_frequency1, $y_frequency2, $y_phase1, $y_phase2)

WEnd

EndIf

Func _RegRead($keyname, $valuename, $default = "")

Local $result = RegRead($keyname, $valuename)

If $result == "" Then $result = $default

Return $result

EndFunc ;==>_RegRead

Func aRandomizeParams()

$randomize = True

EndFunc ;==>aRandomizeParams

Func RandomizeParams($fromFile = 0)

If $fromFile == 1 Then

Local $list = _FileListToArray(@ScriptDir & "\presets", "*.ini", 1)

If UBound($list) > 1 Then

LoadConfig(@ScriptDir & "\presets\" & Random(1, UBound($list) - 1, 1))

Return True

EndIf

EndIf

Global $StartColor = Random(0, 0xFFFFFF, 1)

Global $EndColor = Random(0, 0xFFFFFF, 1)

Global $colors = ColorGradient($StartColor, $EndColor, 0xFF)

Global $BackGroundColor = 0x000000;Random(0, 0xFFFFFF)

Global $x_amplitude1 = Random(0, 50, 1)

Global $x_amplitude2 = Random(0, 50, 1)

Global $x_frequency1 = Random(0, 8, 1)

Global $x_frequency2 = Random(0, 8, 1)

Global $x_phase1 = 0

Global $x_phase2 = 0

Global $y_amplitude1 = Random(0, 50, 1)

Global $y_amplitude2 = Random(0, 50, 1)

Global $y_frequency1 = Random(0, 8, 1)

Global $y_frequency2 = Random(0, 8, 1)

Global $y_phase1 = 0

Global $y_phase2 = 0

Global $NumParticles = Random(1, 50, 1)

Global $max_size = 5

Global $speed = 200 * _Max(_Max(Int($x_frequency1), Int($x_frequency2)), _Max(Int($y_frequency1), Int($y_frequency2)))

$randomize = False

If $mode == 0 Then

UpdateConfigDialog()

EndIf

Global $x_amplitude1_div_100 = $x_amplitude1 / 100

Global $x_amplitude2_div_100 = $x_amplitude2 / 100

Global $y_amplitude1_div_100 = $y_amplitude1 / 100

Global $y_amplitude2_div_100 = $y_amplitude2 / 100

EndFunc ;==>RandomizeParams

Func UpdateConfigDialog()

GUICtrlSetBkColor($lBackgroundColor, $BackGroundColor)

GUICtrlSetBkColor($preview, $BackGroundColor)

GUICtrlSetData($iNumParticles, $NumParticles)

DrawGradient(GUICtrlGetHandle($gradient1), $colors)

GUICtrlSetData($iXAmplitude1, $x_amplitude1)

GUICtrlSetData($iXAmplitude2, $x_amplitude2)

GUICtrlSetData($iXFrequency1, $x_frequency1)

GUICtrlSetData($iXFrequency2, $x_frequency2)

GUICtrlSetData($iXPhase1, $x_phase1)

GUICtrlSetData($iXPhase2, $x_phase2)

GUICtrlSetData($iYAmplitude1, $y_amplitude1)

GUICtrlSetData($iYAmplitude2, $y_amplitude2)

GUICtrlSetData($iYFrequency1, $y_frequency1)

GUICtrlSetData($iYFrequency2, $y_frequency2)

GUICtrlSetData($iYPhase1, $y_phase1)

GUICtrlSetData($iYPhase2, $y_phase2)

GUICtrlSetData($iMaxSize, $max_size)

GUICtrlSetData($iRandomPreset, $randomize_interval)

EndFunc ;==>UpdateConfigDialog

Func LoadConfig($preset = "")

If Not FileExists($preset) Or $preset == "" Then

RandomizeParams()

Else

Global $StartColor = IniRead($preset, "preset", "StartColor", 0x000000)

Global $EndColor = IniRead($preset, "preset", "EndColor", 0xFFFFFF)

Global $colors = ColorGradient($StartColor, $EndColor, 0xFF)

Global $BackGroundColor = IniRead($preset, "preset", "BackGroundColor", 0x000000)

Global $NumParticles = IniRead($preset, "preset", "NumParticles", 50)

Global $x_amplitude1 = IniRead($preset, "preset", "x_amplitude1", 50)

Global $x_amplitude2 = IniRead($preset, "preset", "x_amplitude2", 50)

Global $x_frequency1 = IniRead($preset, "preset", "x_frequency1", 3)

Global $x_frequency2 = IniRead($preset, "preset", "x_frequency2", 2)

Global $x_phase1 = IniRead($preset, "preset", "x_phase1", 0)

Global $x_phase2 = IniRead($preset, "preset", "x_phase2", 0)

Global $y_amplitude1 = IniRead($preset, "preset", "y_amplitude1", 50)

Global $y_amplitude2 = IniRead($preset, "preset", "y_amplitude2", 50)

Global $y_frequency1 = IniRead($preset, "preset", "y_frequency1", 3)

Global $y_frequency2 = IniRead($preset, "preset", "y_frequency2", 3)

Global $y_phase1 = IniRead($preset, "preset", "y_phase1", 0)

Global $y_phase2 = IniRead($preset, "preset", "y_phase2", 0)

Global $max_size = IniRead($preset, "preset", "max_size", 5)

Global $speed = 200 * _Max(_Max(Int($x_frequency1), Int($x_frequency2)), _Max(Int($y_frequency1), Int($y_frequency2)))

EndIf

If $mode == 0 Then

UpdateConfigDialog()

EndIf

Global $x_amplitude1_div_100 = $x_amplitude1 / 100

Global $x_amplitude2_div_100 = $x_amplitude2 / 100

Global $y_amplitude1_div_100 = $y_amplitude1 / 100

Global $y_amplitude2_div_100 = $y_amplitude2 / 100

$current_preset = $preset

EndFunc ;==>LoadConfig

Func DrawParticles($DC, $memory_dc, $frame, $NumParticles, $BackGroundColor, $colors, $max_size, $x_amplitude1, $x_amplitude2, $x_frequency1, $x_frequency2, $x_phase1, $x_phase2, $y_amplitude1, $y_amplitude2, $y_frequency1, $y_frequency2, $y_phase1, $y_phase2)

Local $brush = DllCall($GDI32, "hwnd", "CreateSolidBrush", "int", $BackGroundColor)

DllCall($USER32, "int", "FillRect", "hwnd", $memory_dc[0], "ptr", DllStructGetPtr($rect), "hwnd", $brush[0])

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

DllCall($GDI32, "hwnd", "DeleteObject", "hwnd", $brush[0])

For $i = 1 To $NumParticles

Local $colorindex = Int(($i / $NumParticles) * (UBound($colors) - 1))

$i_ = $i * 3

Local $pen = DllCall($GDI32, "hwnd", "CreatePen", "int", "0", "int", $max_size * ($client_rect1_div_100) * ($i / $NumParticles), "int", $colors[$colorindex])

Local $pen_old = DllCall($GDI32, "hwnd", "SelectObject", "hwnd", $memory_dc[0], "hwnd", $pen[0])

Local $x = $x_max_radius + Sin($x_frequency1 * (($x_phase1 + $i_) / 100 + $frame)) * ($x_amplitude1_div_100) * $x_max_radius

Local $y = $y_max_radius + Cos($y_frequency1 * (($y_phase1 + $i_) / 100 + $frame)) * ($y_amplitude1_div_100) * $y_max_radius

$x += Sin($x_frequency2 * (($x_phase2 + $i_) / 100 + $frame)) * ($x_amplitude2_div_100) * $x_max_radius

$y += Cos($y_frequency2 * (($y_phase2 + $i_) / 100 + $frame)) * ($y_amplitude2_div_100) * $y_max_radius

DllCall($GDI32, "int", "MoveToEx", "hwnd", $memory_dc[0], "int", $x, "int", $y, "ptr", 0)

DllCall($GDI32, "int", "LineTo", "hwnd", $memory_dc[0], "int", $x, "int", $y)

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

DllCall($GDI32, "hwnd", "DeleteObject", "hwnd", $pen[0])

Next

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", $memory_bm[0])

DllCall($GDI32, "int", "DeleteObject", "hwnd", $memory_dc[0])

DllCall($USER32, "int", "ReleaseDC", "hwnd", $DC[0], "hwnd", $HWND)

Global $rect = 0

Exit

EndFunc ;==>Bye

Func OnAutoItExit()

DllClose($USER32)

DllClose($GDI32)

EndFunc ;==>OnAutoItExit

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)

Local $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

Func __IsPressed($hexKey)

Local $a_R = DllCall($USER32, "int", "GetAsyncKeyState", "int", $hexKey)

If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1

Return 0

EndFunc ;==>__IsPressed

Func parametersChange()

;X

Global $x_amplitude1 = GUICtrlRead($iXAmplitude1)

Global $x_amplitude2 = GUICtrlRead($iXAmplitude2)

Global $x_frequency1 = GUICtrlRead($iXFrequency1)

Global $x_frequency2 = GUICtrlRead($iXFrequency2)

Global $x_phase1 = GUICtrlRead($iXPhase1)

Global $x_phase2 = GUICtrlRead($iXPhase2)

;Y

Global $y_amplitude1 = GUICtrlRead($iYAmplitude1)

Global $y_amplitude2 = GUICtrlRead($iYAmplitude2)

Global $y_frequency1 = GUICtrlRead($iYFrequency1)

Global $y_frequency2 = GUICtrlRead($iYFrequency2)

Global $y_phase1 = GUICtrlRead($iYPhase1)

Global $y_phase2 = GUICtrlRead($iYPhase2)

Global $max_size = GUICtrlRead($iMaxSize)

Global $NumParticles = GUICtrlRead($iNumParticles)

Global $randomize_interval = GUICtrlRead($iRandomPreset)

Global $speed = 200 * _Max(_Max(Int($x_frequency1), Int($x_frequency2)), _Max(Int($y_frequency1), Int($y_frequency2)))

GUICtrlSetBkColor($preview, $BackGroundColor)

Global $colors = ColorGradient($StartColor, $EndColor, 0xFF)

Global $x_amplitude1_div_100 = $x_amplitude1 / 100

Global $x_amplitude2_div_100 = $x_amplitude2 / 100

Global $y_amplitude1_div_100 = $y_amplitude1 / 100

Global $y_amplitude2_div_100 = $y_amplitude2 / 100

$parametersChange = False

EndFunc ;==>parametersChange

Func btnCancelClick()

Bye()

EndFunc ;==>btnCancelClick

Func btnLoadClick()

$filename = FileOpenDialog("Choose a preset", $current_preset, "Presets (*.ini)", 2, $current_preset)

If Not @error Then

LoadConfig($filename)

UpdateConfigDialog()

EndIf

EndFunc ;==>btnLoadClick

Func btnOkClick()

RegWrite("HKEY_CURRENT_USER\SOFTWARE\K&S tech.\lissajous magic", "randomize_interval", "REG_SZ", $randomize_interval)

SavePreset()

Bye()

EndFunc ;==>btnOkClick

Func btnParticleEndColorClick()

Local $color = _ChooseColor(0, $EndColor)

If $color >= 0 Then

Global $EndColor = $color

Global $colors = ColorGradient($StartColor, $EndColor, 0xFF)

DrawGradient(GUICtrlGetHandle($gradient1), $colors)

$parametersChange = True

EndIf

EndFunc ;==>btnParticleEndColorClick

Func btnParticleStartColorClick()

Local $color = _ChooseColor(0, $StartColor)

If $color >= 0 Then

Global $StartColor = $color

Global $colors = ColorGradient($StartColor, $EndColor, 0xFF)

DrawGradient(GUICtrlGetHandle($gradient1), $colors)

$parametersChange = True

EndIf

EndFunc ;==>btnParticleStartColorClick

Func btnRandomizePresetClick()

$randomize = True

EndFunc ;==>btnRandomizePresetClick

Func btnFullscreenPreviewClick()

SavePreset()

If @Compiled Then

RunWait('"' & @ScriptFullPath & '" /s')

Else

RunWait('"' & @AutoItExe & '" "' & @ScriptFullPath & '" /s')

EndIf

EndFunc ;==>btnFullscreenPreviewClick

Func btnSaveClick()

Local $preset = FileSaveDialog("Save preset", @ScriptDir & "\presets", "Presets (*.ini)", 2, $current_preset)

If @error Then

Return False

EndIf

If Not StringRegExp($preset, "ini$") Then $preset &= ".ini"

SavePreset($preset)

EndFunc ;==>btnSaveClick

Func SavePreset($preset = "")

If $preset == "" Then $preset = @ScriptDir & "\lissajous.ini"

IniWrite($preset, "preset", "StartColor", $StartColor)

IniWrite($preset, "preset", "EndColor", $EndColor)

IniWrite($preset, "preset", "BackGroundColor", $BackGroundColor)

IniWrite($preset, "preset", "NumParticles", GUICtrlRead($iNumParticles))

IniWrite($preset, "preset", "x_amplitude1", $x_amplitude1)

IniWrite($preset, "preset", "y_amplitude1", $y_amplitude1)

IniWrite($preset, "preset", "x_frequency1", $x_frequency1)

IniWrite($preset, "preset", "y_frequency1", $y_frequency1)

IniWrite($preset, "preset", "x_phase1", $x_phase1)

IniWrite($preset, "preset", "y_phase1", $y_phase1)

IniWrite($preset, "preset", "x_amplitude2", $x_amplitude2)

IniWrite($preset, "preset", "y_amplitude2", $y_amplitude2)

IniWrite($preset, "preset", "x_frequency2", $x_frequency2)

IniWrite($preset, "preset", "y_frequency2", $y_frequency2)

IniWrite($preset, "preset", "x_phase2", $x_phase2)

IniWrite($preset, "preset", "y_phase2", $y_phase2)

IniWrite($preset, "preset", "max_size", $max_size)

$current_preset = $preset

Return $preset

EndFunc ;==>SavePreset

Func lBackgroundColorClick()

Local $color = _ChooseColor(0, $BackGroundColor)

If $color >= 0 Then

Global $BackGroundColor = $color

GUICtrlSetBkColor($lBackgroundColor, $BackGroundColor)

$parametersChange = True

EndIf

EndFunc ;==>lBackgroundColorClick

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

The script is not perfect... but it looks cool :x

I noticed that some people have difficulties understanding how to install this script as a screensaver. So, here are the instructions:

First, compile the au3 script to .exe by right clicking and selecting "Compile Script":

Posted Image

Then, rename the .exe to .scr:

Posted Image

And select "Yes":

Posted Image

Then, to configure the screensaver, right click and select "Configure" or to install it select "Install":

Posted Image

I hope now everyone will understand how to install it :rambo:

(I could easyly post the compiled .scr, but I dont like posting of executable files in this forum...)

Edited by lokster
Link to comment
Share on other sites

I love it!!!!!!! Have you ever considered using the [ codebox ] tag?

http://www.autoitking.co.nr Site is DOWN | My deviantART | No Topic Topic - Don't do it!-------------------- UDF's/Scripts:AutoIt: [BenEditor 3.6] [_ShutDown()]PHP: [CommentScript]Web Based AutoIt: [MemStats] [HTML to AU3] [User LogIn and SignUp script]
Link to comment
Share on other sites

@AutoItKing i am just too lazy to type the tag... :rolleyes:

I made several changes to the script - fixed some bugs, and added "Randomize" button in the config dialog, so you can easy generate new presets.

@Uriziel01 maybe I already fixed this...

Edited by lokster
Link to comment
Share on other sites

I don't even wanna study it it very nice

[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

Like Al Pacino in "Scent of a Woman" said, whoo-aa! :rolleyes:

Nice work. This will take some reading time to understand..

And all the work (a fully working screensaver) that has been done to get this - THANKS!

Local $x = $x_radius + Sin($x_frequency1 * (($x_phase1 + $i_) / 100 + $frame)) * ($x_amplitude1 / 100) * $x_radius
Local $y = $y_radius + Cos($y_frequency1 * (($y_phase1 + $i_) / 100 + $frame)) * ($y_amplitude1 / 100) * $y_radius
$x += Sin($x_frequency2 * (($x_phase2 + $i_) / 100 + $frame)) * ($x_amplitude2 / 100) * $x_radius
$y += Cos($y_frequency2 * (($y_phase2 + $i_) / 100 + $frame)) * ($y_amplitude2 / 100) * $y_radius

OMFG

Edit:

Global Const $pi = 3.1415926535897932384626433832795028841971693993751058209749445923078164062

Note that AutoIt strips everything past the tenth fraction (a nature of floats/doubles in C) so all this is not necessary...

Edited by zatorg
Link to comment
Share on other sites

Compile the script.

Then either run it with the parameter "/c" or put the compiled EXE (if you want it to load faster, make the compiler not to UPX it) into %windir%\system32 changing the extension from ".exe" to ".scr". Then go to "Display Properties" (ie right-click on Desktop and choose "Properties") -> Screen Saver -> Choose the one which name matches the freshly made .scr -> Click on "Settings".

Link to comment
Share on other sites

Note that AutoIt strips everything past the tenth fraction (a nature of floats/doubles in C) so all this is not necessary...

Yeah you are completely right... in the matter of fact, even if I define Global Const $pi = 3.14, it will do the trick... But I copyed this line of code from some other script (not mine) and didn't bother to change it... :rolleyes:

Btw, I made some updates/changes to the script.

Now, you don't need to save presets to the "presets" folder to get random presets showing. The screensaver generates internally random presets and changes them at interval that is specified in the configuration dialog.

However, if you create the presets subfolder, and save some presets in it, the screensaver will randomly select random preset from that folder or internally generate random preset.

AND when the screensaver is running, if you press {SPACE} it will load/generate random preset.

The script has grown big, and currently needs some major optimizations/changes that I plan to make.

So, don't be frustrated if you encounter some stupid bugs :rambo:

First post updated.

Link to comment
Share on other sites

lokster,

I like both of the screensavers you've made recently...they're quite nice! I have just one suggestion for both however: Instead of using @DesktopWidth and @DesktopHeight, you could instead include the below code, then use $VirtualDesktopWidth and $VirtualDesktopHeight instead so that folks (like me) with multiple monitors don't have half of their desktop left un-'savered'.

$VirtualDesktopWidth = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 78)

$VirtualDesktopWidth = $VirtualDesktopWidth[0]

$VirtualDesktopHeight = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", 79)

$VirtualDesktopHeight = $VirtualDesktopHeight[0]

I tried it on this screensaver of yours, and it works great. Alternately, you could also create a secondary GUI before that fills $VirtualDesktopWidth by $VirtualDesktopHeight and is a black, titleless window (create it first, so that the actual screensaver window is in front of this secondary window). That way, you can still use @DesktopWidth and @DesktopHeight to keep the area that I'm working with minimized, but still have the rest of the desktop covered.

Anyway, VERY nice, impressive job on this and the Fire screensaver...it's impressive to see pretty nice screensavers written in AutoIt, which isn't much in the way of a graphics-heavy language :rolleyes:

Edit: BTW, if you ever discover a method for creating a 'preview' function of the screensaver that shows up in the dialog where you select which screensaver to use, PLEASE PLEASE post it...it's the only thing I can't figure out how to do in AutoIt; the only thing standing between us and making 'full, real screensavers'. I came close once, but if the user moved the dialog while the preview was playing, the preview remained where it was...obviously less than ideal.

Keep it up!

Edited by james3mg
"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
Link to comment
Share on other sites

This is easy :whistle: I will explain it. When you open the windows screensaver configuration, to display the screensaver preview, windows starts the screensaver executable with the command line switch "/p 354543". The number 354543 here is just a random number, but in the real situation, it is actually the hWnd (as integer, not HEX) of the window where the preview must be displayed. Knowing the hwnd of this window, you can easy make somethng like this:

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 152, 112, 0, 0,$WS_POPUP)
$Label1 = GUICtrlCreateLabel("Hello world!", 0, 0)
GUISetOnEvent($GUI_EVENT_CLOSE, "Bye")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$USER32 = DllOpen("user32.dll")

If $CmdLine[0] > 0 Then
    If $CmdLine[1]=="/p" And UBound($CmdLine)>=3 Then
        $hWnd = HWnd($CmdLine[2])
        DllCall($USER32,"int","SetParent","hwnd",$Form1,"hwnd",$hWnd)
    EndIf
Else
    Exit
EndIf

While 1
    If Not WinExists($hWnd) Then Bye()
    Sleep(100)
WEnd

Func Bye()
    DllClose($USER32)
    Exit
EndFunc

This will make $Form1 child window of the screensaver preview window - it will move with it.

Remember that $Form1 must be with X,Y coordinates 0,0 and width and height must be 152x112. Thats it.

Simple, isn't it :lmao:

Currently I am making some MAJOR changes to my screensaver - better preview in the config, and some code optimisations - mainly cutting down the code to be as smaller as possible, without losing the current functionality.

Actually the changes are almost ready, I only need to test them. Expect update soon.

:EDIT

I almost totally rewrited the script. Now the preview in the configuration dialog shows how the real screensaver looks like.

Also, there is support for preview inside the windows screensaver configuration dialog, but it's currently disabled because of some issues...

First post updated.

Edited by lokster
Link to comment
Share on other sites

GREAT, thanks for your excellent example. I was trying to make my preview a child of the config window using AutoIt tags only, and it just didn't seem to be working at all. I'm most incredibly extremely bad at dll calls, so I didn't know this was what was needed.

Thanks again :whistle::cheer::lmao::cheer:

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
Link to comment
Share on other sites

I really like this screensaver, very fluid. Good Work :whistle:

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...