Here's the code snippet I came up with, but I seem to have trouble the second I use a Default keyword in my udf. Any help with that would be greatly appreciated.
Otherwise, it correctly searches for files based upon the filetype you specify (*.*, *.pdf, *.jpg, *.gif, etc).
Func RandomFile($FileType = '*', $Directory = @WorkingDir)
FileChangeDir(@WorkingDir)
$Handle = FileFindFirstFile(@WorkingDir & '\' & $FileType)
If $Handle = -1 Then Return 0
Local $FileCount = 0, $aFiles[1], $cache
While True
$cache = FileFindNextFile($Handle)
If @error then ExitLoop
If StringInStr(FileGetAttrib($cache), 'd') then ContinueLoop
Redim $aFiles[UBound($aFiles)+1]
$aFiles[UBound($aFiles)-1] = @WorkingDir & '\' & $cache
$FileCount += 1
WEnd
FileClose($Handle)
Return $aFiles[Random(1, $FileCount, 1)]
EndFunc
While True
MsgBox(0, "", RandomFile())
;MsgBox(0, "Test2", RandomFile(Default))
WEnd