Jump to content

Random Screensaver


Recommended Posts

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 by bb01
Link to comment
Share on other sites

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 by smartee
Link to comment
Share on other sites

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

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