Sign in to follow this  
Followers 0
bb01

Random Screensaver

4 posts in this topic

#1 ·  Posted (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 by bb01

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by smartee

Share this post


Link to post
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...

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by AutoBert

Share this post


Link to post
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
Sign in to follow this  
Followers 0