Opt('MustDeclareVars', 1)
Global $sDir = @ScriptDir & '\0', $aFiles, $sString = '|', $iRand
$aFiles = _FileSearch($sDir, '*', 1)
If @error Then Exit
ConsoleWrite('Files: ' & $aFiles[0] & @LF)
For $i = 1 To $aFiles[0]
$iRand = Random(1, $aFiles[0], 1)
While 1
$iRand = Random(1, $aFiles[0], 1)
If Not StringInStr($sString, '|' & $iRand & '|') Then
$sString &= $iRand & '|'
ExitLoop
EndIf
Sleep(2)
WEnd
;Send($aFiles[$iRand])
ConsoleWrite($i & @TAB & $iRand & @TAB & $aFiles[$iRand] & @LF)
Sleep(10000)
Next
MsgBox(64, 'Info', 'Кончились файлы :)')
Func _FileSearch($sPath, $sFileMask = "*", $iFlag = 0, $iSubDir = 1, $iSort = 0)
;CreatoR; http://autoit-script.ru/index.php/topic,8266.msg55775
Local $sOutBin, $sOut, $aOut, $sRead, $hDir, $sAttrib, $sFiles, $aMasks
If Not StringInStr(FileGetAttrib($sPath), "D") Then
Return SetError(1, 0, 0)
EndIf
If $iSubDir = 1 Then
$sAttrib &= ' /S'
EndIf
If $iSort = 1 Then
$sAttrib &= ' /O:N'
EndIf
Switch $iFlag
Case 1
$sAttrib &= ' /A-D'
Case 2
$sAttrib &= ' /AD'
Case Else
$sAttrib &= ' /A'
EndSwitch
$sOut = StringToBinary('0' & @CRLF, 2)
$sPath = StringRegExpReplace($sPath, '\\+$', '')
$sFileMask = StringRegExpReplace($sFileMask, '^;+|;+$', '')
$sFileMask = StringRegExpReplace($sFileMask, ';{2,}', ';')
$aMasks = StringSplit($sFileMask, ';')
For $i = 1 To $aMasks[0]
If StringStripWS($aMasks[$i], 8) = "" Then
ContinueLoop
EndIf
$sFiles &= '"' & $sPath & '\' & $aMasks[$i] & '"'
If $i < $aMasks[0] Then
$sFiles &= ';'
EndIf
Next
$hDir = Run(@ComSpec & ' /U /C DIR ' & $sFiles & ' /B' & $sAttrib, @SystemDir, @SW_HIDE, 6)
While 1
$sRead = StdoutRead($hDir, False, True)
If @error Then
ExitLoop
EndIf
If $sRead <> "" Then
$sOut &= $sRead
EndIf
Sleep(10)
WEnd
$aOut = StringRegExp(BinaryToString($sOut, 2), '[^\r\n]+', 3)
If @error Or UBound($aOut) < 2 Then
Return SetError(2, 0, 0)
EndIf
$aOut[0] = UBound($aOut) - 1
Return $aOut
EndFunc ;==>_FileSearch
>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "d:\Miscel\Pics\МОИ СКРИПТЫ\test.au3"
D:\Miscel\Pics\??? ???????\test.au3 (4) : ==> No variable given for "Dim", "Local", "Global", "Struct" or "Const" statement.:
Global $sDir = 'd:\Miscel\Pics\Old comp\',
Global $sDir = 'd:\Miscel\Pics\Old comp\',^ ERROR
>Exit code: 1 Time: 0.211
Opt('MustDeclareVars', 1)
;...
Global $sDir = 'd:\Miscel\Pics\Old comp\';...
;...
Global $sDir = @ScriptDir & '\0', $aFiles, $sString = '|', $iRand
$aFiles = _FileSearch($sDir, '*', 1)
If @error Then Exit
ConsoleWrite('Files: ' & $aFiles[0] & @LF)
For $i = 1 To $aFiles[0]
$iRand = Random(1, $aFiles[0], 1)
While 1
$iRand = Random(1, $aFiles[0], 1)
If Not StringInStr($sString, '|' & $iRand & '|') Then
$sString &= $iRand & '|'
ExitLoop
EndIf
Sleep(2)
WEnd
;Send($aFiles[$iRand])
ConsoleWrite($i & @TAB & $iRand & @TAB & $aFiles[$iRand] & @LF)
Sleep(10000)
Next
MsgBox(64, 'Info', 'Кончились файлы :)')
Func _FileSearch($sPath, $sFileMask = "*", $iFlag = 0, $iSubDir = 1, $iSort = 0)
;CreatoR; http://autoit-script.ru/index.php/topic,8266.msg55775
Local $sOutBin, $sOut, $aOut, $sRead, $hDir, $sAttrib, $sFiles, $aMasks
If Not StringInStr(FileGetAttrib($sPath), "D") Then
Return SetError(1, 0, 0)
EndIf
If $iSubDir = 1 Then
$sAttrib &= ' /S'
EndIf
If $iSort = 1 Then
$sAttrib &= ' /O:N'
EndIf
Switch $iFlag
Case 1
$sAttrib &= ' /A-D'
Case 2
$sAttrib &= ' /AD'
Case Else
$sAttrib &= ' /A'
EndSwitch
$sOut = StringToBinary('0' & @CRLF, 2)
$sPath = StringRegExpReplace($sPath, '\\+$', '')
$sFileMask = StringRegExpReplace($sFileMask, '^;+|;+$', '')
$sFileMask = StringRegExpReplace($sFileMask, ';{2,}', ';')
$aMasks = StringSplit($sFileMask, ';')
For $i = 1 To $aMasks[0]
If StringStripWS($aMasks[$i], 8) = "" Then
ContinueLoop
EndIf
$sFiles &= '"' & $sPath & '\' & $aMasks[$i] & '"'
If $i < $aMasks[0] Then
$sFiles &= ';'
EndIf
Next
$hDir = Run(@ComSpec & ' /U /C DIR ' & $sFiles & ' /B' & $sAttrib, @SystemDir, @SW_HIDE, 6)
While 1
$sRead = StdoutRead($hDir, False, True)
If @error Then
ExitLoop
EndIf
If $sRead <> "" Then
$sOut &= $sRead
EndIf
Sleep(10)
WEnd
$aOut = StringRegExp(BinaryToString($sOut, 2), '[^\r\n]+', 3)
If @error Or UBound($aOut) < 2 Then
Return SetError(2, 0, 0)
EndIf
$aOut[0] = UBound($aOut) - 1
Return $aOut
EndFunc ;==>_FileSearch
#include <Array.au3>
#include <File.au3>
For $i = 0 To 99
$iFlag = Random(0,1,0)
ConsoleWrite("line 1" & @LF) ; Line 1
ConsoleWrite("line 2" & @LF) ; Line 2
If $iFlag > 0.7 Then
$Dir = 'C:\Windows\System32\'
$Files = _FileListToArray($Dir, '*', 1)
Sleep(1000)
ConsoleWrite($Dir & $Files[Random(1, $Files[0], 1)])
EndIf
ConsoleWrite("line 5" & @LF) ; Line 5
Next
#include <File.au3>
#include <Array.au3>
HotKeySet('{ESC}', '_Exit')
$Dir = 'D:\Program Files\'
$Files = _FileListToArray($Dir, '*', 1)
While 1
;~ Sleep(10000)
if $Files[0]=1 Then
$id=1
Else
$id=Random(1, $Files[0], 1)
EndIf
;~ Send($Dir & $Files[$id])
ConsoleWrite($Files[$id]& '-'&$Files[0]&'-'&$id&@LF)
_ArrayDelete ( $Files,$id)
$Files[0]=UBound($Files)-1
if $Files[0]=0 Then Exit
WEnd
Func _Exit()
Exit
EndFunc
Попробуйте для этого использовать _RandomEx вместо Random в моем 1 посте:Нужно чтобы засылаемые имена файлов НЕ повторялись.