This is a demonstration script on how to make your own screensaver - screensaver is basicaly an exe-program, but renamed to *.scr extension.
- When we run the screensaver, or if we sellect Test (Check) Item from the context menu of the file, it executed with /S command line.
- When we sellect Options item from the context menu of the file, the screensaver executed with no command line passed.
- When we sellect Install item from the context menu of the file, the screensaver executed with /p first command line ($CmdLine), and a handle to DC (to show our preview in desktop properties dialog) is the second command line ($CmdLine).
- When we press the "Options" button from the screensaver properties dialog (right mouse button on the screensaver -> "Install" item), the /c: command passed to our script (screensaver).
And then we can run screensaver when it required, or we can show Options dialog, wich can be a simple GUI.
Here is an obstraction example on how we can make working screensaver:
#include <GuiConstants.au3> If $CmdLineRaw = "/S" Then ScreenSaver_Proc() ElseIf $CmdLine = 0 Or StringLeft($CmdLineRaw, 3) = "/c:" Then SCR_Options_Proc(StringLeft($CmdLineRaw, 3) = "/c:") EndIf Func SCR_Options_Proc($DisableParent=0) Local $iMsg, $ParentHwnd = 0 ;If "/c:" passed as commandline, that's mean that the "Options" button was pressed from the screensaver installation dialog ;therefore we can disable the parent dialog and open our Options dialog as child If $DisableParent = 1 Then $ParentHwnd = WinGetHandle("") WinSetState($ParentHwnd, "", @SW_DISABLE) EndIf Local $GUI = GuiCreate("ScreenSaver Options", 250, 120, -1, -1, -1, $WS_EX_TOOLWINDOW+$WS_EX_TOPMOST, $ParentHwnd) GUICtrlCreateLabel("Our Options go here", 30, 20, 200, 30) GUICtrlSetFont(-1, 16) Local $Preview_Button = GUICtrlCreateButton("Preview", 10, 80, 70, 20) GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ;Enable back the parent dialog If $DisableParent = 1 Then WinSetState($ParentHwnd, "", @SW_ENABLE) Exit Case $Preview_Button ScreenSaver_Proc() EndSwitch WEnd EndFunc Func ScreenSaver_Proc() MsgBox(262144+64, "ScreenSaver", "Our ScreenSaver") EndFunc
When we compile this script, and rename it from Script.exe to Script.scr, it will work as real ScreenSaver!!!
Or we can add this part of code to the begining of this script, and the compilation process will be executed when we start the script (If Not @Compiled)...
If Not @Compiled Then $AutoItPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") $AutoItExe = $AutoItPath & "\Aut2Exe\Aut2exe.exe" $SCR_Name = StringTrimRight(@ScriptName, 4) $SCR_Path = StringTrimRight(@ScriptFullPath, 3) & "scr" $SCR_Icon = $AutoItPath & "\Icons\filetype-blank.ico" RunWait($AutoItExe & ' /in "' & FileGetShortName(@ScriptFullPath) & '" /out "' & $SCR_Path & '" /icon "' & $SCR_Icon & '"') If @error Or Not FileExists($SCR_Path) Then MsgBox(48, "Error!", "There was an error to comile the SCR file.") Exit EndIf MsgBox(64, "Done!", "Compiling is finished!" & @LF & $SCR_Name & " is saved as:" & @LF & @LF & $SCR_Path) Exit EndIf
In the archive there is ready examples, one is Matrix (the best one ), and the others are simple runing text screensaver and obstraction example on how to built your own ScreenSaver.
ScreenShots of the Matrix ScreenSaver:
____ Options dialog: ScreenSaver FullScreen:
With this screensaver script, you can compile it from the Options dialog, after that the screensaver will be ready as stand-alone application (for the compiling process requierd AutoIt + the script itself must stay uncompiled).
The credits for this one goes to the Jex and to jokke - for the initial concept and the main engine of this screensaver.
It plays a background sound now
Previous total downloads: 9
[Dec 1 2007, 12:23 PM]:
- Now compatible with AutoIt 220.127.116.11.
- Few minor improvements to the code.
[Dec 01 2007, 12:27 AM]:
- Now the sound will loop untill the screensaver is closed (<Sound.au3> used).
- Now the preview in the desktop properties dialog displayed as it should be.
- Now the real Matrix font used for the letters falling.
- Now the screensaver program will not be executed if it called with the same command line again.
- Added options to set Begin/End Coolor of the Matrix letters.
- The array of letters now created at the start, instead of using every time Chr() - it was slowing down the MatrixInitialize() process.
- Fixed the bug with the font size - now the value is saved properly.
- Prevented High CPU usage by the screensaver in some cases.
[Nov 29 2007, 01:53 AM]:
- Now the sound can be Disabled/Enable.
- Now there is Option to set Matrix chars font size.
Edited by MrCreatoR, 21 May 2009 - 05:00 AM.