james3mg Posted March 27, 2007 Share Posted March 27, 2007 (edited) Here's take one of a Windows version of a feature I like in most Linux distros - the "Random" screensaver. I know there's probably programs that do this for you, but I like writing them myself, and AutoIt's the best anyway This is extremely basic, and hopefully actually runs, unlike some of my other scripts lately when I've gone to post them here. The only configuration it allows is you can select/deselect any individual screensaver, so that the annoying screensaver you don't like but keep around for some reason won't ever be used by this script as your screensaver.Edit: Now you can choose to have it cycle through your selected screensavers every 'x' minutes too.It's just take one two three because there's a few features I'm considering:1) Having each screensaver only show up for a selected number of minutes at a time. I didn't include this because I haven't tested what happens to the screen between the time I'm switching from one screensaver to another - is the desktop shown for a moment, or longer? This can be a security concern in some environments.Edit:Thanks to fear1313, this shouldn't be an issue anymore, and I figured out how to save the config data, so this is now included.2) Allowing configuration of each screensaver from within this script. Seemed a little clunky, and I'm not sure everyone would realize this wouldn't just configure the screensaver only when the Random screensaver was running. That is, if you modified the Marquee text from within this script (which just passes the configure command through to the Marquee screensaver program as if Windows had called it itself), then they go back and re-select just Marquee as their screensaver, I'm not sure it's obvious that the changes you made within Random would still govern the Marquee screensaver as a standalone. Opting toward simplicity and clarity, I omitted this for the time being.Edit: 3) Allowing the user to select if their desktop is forcefully hidden or not. Currently, it always is, to mitigate the security concern as well as a potential for annoying flashing between the screensavers, but I might add an option that would allow screensavers that happen "over" a background picture of what your desktop currently looks like (old-style "mystify your mind" or Vista's "Bubbles", being two examples). Primarily I didn't include this yet because I'm lazy.So try this out - I hope everyone really likes it. I like randomizing my desktop, if you can't tell by my last few posts Thanks, as always, to the entire AutoIt team! Please let me know what you think!Oh, to run this as your screensaver, it has to be compiled to SSRandom.exe. Then rename it to SSRandom.scr and copy it to your @WindowsDir\System32 directory. Now get into your Screensaver Config dialog and choose Random from the drop-down list and click Preview.If you tried the previous versions of this script, please delete RandomScreensaverExclusions from @userprofiledir before you try this one. Due to features being added, I've changed slightly how it reads this file, but I didn't want to build in interpertation of old formats.expandcollapse popup#NoTrayIcon #include <File.au3> #include <GuiTreeView.au3> #include <GUIConstants.au3> Global $rand Global Const $SM_VIRTUALWIDTH = 78 Global Const $SM_VIRTUALHEIGHT = 79 $VIRTUALDESKTOPWIDTH = DLLCall("user32.dll","int","GetSystemMetrics","int",$SM_VIRTUALWIDTH) $VIRTUALDESKTOPWIDTH = $VIRTUALDESKTOPWIDTH[0] $VIRTUALDESKTOPHEIGHT = DLLCall("user32.dll","int","GetSystemMetrics","int",$SM_VIRTUALHEIGHT) $VIRTUALDESKTOPHEIGHT = $VIRTUALDESKTOPHEIGHT[0] ;;Create the Configure GUI $ConfigGUI=GUICreate("Configure Random Screensaver",300,180) GUICtrlCreateLabel("Uncheck any screensavers you don't want showing up:",5,0) $SSList=GUICtrlCreateTreeView(0,20,300,100,$GUI_SS_DEFAULT_TREEVIEW+$TVS_CHECKBOXES) ;You could put a button here to configure the highlighted screensaver by running the highlighted text with " /c" appended to it, but I elected to leave it out. $RotateCheckbox=GUICtrlCreateCheckbox("Change the screensaver every",5,125,165,20) $RotateInputTime=GUICtrlCreateInput("",170,125,60,20) GUICtrlCreateUpdown($RotateInputTime,$UDS_NOTHOUSANDS) GUICtrlSetLimit(-1,1440,1) GUICtrlCreateLabel("minutes",235,127,75,20) $CancelButton=GUICtrlCreateButton("Cancel",100,155,50,20) $SaveButton=GUICtrlCreateButton("Save",150,155,50,20) $HelpButton=GUICtrlCreateButton("?",275,155,20,20) ;;End Create the Configure GUI If StringLeft($CmdLineRaw,2) = "/c" Then;they clicked the "Configure button" while this was selected as the current screensaver; enter configuration for SSRandom.scr $SSes=_FileListToArray(@WindowsDir&"\System32","*.scr");list all screensavers 'installed' on this machine (lit. present in System32) If NOT IsArray($SSes) Then Exit;no screensavers 'installed' Global $ExcludedArray=StringSplit(FileRead(@UserProfileDir&"\RandomScreensaverExclusions"),"|") If @error Then Global $ExcludedArray[3]=["2","1","30"];if there aren't any excluded screensavers, create an array to simulate a return from StringSplit with options pre-configured Global $TreeViewItems[1]=[0];This array stores the ID numbers of all the treeview items; [0] is the number of items present Global $RotateScreensaver=$ExcludedArray[$ExcludedArray[0]-1] Global $RotateTime=$ExcludedArray[$ExcludedArray[0]] For $i=1 To $SSes[0] If $SSes[$i] = "SSRandom.scr" Then ContinueLoop;you don't want to see this screensaver in the list $TreeViewItems[0]+=1 ReDim $TreeViewItems[$TreeViewItems[0]+1] $TreeViewItems[$TreeViewItems[0]]=GUICtrlCreateTreeViewItem($SSes[$i],$SSList) GUICtrlSetState(-1,$GUI_CHECKED);checked by default (thus included in the random rotation) For $n=1 To $ExcludedArray[0] If $SSes[$i]=$ExcludedArray[$n] Then GUICtrlSetState(-1,$GUI_UNCHECKED);uncheck it if the string is found in RandomScreensaverExclusions file ExitLoop EndIf Next Next GUICtrlSetData($RotateInputTime,$RotateTime) If $RotateScreensaver=1 Then GUICtrlSetState($RotateCheckbox,$GUI_CHECKED) Else GUICtrlSetState($RotateCheckbox,$GUI_UNCHECKED) EndIf GUISetState(@SW_SHOW);done filling in the treeview; show the GUI GUILoop() Exit;redundant from the Close and Cancel button handlers in the loop; better safe than sorry EndIf ;enter 'normal' operation...anything other than configure mode. Parameters are passed through to random screensaver, ensuring previews work, etc $SSes=_FileListToArray(@WindowsDir&"\System32","*.scr") If NOT IsArray($SSes) Then Exit Global $ExcludedArray=StringSplit(FileRead(@UserProfileDir&"\RandomScreensaverExclusions"),"|") If @error Then Global $ExcludedArray[3]=["2","1","30"] Global $RotateScreensaver=$ExcludedArray[$ExcludedArray[0]-1] Global $RotateTime=$ExcludedArray[$ExcludedArray[0]] Func PickSaver() While 1;loop through until a screensaver is picked that's not in the excluded list. IF good screensaver is picked the first time, this method will net better performance over deleting array elements in the exclusion list. $rand=Random(1,$SSes[0],1) $Excluded=0 For $i=1 To $ExcludedArray[0]-2 If $SSes[$rand]=$ExcludedArray[$i] Then;this screensaver's name was found in the exclusion list file; loop again to pick another screensaver $Excluded=1 ExitLoop EndIf Next If NOT $Excluded Then ExitLoop;don't loop again; this screensaver's name was not found in the exclusion list file. WEnd EndFunc PickSaver() $SwitchTimer=TimerInit() Run($SSes[$rand] & " " & $CmdLineRaw,@WindowsDir&"\System32");run the screensaver, passing all parameters through to it, ensuring previews, etc work $hideDesktopWin=GUICreate("Hide the desktop",$VIRTUALDESKTOPWIDTH,$VIRTUALDESKTOPHEIGHT,0,0,$WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) GUISetBkColor(0x000000,$hideDesktopWin) If NOT StringInStr($CmdLineRaw,"/p") Then GUISetState(@SW_SHOW,$hideDesktopWin) EndIf While 1 If NOT ProcessExists($SSes[$rand]) Then Exit If TimerDiff($SwitchTimer) > ($RotateTime*60000) AND $RotateScreensaver Then ProcessClose($SSes[$rand]) $oldSS=$SSes[$rand] Do PickSaver() Until $SSes[$rand] <> $oldSS $SwitchTimer=TimerInit() Run($SSes[$rand] & " " & $CmdLineRaw,@WindowsDir&"\System32");run the screensaver, passing all parameters through to it, ensuring previews, etc work EndIf Sleep(50) WEnd Func GUILoop();called and run only when Configure button is clicked from Windows' Screen Saver dialog While 1 $msg=GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $CancelButton Exit Case $SaveButton $SaveFile=FileOpen(@UserProfileDir&"\RandomScreensaverExclusions",2) FileWrite($SaveFile,"SSRandom.scr|") For $i=1 To $TreeViewItems[0] If NOT BitAnd(GUICtrlRead($TreeViewItems[$i]),$GUI_CHECKED) Then FileWrite($SaveFile,_GUICtrlTreeViewGetText($SSList,$TreeViewItems[$i])&"|") Next $RotateScreensaver=BitAND(GUICtrlRead($RotateCheckbox),$GUI_CHECKED) If GUICtrlRead($RotateInputTime) = "" Then GUICtrlSetData($RotateInputTime,1) $RotateTime=GUICtrlRead($RotateInputTime) FileWrite($SaveFile,$RotateScreensaver&"|"&$RotateTime) FileClose($SaveFile) Exit Case $HelpButton MsgBox(0,"Help and About","Random Screensaver (SSRandom.exe) is written and copyright by james3mg from the AutoIt Forums (http://www.autoitscript.com/forum), 2007."&@CRLF&@CRLF&"Uncheck any screensavers you don't want displayed in the random rotation, then choose if you want it to cycle through different screensavers every so many minutes, instead of just each time your computer is idle. Configure each individual screensaver by selecting it in the Display Properties/Screen Saver dialog of your Windows PC and choosing 'Configure'. Data is stored in 'RandomScreensaverExclusions' file under your profile."&@CRLF&@CRLF&"Thanks to everyone affilated with AutoIt!") EndSwitch WEnd EndFuncIf you tried the previous versions of this script, please delete RandomScreensaverExclusions from @userprofiledir before you try this one. Due to features being added, I've changed slightly how it reads this file, but I didn't want to build in interpertation of old formats. Edited April 3, 2007 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 More sharing options...
magician13134 Posted March 27, 2007 Share Posted March 27, 2007 I can't run these at school, can I get a SS? Visit Magic Soft Inc. for some of my software Link to comment Share on other sites More sharing options...
james3mg Posted March 27, 2007 Author Share Posted March 27, 2007 I can't run these at school, can I get a SS?Google "Free Screensavers" to find more than you can handle Careful though, if your school doesn't have any screensavers on their computers, they may not want you loading any either... "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 More sharing options...
james3mg Posted March 28, 2007 Author Share Posted March 28, 2007 (edited) I won't bump more than once, but... Did anyone try/like this? anyone? ...Bueller? I can upload the compiled .scr version of this script if it would help, then you could just copy it into your system32 directory and choose "Random" as your current screensaver... .... .. ... . any takers? Edited March 28, 2007 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 More sharing options...
Richard Robertson Posted March 29, 2007 Share Posted March 29, 2007 Looks nice but has no real world use. It is entertaining to some extent. I just never use a screensaver, as I have my laptop standby instead of screen save. Link to comment Share on other sites More sharing options...
james3mg Posted March 29, 2007 Author Share Posted March 29, 2007 Looks nice but has no real world use.It is entertaining to some extent. I just never use a screensaver, as I have my laptop standby instead of screen save.Fair enough, I was trying to incorporate GetCoffee(@Username,"Starbucks") into it for the real world use, but it kept returning Folgers coffee instead, so I scrapped it Just kidding, but a lot of people do use screensavers. I enjoy making small scripts like this, and just thought I'd share it with the community, since there are some programs out there that do the same thing that people actually ask money for. Glad you found it entertaining though, thanks And thanks for the reply...I was starting to feel lonely "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 More sharing options...
testingtest Posted March 30, 2007 Share Posted March 30, 2007 I compile the script but doesn't work Link to comment Share on other sites More sharing options...
james3mg Posted March 30, 2007 Author Share Posted March 30, 2007 I compile the script but doesn't work Did you rename it to SSRandom.scr once it was compiled, then move it into @WindowsDir\System32 ?Once you do that, select "Random" as your current screensaver in your windows control panel.If you did all that, let me know and I'll try to get you the working file directly. "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 More sharing options...
BillLuvsU Posted March 30, 2007 Share Posted March 30, 2007 It's cool. as to revealing the desktop when swithing screensavers, create a full screen GUI with a black background so that when the screensaver dies all you see is black. Cool idea though! [center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw Link to comment Share on other sites More sharing options...
testingtest Posted March 30, 2007 Share Posted March 30, 2007 (edited) pretty cool i didn't read top post sorry lol Edited March 30, 2007 by testingtest Link to comment Share on other sites More sharing options...
james3mg Posted March 30, 2007 Author Share Posted March 30, 2007 It's cool. as to revealing the desktop when swithing screensavers, create a full screen GUI with a black background so that when the screensaver dies all you see is black. Cool idea though!That's the right idea...thanks I'll give it a try and see if I can jump the other hurdles I expect when I do that... I'll post it here if I get it working@testingtest: glad it's working, thanks for the feedback! "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 More sharing options...
james3mg Posted April 3, 2007 Author Share Posted April 3, 2007 I've added a few features...see edited first post! "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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now