bb01 Posted April 7, 2011 Share Posted April 7, 2011 (edited) Ok why's this not working... I'm looking to run a random screensaver from the script folder.. #include <Array.au3> #include <File.au3> $searchdir = @ScriptDir $FileList = _FileListToArray($searchdir, "*.scr") If @error = 4 Then MsgBox(0, "Wheres the Screensavers", "No Screensavers found" & _ @CRLF & 'Make sure theyre in "' & $searchdir & '"') Exit EndIf ; ---- $RFile is the Random Screensaver ----------- $RFile = Random($FileList) ShellExecuteWait($RFile) And all i keep getting is Windows cannot find 0 Edited April 7, 2011 by bb01 Link to comment Share on other sites More sharing options...
smartee Posted April 7, 2011 Share Posted April 7, 2011 (edited) You are using the wrong syntax for the random function. try replacing that line with$RFile = $searchdir & "\" & $FileList[(Random(1,$FileList[0],1))] EDIT: Added $searchdir part to $Rfile Edited April 7, 2011 by smartee Link to comment Share on other sites More sharing options...
bb01 Posted April 7, 2011 Author Share Posted April 7, 2011 Ahhh excellent.. thank you... i was sure that i was getting it right.. but couldn't work out why it wasn't doing it right.. Was even trying $RFile = Random($FileList ,1) to no avail... Thank you Smartee.. i wish there was a help file that actually did show things like this.. as the autoit help file only shows the basics & thats not a real lot to work from... Link to comment Share on other sites More sharing options...
AutoBert Posted April 8, 2011 Share Posted April 8, 2011 (edited) i wish there was a help file that actually did show things like this.. as the autoit help file only shows the basics & thats not a real lot to work from... When you learned the basics than it's easy to solve (like smartee). Remarks The array returned is one-dimensional and is made up as follows: $array[0] = Number of Files\Folders returned $array[1] = 1st File\Folder $array[2] = 2nd File\Folder $array[3] = 3rd File\Folder $array[n] = nth File\Folder Helpfile for _FileListToArray) Random Generates a pseudo-random float-type number. Random ( [Min [, Max [, Flag]]] ) Remarks ... By default the Random function works with decimal/floating point numbers. If you want to only have integer/whole number results then set the Flag to 1. so lear the basics the helpfile is very good. Edited April 8, 2011 by AutoBert 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